Skip to content

fix(cli): mute interactions on non tty sessions#172

Open
coryrylan wants to merge 3 commits into
mainfrom
topic-lint-rule-fixes
Open

fix(cli): mute interactions on non tty sessions#172
coryrylan wants to merge 3 commits into
mainfrom
topic-lint-rule-fixes

Conversation

@coryrylan

@coryrylan coryrylan commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added an ESLint rule that flags <label> usage for form controls inside compact page headers/toolbars and recommends using aria-label.
    • Documented the new lint rule in the Elements Lint guide.
  • Bug Fixes

    • Suppressed the CLI banner in non-interactive terminals while keeping the CLI identifier.
    • Spinner/progress output now more reliably respects terminal interactivity settings.
    • Reduced tool/service result caps to return up to 3 items instead of 5.
  • Documentation

    • Improved JSDoc descriptions for PagePanel open/close behavior and sort event detail.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR gates CLI banner and spinner output on terminal interactivity, lowers the shared api/examples result limit from 5 to 3 with matching tests, updates packages service test expectations, clarifies component JSDoc, and adds a new ESLint rule with config, tests, and docs.

Changes

Mixed CLI, tools, docs, and lint updates

Layer / File(s) Summary
Interactive terminal detection and spinner gating
projects/cli/src/utils.ts, projects/cli/src/utils.test.ts
Adds interactive terminal detection helpers and updates async tool progress handling to require a TTY on stderr before showing the spinner; tests restore isTTY state and cover non-interactive execution.
Banner suppression on non-interactive stdout
projects/cli/src/index.ts, projects/cli/src/index.test.ts
CLI greeting generation now checks stdout interactivity before rendering the banner, and the index test suite adds coverage for non-interactive output plus the updated api.get limit expectation.
API and examples result limit reduction
projects/internals/tools/src/api/service.ts, projects/internals/tools/src/api/service.test.ts, projects/internals/tools/src/examples/service.ts, projects/internals/tools/src/examples/service.test.ts
Reduces the shared result limit from 5 to 3 in api and examples services, and updates their metadata and output assertions to match the new cap.
Packages service test parity update
projects/internals/tools/src/packages/service.test.ts
Packages service tests now derive the expected package set from the changelogs input schema enum and validate the core package version with a semver pattern.
Component JSDoc updates
projects/core/src/page/page-panel/page-panel.ts, projects/core/src/sort-button/sort-button.ts
Revises the page-panel and sort-button JSDoc entries to describe event timing and sort-state progression more explicitly.
Prefer aria-label lint rule
projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.ts, projects/lint/src/eslint/configs/html.ts, projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.test.ts, projects/lint/README.md, projects/site/src/docs/lint/index.md
Adds a new HTML ESLint rule that reports <label> usage inside compact containers, registers it in the HTML config, covers it with RuleTester cases, and documents it in lint references.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • NVIDIA/elements#155: Shares the CLI interactivity and spinner-related changes in projects/cli/src/utils.ts and projects/cli/src/index.ts.

Suggested reviewers: johnyanarella, jareddlc

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 matches the CLI non-TTY suppression work, though it omits the other lint, docs, and internal limit changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch topic-lint-rule-fixes

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

projects/cli/src/index.test.ts

Parsing error: error TS5012: Cannot read file '/tsconfig.json': ENOENT: no such file or directory, open '/tsconfig.json'.

projects/cli/src/utils.test.ts

Parsing error: error TS5012: Cannot read file '/tsconfig.json': ENOENT: no such file or directory, open '/tsconfig.json'.

