-
Notifications
You must be signed in to change notification settings - Fork 6
fix(cli): mute interactions on non tty sessions #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -95,24 +95,23 @@ describe('PackagesService', () => { | |||||||||
| expect((limited as string).length).toBeLessThanOrEqual((full as string).length); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| it('should expose the same package set in list and changelogs-unknown-package error', async () => { | ||||||||||
| const list = (await PackagesService.list()) as string; | ||||||||||
| 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; | ||||||||||
| const schemaSet = new Set(schema?.properties?.name.enum ?? []); | ||||||||||
|
Comment on lines
+99
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 2Repository: 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 4Repository: NVIDIA/elements Length of output: 13579 Guard the optional metadata chain here
🛡️ 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| const error = await PackagesService.changelogsGet({ name: 'does-not-exist', format: 'markdown' }).catch( | ||||||||||
| e => e as Error | ||||||||||
| ); | ||||||||||
| const available = error.message.split('Available packages:')[1] ?? ''; | ||||||||||
| const errSet = new Set(Array.from(available.matchAll(/"([^"]+)"/g), m => m[1])); | ||||||||||
|
|
||||||||||
| expect(listSet.size).toBeGreaterThan(0); | ||||||||||
| expect(errSet).toEqual(listSet); | ||||||||||
| expect(schemaSet.size).toBeGreaterThan(0); | ||||||||||
| expect(errSet).toEqual(schemaSet); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| it('should provide versions method', async () => { | ||||||||||
| const result = await PackagesService.versions(); | ||||||||||
| expect(result).toBeDefined(); | ||||||||||
| expect(typeof result).toBe('object'); | ||||||||||
| expect(result['@nvidia-elements/core']).toBe('1.0.0'); | ||||||||||
| expect(result['@nvidia-elements/core']).toMatch(/^\d+\.\d+\.\d+$/); | ||||||||||
| }); | ||||||||||
| }); | ||||||||||
There was a problem hiding this comment.
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 whetherToolMethodcan be inferred/typed directly onchangelogsGetto 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.mdfor type safety, type guards, discriminated unions, and exhaustive checking."🤖 Prompt for AI Agents
Source: Coding guidelines