projects/core/src/page/page-panel/page-panel.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

  • 5 others

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.test.ts`:
- Line 11: The `preferAriaLabelInCompactContainers` test setup is using a double
cast to `JSRuleDefinition`, which bypasses type safety and hides incompatible
rule-shape changes. Update the assertion in the test to rely on proper
structural typing or an explicit type guard instead of `as unknown as`, and keep
the check aligned with the actual rule object shape used by
`preferAriaLabelInCompactContainers`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: b9467d34-774e-4690-a8f0-63c1d47b9b0a

📥 Commits

Reviewing files that changed from the base of the PR and between 0ff44a6 and 96ff3a5.

📒 Files selected for processing (16)
  • projects/cli/src/index.test.ts
  • projects/cli/src/index.ts
  • projects/cli/src/utils.test.ts
  • projects/cli/src/utils.ts
  • projects/core/src/page/page-panel/page-panel.ts
  • projects/core/src/sort-button/sort-button.ts
  • projects/internals/tools/src/api/service.test.ts
  • projects/internals/tools/src/api/service.ts
  • projects/internals/tools/src/examples/service.test.ts
  • projects/internals/tools/src/examples/service.ts
  • projects/internals/tools/src/packages/service.test.ts
  • projects/lint/README.md
  • projects/lint/src/eslint/configs/html.ts
  • projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.test.ts
  • projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.ts
  • projects/site/src/docs/lint/index.md

import { elementsHtmlConfig } from '../configs/html.js';
import preferAriaLabelInCompactContainers from './prefer-aria-label-in-compact-containers.js';

const rule = preferAriaLabelInCompactContainers as unknown as JSRuleDefinition;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Double unknown cast bypasses type checking for the rule shape.

preferAriaLabelInCompactContainers as unknown as JSRuleDefinition sidesteps structural type checking between the custom rule object and ESLint's expected rule type, so a future incompatible change to the rule shape wouldn't be caught here.

As per coding guidelines, **/*.ts files should follow /projects/site/src/docs/internal/guidelines/typescript.md for type safety and type guards.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.test.ts`
at line 11, The `preferAriaLabelInCompactContainers` test setup is using a
double cast to `JSRuleDefinition`, which bypasses type safety and hides
incompatible rule-shape changes. Update the assertion in the test to rely on
proper structural typing or an explicit type guard instead of `as unknown as`,
and keep the check aligned with the actual rule object shape used by
`preferAriaLabelInCompactContainers`.

Source: Coding guidelines

@coryrylan coryrylan requested a review from jareddlc July 2, 2026 23:05
@coryrylan coryrylan force-pushed the topic-lint-rule-fixes branch from 96ff3a5 to d002590 Compare July 8, 2026 15:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@projects/internals/tools/src/packages/service.test.ts`:
- Line 99: The `PackagesService.changelogsGet as ToolMethod<unknown>` cast is
bypassing TypeScript’s type safety in the test. Update the test to use the
actual `PackagesService.changelogsGet` type directly, or adjust the `ToolMethod`
typing so `inputSchema` can be accessed without an unsafe cast. Keep the change
localized around `changelogsGet` and `metadata.inputSchema`, and prefer
inference or proper narrowing over asserting to `ToolMethod<unknown>`.

In `@projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.ts`:
- Around line 27-70: The ESLint rule object is only inferred from the literal,
so it is not being checked against the expected rule type. Update the `rule`
definition in `prefer-aria-label-in-compact-containers` to use an explicit
`Rule.RuleModule` or `JSRuleDefinition` annotation while keeping the existing
`create` and `meta` structure, so future changes are type-validated instead of
relying on `as const` alone.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: e0b11890-a4d6-4dfe-8108-aabdfa24254a

📥 Commits

Reviewing files that changed from the base of the PR and between 96ff3a5 and d002590.

📒 Files selected for processing (16)
  • projects/cli/src/index.test.ts
  • projects/cli/src/index.ts
  • projects/cli/src/utils.test.ts
  • projects/cli/src/utils.ts
  • projects/core/src/page/page-panel/page-panel.ts
  • projects/core/src/sort-button/sort-button.ts
  • projects/internals/tools/src/api/service.test.ts
  • projects/internals/tools/src/api/service.ts
  • projects/internals/tools/src/examples/service.test.ts
  • projects/internals/tools/src/examples/service.ts
  • projects/internals/tools/src/packages/service.test.ts
  • projects/lint/README.md
  • projects/lint/src/eslint/configs/html.ts
  • projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.test.ts
  • projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.ts
  • projects/site/src/docs/lint/index.md

const listSet = new Set(Array.from(list.matchAll(/^## (\S+) v/gm), m => m[1]));

it('should expose the same package set in the changelogs schema and unknown-package error', async () => {
const schema = (PackagesService.changelogsGet as ToolMethod<unknown>).metadata.inputSchema;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Type cast bypasses type safety.

PackagesService.changelogsGet as ToolMethod<unknown> casts around the actual type instead of narrowing it. Consider whether ToolMethod can be inferred/typed directly on changelogsGet to avoid the cast, per TypeScript guidance on type safety.

As per coding guidelines, "When working with TypeScript code, follow /projects/site/src/docs/internal/guidelines/typescript.md for type safety, type guards, discriminated unions, and exhaustive checking."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@projects/internals/tools/src/packages/service.test.ts` at line 99, The
`PackagesService.changelogsGet as ToolMethod<unknown>` cast is bypassing
TypeScript’s type safety in the test. Update the test to use the actual
`PackagesService.changelogsGet` type directly, or adjust the `ToolMethod` typing
so `inputSchema` can be accessed without an unsafe cast. Keep the change
localized around `changelogsGet` and `metadata.inputSchema`, and prefer
inference or proper narrowing over asserting to `ToolMethod<unknown>`.

Source: Coding guidelines

Comment on lines +27 to +70
const rule = {
meta: {
type: 'problem' as const,
docs: {
description: 'Prefer aria-label on form controls inside toolbars and page headers.',
category: 'Best Practice',
recommended: true,
url: `${__ELEMENTS_PAGES_BASE_URL__}/docs/lint/`
},
schema: [],
messages: {
['prefer-aria-label']:
'Remove <label> from <{{control}}> inside <{{container}}> and use aria-label instead to preserve the compact layout.'
}
},
create(context: Rule.RuleContext) {
return createVisitors(context, {
Tag(node: HtmlTagNode) {
if (node.name.toLowerCase() !== 'label') {
return;
}

const control = findAncestor(node.parent, FORM_CONTROLS);
if (!control) {
return;
}

const container = findAncestor(control.parent, COMPACT_CONTAINERS);
if (!container) {
return;
}

context.report({
node,
messageId: 'prefer-aria-label',
data: {
control: control.name.toLowerCase(),
container: container.name.toLowerCase()
}
});
}
});
}
} as const;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Rule object lacks an explicit Rule.RuleModule (or JSRuleDefinition) type annotation.

rule is inferred purely from the object literal (with as const), so there's no structural check against ESLint's rule type. This is likely why the test file needed as unknown as JSRuleDefinition — the object shape isn't verified to satisfy ESLint's expected type, so an incompatible future change (e.g. renaming create, mistyped meta) wouldn't be caught at compile time here.

As per coding guidelines, **/*.ts files should follow /projects/site/src/docs/internal/guidelines/typescript.md for type safety and type guards.

♻️ Proposed fix
-const rule = {
+const rule: Rule.RuleModule = {
   meta: {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const rule = {
meta: {
type: 'problem' as const,
docs: {
description: 'Prefer aria-label on form controls inside toolbars and page headers.',
category: 'Best Practice',
recommended: true,
url: `${__ELEMENTS_PAGES_BASE_URL__}/docs/lint/`
},
schema: [],
messages: {
['prefer-aria-label']:
'Remove <label> from <{{control}}> inside <{{container}}> and use aria-label instead to preserve the compact layout.'
}
},
create(context: Rule.RuleContext) {
return createVisitors(context, {
Tag(node: HtmlTagNode) {
if (node.name.toLowerCase() !== 'label') {
return;
}
const control = findAncestor(node.parent, FORM_CONTROLS);
if (!control) {
return;
}
const container = findAncestor(control.parent, COMPACT_CONTAINERS);
if (!container) {
return;
}
context.report({
node,
messageId: 'prefer-aria-label',
data: {
control: control.name.toLowerCase(),
container: container.name.toLowerCase()
}
});
}
});
}
} as const;
const rule: Rule.RuleModule = {
meta: {
type: 'problem' as const,
docs: {
description: 'Prefer aria-label on form controls inside toolbars and page headers.',
category: 'Best Practice',
recommended: true,
url: `${__ELEMENTS_PAGES_BASE_URL__}/docs/lint/`
},
schema: [],
messages: {
['prefer-aria-label']:
'Remove <label> from <{{control}}> inside <{{container}}> and use aria-label instead to preserve the compact layout.'
}
},
create(context: Rule.RuleContext) {
return createVisitors(context, {
Tag(node: HtmlTagNode) {
if (node.name.toLowerCase() !== 'label') {
return;
}
const control = findAncestor(node.parent, FORM_CONTROLS);
if (!control) {
return;
}
const container = findAncestor(control.parent, COMPACT_CONTAINERS);
if (!container) {
return;
}
context.report({
node,
messageId: 'prefer-aria-label',
data: {
control: control.name.toLowerCase(),
container: container.name.toLowerCase()
}
});
}
});
}
} as const;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.ts`
around lines 27 - 70, The ESLint rule object is only inferred from the literal,
so it is not being checked against the expected rule type. Update the `rule`
definition in `prefer-aria-label-in-compact-containers` to use an explicit
`Rule.RuleModule` or `JSRuleDefinition` annotation while keeping the existing
`create` and `meta` structure, so future changes are type-validated instead of
relying on `as const` alone.

Source: Coding guidelines

@coryrylan coryrylan changed the title Topic lint rule fixes fix(cli): mute interactions on non tty sessions Jul 9, 2026
coryrylan added 3 commits July 9, 2026 12:42
- Introduced a new ESLint rule to enforce the use of aria-label on form controls within compact containers (e.g., toolbars and page headers)

Signed-off-by: Cory Rylan <crylan@nvidia.com>
Signed-off-by: Cory Rylan <crylan@nvidia.com>
Signed-off-by: Cory Rylan <crylan@nvidia.com>
@coryrylan coryrylan force-pushed the topic-lint-rule-fixes branch from d002590 to 08ed588 Compare July 9, 2026 16:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.ts (1)

27-70: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Missing explicit Rule.RuleModule type annotation on rule.

Same concern raised previously: the object literal is only inferred via as const, with no structural check against ESLint's rule type, which is why the test file needs as unknown as JSRuleDefinition.

♻️ Proposed fix
-const rule = {
+const rule: Rule.RuleModule = {
   meta: {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.ts`
around lines 27 - 70, The `rule` object in
`prefer-aria-label-in-compact-containers` is only inferred with `as const`, so
it is not being checked against ESLint’s rule contract. Add an explicit
`Rule.RuleModule` annotation (or equivalent typed rule definition) to the `rule`
constant so `meta`, `messages`, and `create(context)` are validated
structurally. Keep the existing `createVisitors`-based implementation and `Tag`
visitor, but make sure the exported rule is typed directly instead of relying on
downstream casts like `JSRuleDefinition`.
projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.test.ts (1)

11-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Double unknown cast bypasses type checking for the rule shape.

Same concern as flagged previously — casting through unknown hides incompatible shape changes between the custom rule object and ESLint's JSRuleDefinition. Resolving this depends on adding the Rule.RuleModule annotation in the rule file (see comment there).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.test.ts`
at line 11, The test is bypassing type safety by casting
preferAriaLabelInCompactContainers through unknown to JSRuleDefinition, which
can hide shape mismatches. Update the test to use the rule’s proper typed export
once the rule file is annotated with Rule.RuleModule, and remove the double cast
so the compiler validates the rule shape directly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@projects/internals/tools/src/packages/service.test.ts`:
- Around line 99-100: The `PackagesService.changelogsGet` metadata access in
`service.test.ts` is not fully guarded for optional values. Update the
`ToolMethod.metadata` lookup so `inputSchema` is accessed only through optional
chaining, and also guard the `name` property before reading `enum` when building
`schemaSet`. Use the existing `PackagesService.changelogsGet` and
`schema`/`schemaSet` test setup to keep the change localized and compatible with
strict null checks.

---

Duplicate comments:
In
`@projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.test.ts`:
- Line 11: The test is bypassing type safety by casting
preferAriaLabelInCompactContainers through unknown to JSRuleDefinition, which
can hide shape mismatches. Update the test to use the rule’s proper typed export
once the rule file is annotated with Rule.RuleModule, and remove the double cast
so the compiler validates the rule shape directly.

In `@projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.ts`:
- Around line 27-70: The `rule` object in
`prefer-aria-label-in-compact-containers` is only inferred with `as const`, so
it is not being checked against ESLint’s rule contract. Add an explicit
`Rule.RuleModule` annotation (or equivalent typed rule definition) to the `rule`
constant so `meta`, `messages`, and `create(context)` are validated
structurally. Keep the existing `createVisitors`-based implementation and `Tag`
visitor, but make sure the exported rule is typed directly instead of relying on
downstream casts like `JSRuleDefinition`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: ceb1d10a-9196-44cc-8315-371d950b4bf5

📥 Commits

Reviewing files that changed from the base of the PR and between d002590 and 08ed588.

📒 Files selected for processing (16)
  • projects/cli/src/index.test.ts
  • projects/cli/src/index.ts
  • projects/cli/src/utils.test.ts
  • projects/cli/src/utils.ts
  • projects/core/src/page/page-panel/page-panel.ts
  • projects/core/src/sort-button/sort-button.ts
  • projects/internals/tools/src/api/service.test.ts
  • projects/internals/tools/src/api/service.ts
  • projects/internals/tools/src/examples/service.test.ts
  • projects/internals/tools/src/examples/service.ts
  • projects/internals/tools/src/packages/service.test.ts
  • projects/lint/README.md
  • projects/lint/src/eslint/configs/html.ts
  • projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.test.ts
  • projects/lint/src/eslint/rules/prefer-aria-label-in-compact-containers.ts
  • projects/site/src/docs/lint/index.md

Comment on lines +99 to +100
const schema = (PackagesService.changelogsGet as ToolMethod<unknown>).metadata.inputSchema;
const schemaSet = new Set(schema?.properties?.name.enum ?? []);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
fd tsconfig.json projects/internals/tools -x cat {}
fd tsconfig.json -x cat {} \; 2>/dev/null | rg -n 'strict'

Repository: NVIDIA/elements

Length of output: 2036


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== service.test.ts excerpt ==\n'
cat -n projects/internals/tools/src/packages/service.test.ts | sed -n '80,115p'

printf '\n== ToolMethod definition ==\n'
rg -n "type ToolMethod|interface ToolMethod|export .*ToolMethod" projects/internals/tools/src -g '*.ts' -A 8 -B 4

printf '\n== metadata / inputSchema / properties usage ==\n'
rg -n "\.metadata(\?|)\.inputSchema|properties\?\.name\.enum|properties\?\.name\?\.enum|name\.enum" projects/internals/tools/src -g '*.ts' -A 2 -B 2

Repository: NVIDIA/elements

Length of output: 16152


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== ToolMetadata / Schema definitions ==\n'
cat -n projects/internals/tools/src/internal/tools.ts | sed -n '1,120p'

printf '\n== packages service schema setup ==\n'
rg -n "changelogsGet|inputSchema|properties|enum" projects/internals/tools/src/packages -g '*.ts' -A 4 -B 4

Repository: NVIDIA/elements

Length of output: 13579


Guard the optional metadata chain here projects/internals/tools/src/packages/service.test.ts:99-100

ToolMethod.metadata is optional, so .metadata.inputSchema can trip strict null checks, and schema?.properties?.name.enum still leaves name unguarded. Use optional chaining on both access paths.

🛡️ Proposed fix for consistent optional chaining
-    const schema = (PackagesService.changelogsGet as ToolMethod<unknown>).metadata.inputSchema;
-    const schemaSet = new Set(schema?.properties?.name.enum ?? []);
+    const schema = (PackagesService.changelogsGet as ToolMethod<unknown>).metadata?.inputSchema;
+    const schemaSet = new Set(schema?.properties?.name?.enum ?? []);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const schema = (PackagesService.changelogsGet as ToolMethod<unknown>).metadata.inputSchema;
const schemaSet = new Set(schema?.properties?.name.enum ?? []);
const schema = (PackagesService.changelogsGet as ToolMethod<unknown>).metadata?.inputSchema;
const schemaSet = new Set(schema?.properties?.name?.enum ?? []);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@projects/internals/tools/src/packages/service.test.ts` around lines 99 - 100,
The `PackagesService.changelogsGet` metadata access in `service.test.ts` is not
fully guarded for optional values. Update the `ToolMethod.metadata` lookup so
`inputSchema` is accessed only through optional chaining, and also guard the
`name` property before reading `enum` when building `schemaSet`. Use the
existing `PackagesService.changelogsGet` and `schema`/`schemaSet` test setup to
keep the change localized and compatible with strict null checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant