-
-
Notifications
You must be signed in to change notification settings - Fork 118
Add preact devtools #204
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
Add preact devtools #204
Changes from 1 commit
57440b4
e79e0da
6b86266
611228e
4a00b4b
2959fe4
3753583
aead2e2
2a67a98
9bc04b0
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@tanstack/preact-ai-devtools': minor | ||
| --- | ||
|
|
||
| Initial release |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # @tanstack/preact-ai-devtools |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| <div align="center"> | ||
| <img src="./media/header_ai.png" > | ||
| </div> | ||
|
|
||
| <br /> | ||
|
|
||
| <div align="center"> | ||
| <a href="https://npmjs.com/package/@tanstack/ai" target="\_parent"> | ||
| <img alt="" src="https://img.shields.io/npm/dm/@tanstack/ai.svg" /> | ||
| </a> | ||
| <a href="https://github.com/TanStack/ai" target="\_parent"> | ||
| <img alt="" src="https://img.shields.io/github/stars/TanStack/ai.svg?style=social&label=Star" alt="GitHub stars" /> | ||
|
Contributor
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. Replace hard tabs with spaces. Lines 12, 23-25 contain hard tabs instead of spaces, which should be corrected for consistency with the rest of the file. 🔧 Proposed fix <a href="https://github.com/TanStack/ai" target="\_parent">
- <img alt="" src="https://img.shields.io/github/stars/TanStack/ai.svg?style=social&label=Star" alt="GitHub stars" />
+ <img alt="" src="https://img.shields.io/github/stars/TanStack/ai.svg?style=social&label=Star" alt="GitHub stars" />
</a>- <a href="#badge">
- <img src="https://img.shields.io/github/v/release/tanstack/ai" alt="Release"/>
- </a>
+<a href="#badge">
+ <img src="https://img.shields.io/github/v/release/tanstack/ai" alt="Release"/>
+</a>Also applies to: 23-25 🧰 Tools🪛 markdownlint-cli2 (0.18.1)12-12: Hard tabs (MD010, no-hard-tabs) 🤖 Prompt for AI Agents |
||
| </a> | ||
| <a href="https://bundlephobia.com/result?p=@tanstack/ai@latest" target="\_parent"> | ||
| <img alt="" src="https://badgen.net/bundlephobia/minzip/@tanstack/ai@latest" /> | ||
| </a> | ||
|
Comment on lines
+8
to
+16
Contributor
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. Package references are incorrect for preact-ai-devtools. The badges reference 📦 Proposed fix-<a href="https://npmjs.com/package/@tanstack/ai" target="\_parent">
- <img alt="" src="https://img.shields.io/npm/dm/@tanstack/ai.svg" />
+<a href="https://npmjs.com/package/@tanstack/preact-ai-devtools" target="\_parent">
+ <img alt="" src="https://img.shields.io/npm/dm/@tanstack/preact-ai-devtools.svg" />
</a>
<a href="https://github.com/TanStack/ai" target="\_parent">
<img alt="" src="https://img.shields.io/github/stars/TanStack/ai.svg?style=social&label=Star" alt="GitHub stars" />
</a>
-<a href="https://bundlephobia.com/result?p=@tanstack/ai@latest" target="\_parent">
- <img alt="" src="https://badgen.net/bundlephobia/minzip/@tanstack/ai@latest" />
+<a href="https://bundlephobia.com/result?p=@tanstack/preact-ai-devtools@latest" target="\_parent">
+ <img alt="" src="https://badgen.net/bundlephobia/minzip/@tanstack/preact-ai-devtools@latest" />
</a>🧰 Tools🪛 markdownlint-cli2 (0.18.1)12-12: Hard tabs (MD010, no-hard-tabs) 🤖 Prompt for AI Agents |
||
| </div> | ||
|
|
||
| <div align="center"> | ||
| <a href="#badge"> | ||
| <img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg"> | ||
| </a> | ||
| <a href="#badge"> | ||
| <img src="https://img.shields.io/github/v/release/tanstack/ai" alt="Release"/> | ||
| </a> | ||
| <a href="https://twitter.com/tan_stack"> | ||
| <img src="https://img.shields.io/twitter/follow/tan_stack.svg?style=social" alt="Follow @TanStack"/> | ||
| </a> | ||
| </div> | ||
|
|
||
| <div align="center"> | ||
|
|
||
| ### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/) | ||
| </div> | ||
|
|
||
| # TanStack Preact AI Devtools | ||
|
|
||
| Developer tools for TanStack AI in Preact applications. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| npm install @tanstack/preact-ai-devtools | ||
| # or | ||
| pnpm add @tanstack/preact-ai-devtools | ||
| # or | ||
| yarn add @tanstack/preact-ai-devtools | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Using the Panel Component | ||
|
|
||
| Add the `AiDevtoolsPanel` component to your app: | ||
|
|
||
| ```tsx | ||
| import { AiDevtoolsPanel } from '@tanstack/preact-ai-devtools' | ||
|
|
||
| function App() { | ||
| return ( | ||
| <> | ||
| <YourApp /> | ||
| <AiDevtoolsPanel /> | ||
| </> | ||
| ) | ||
| } | ||
| ``` | ||
|
|
||
| ### Using the Plugin | ||
|
|
||
| You can also use the devtools as a plugin: | ||
|
|
||
| ```tsx | ||
| import { aiDevtoolsPlugin } from '@tanstack/preact-ai-devtools' | ||
| import { useAIProvider } from '@tanstack/ai-preact' | ||
|
|
||
| function App() { | ||
| const ai = useAIProvider({ | ||
| // your config | ||
| plugins: [aiDevtoolsPlugin()], | ||
| }) | ||
|
||
|
|
||
| return <YourApp /> | ||
| } | ||
| ``` | ||
|
|
||
| ## Production Builds | ||
|
|
||
| For production builds, import from the production entry point to exclude devtools code: | ||
|
|
||
| ```tsx | ||
| import { AiDevtoolsPanel } from '@tanstack/preact-ai-devtools/production' | ||
| ``` | ||
|
|
||
| The devtools will automatically be disabled in production environments when using the main entry point. | ||
|
|
||
| ## Get Involved | ||
|
|
||
| - [Join the Discord](https://tlinz.com/discord) | ||
| - [Read the docs](https://tanstack.com/ai) | ||
| - [Report an issue](https://github.com/TanStack/ai/issues) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| { | ||
| "name": "@tanstack/preact-ai-devtools", | ||
| "version": "0.0.0", | ||
| "description": "Preact Devtools for TanStack AI.", | ||
| "author": "tannerlinsley", | ||
| "license": "MIT", | ||
| "homepage": "https://tanstack.com/ai", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/TanStack/ai.git", | ||
| "directory": "packages/typescript/ai" | ||
| }, | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "funding": { | ||
| "type": "github", | ||
| "url": "https://github.com/sponsors/tannerlinsley" | ||
| }, | ||
| "scripts": { | ||
| "clean": "premove ./build ./dist", | ||
| "lint:fix": "eslint ./src --fix", | ||
| "test:eslint": "eslint ./src", | ||
| "test:lib": "vitest --passWithNoTests", | ||
| "test:lib:dev": "pnpm test:lib --watch", | ||
| "test:types": "tsc", | ||
| "test:build": "publint --strict", | ||
| "build": "vite build" | ||
| }, | ||
| "type": "module", | ||
| "types": "./dist/esm/index.d.ts", | ||
| "module": "./dist/esm/index.js", | ||
| "exports": { | ||
| ".": { | ||
| "import": { | ||
| "types": "./dist/esm/index.d.ts", | ||
| "default": "./dist/esm/index.js" | ||
| } | ||
| }, | ||
| "./production": { | ||
| "import": { | ||
| "types": "./dist/esm/production.d.ts", | ||
| "default": "./dist/esm/production.js" | ||
| } | ||
| }, | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "sideEffects": false, | ||
| "files": [ | ||
| "dist", | ||
| "src" | ||
| ], | ||
| "dependencies": { | ||
| "@tanstack/ai-devtools-core": "workspace:*", | ||
| "@tanstack/devtools-utils": "^0.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@vitest/coverage-v8": "4.0.14", | ||
| "vite": "^7.2.7", | ||
| "@preact/preset-vite": "^2.9.3" | ||
| }, | ||
| "peerDependencies": { | ||
| "preact": "^10.0.0" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { createPreactPanel } from '@tanstack/devtools-utils/preact' | ||
| import { AiDevtoolsCore } from '@tanstack/ai-devtools-core' | ||
| import type { DevtoolsPanelProps } from '@tanstack/devtools-utils/preact' | ||
|
|
||
| const [AiDevtoolsPanel, AiDevtoolsPanelNoOp] = createPreactPanel(AiDevtoolsCore) | ||
|
|
||
| export interface AiDevtoolsPreactInit extends DevtoolsPanelProps {} | ||
|
|
||
| export { AiDevtoolsPanel, AiDevtoolsPanelNoOp } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import * as Devtools from './AiDevtools' | ||
| import * as plugin from './plugin' | ||
|
|
||
| export const AiDevtoolsPanel = | ||
| process.env.NODE_ENV !== 'development' | ||
| ? Devtools.AiDevtoolsPanelNoOp | ||
| : Devtools.AiDevtoolsPanel | ||
|
|
||
| export const aiDevtoolsPlugin = | ||
| process.env.NODE_ENV !== 'development' | ||
| ? plugin.aiDevtoolsNoOpPlugin | ||
| : plugin.aiDevtoolsPlugin | ||
|
Comment on lines
+4
to
+12
Contributor
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. 🧩 Analysis chain🏁 Script executed: # First, verify the file exists and check its contents
ls -la packages/typescript/preact-ai-devtools/src/
cat -n packages/typescript/preact-ai-devtools/src/index.tsRepository: TanStack/ai Length of output: 914 🏁 Script executed: # Check the package.json for build configuration and exports
cat packages/typescript/preact-ai-devtools/package.jsonRepository: TanStack/ai Length of output: 1588 🏁 Script executed: # Check if dist directory exists and what's in it
ls -la packages/typescript/preact-ai-devtools/dist/ 2>/dev/null || echo "dist/ does not exist yet"Repository: TanStack/ai Length of output: 79 🏁 Script executed: # Look for the Nx/build configuration files
fd -e "tsconfig.json" -e "vite.config.ts" -e "vite.config.js" packages/typescript/preact-ai-devtools/ 2>/dev/null | head -20Repository: TanStack/ai Length of output: 37 🏁 Script executed: # Check production.ts which appears to be an alternative export
cat -n packages/typescript/preact-ai-devtools/src/production.tsRepository: TanStack/ai Length of output: 239 🏁 Script executed: # Check AiDevtools.tsx to see the NoOp implementation
cat -n packages/typescript/preact-ai-devtools/src/AiDevtools.tsxRepository: TanStack/ai Length of output: 519 🏁 Script executed: # Check plugin.tsx to see the NoOp implementation
cat -n packages/typescript/preact-ai-devtools/src/plugin.tsxRepository: TanStack/ai Length of output: 467 🏁 Script executed: # Look for Vite configuration
find packages/typescript/preact-ai-devtools -name "vite.config.*" -o -name "tsconfig.json" | xargs cat -n 2>/dev/nullRepository: TanStack/ai Length of output: 1461 🏁 Script executed: # Check if there's a shared Vite config at the workspace root
find . -maxdepth 3 -name "vite.config.*" | head -10Repository: TanStack/ai Length of output: 324 🏁 Script executed: # Find the vite-config package to understand how NODE_ENV is handled
fd -e "vite-config" -type d | head -5Repository: TanStack/ai Length of output: 225 🏁 Script executed: # Search for documentation or configuration about NODE_ENV handling
rg "NODE_ENV" packages/typescript/preact-ai-devtools/ -C 3Repository: TanStack/ai Length of output: 991 🏁 Script executed: # Check if there's a shared vite config explanation
rg "define:" . --type ts --type js -C 2 | head -30Repository: TanStack/ai Length of output: 37 🏁 Script executed: # Look at how other devtools packages handle this
find packages/typescript -name "*devtools*" -type d | head -10Repository: TanStack/ai Length of output: 201 🏁 Script executed: # Check the ai-devtools-core to see if there's a similar pattern
cat packages/typescript/ai-devtools-core/src/index.ts 2>/dev/null | head -20Repository: TanStack/ai Length of output: 37 🏁 Script executed: # Look at how tanstackViteConfig is configured - might be in a shared package
rg "tanstackViteConfig" . --type-list | head -5Repository: TanStack/ai Length of output: 444 🏁 Script executed: # Check the vite-config package contents
find . -path "*/vite-config/*" -name "*.ts" | head -10Repository: TanStack/ai Length of output: 37 🏁 Script executed: # Search for packages that contain vite-config
ls -la packages/ | grep -i viteRepository: TanStack/ai Length of output: 37 🏁 Script executed: # Check if tanstackViteConfig is exported from a package
rg "export.*tanstackViteConfig" --type ts --type jsRepository: TanStack/ai Length of output: 37 🏁 Script executed: # Search for tanstackViteConfig definition or import
rg "tanstackViteConfig" --include="*.ts" --include="*.js"Repository: TanStack/ai Length of output: 496 🏁 Script executed: # Check node_modules or look for the package
find . -name "@tanstack" -type d | grep viteRepository: TanStack/ai Length of output: 37 🏁 Script executed: # Look at package.json files to find where tanstackViteConfig comes from
rg "@tanstack/vite-config" --include="package.json"Repository: TanStack/ai Length of output: 496 🏁 Script executed: # Check the vite config more carefully - look at what tanstackViteConfig does
# It might be handling NODE_ENV automatically
cat -n packages/typescript/react-ai-devtools/vite.config.ts 2>/dev/null | head -50Repository: TanStack/ai Length of output: 1102 🏁 Script executed: # Search for how other packages handle NODE_ENV
rg "NODE_ENV" packages/typescript/ -l | head -10Repository: TanStack/ai Length of output: 253 🏁 Script executed: # Check the structure of another devtools package to compare
cat packages/typescript/react-ai-devtools/src/index.ts 2>/dev/nullRepository: TanStack/ai Length of output: 478 🏁 Script executed: # Look at the learnings to understand the recommended pattern
# Check if there are any adapter patterns mentioned
rg "adapter" packages/typescript/preact-ai-devtools/ -iRepository: TanStack/ai Length of output: 37 🏁 Script executed: # Verify the package exports are correctly defined
cat packages/typescript/preact-ai-devtools/package.json | jq '.exports'Repository: TanStack/ai Length of output: 346 The environment-based export pattern is correct, but consider documenting the explicit The conditional 🤖 Prompt for AI Agents |
||
|
|
||
| export type { AiDevtoolsPreactInit } from './AiDevtools' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { createPreactPlugin } from '@tanstack/devtools-utils/preact' | ||
| import { AiDevtoolsPanel } from './AiDevtools' | ||
|
|
||
| const [aiDevtoolsPlugin, aiDevtoolsNoOpPlugin] = createPreactPlugin({ | ||
| Component: AiDevtoolsPanel, | ||
| name: 'TanStack AI', | ||
| id: 'tanstack-ai', | ||
| defaultOpen: true, | ||
| }) | ||
|
|
||
| export { aiDevtoolsPlugin, aiDevtoolsNoOpPlugin } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export { AiDevtoolsPanel } from './AiDevtools' | ||
|
|
||
| export type { AiDevtoolsPreactInit } from './AiDevtools' | ||
|
|
||
| export { aiDevtoolsPlugin } from './plugin' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "extends": "../../../tsconfig.json", | ||
| "compilerOptions": { | ||
| "jsx": "preserve", | ||
| "jsxFactory": "h", | ||
| "jsxFragmentFactory": "Fragment", | ||
| "moduleResolution": "bundler", | ||
| "strictNullChecks": true | ||
| }, | ||
| "include": ["eslint.config.js", "prettier.config.js", "src"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { defineConfig, mergeConfig } from 'vitest/config' | ||
| import { tanstackViteConfig } from '@tanstack/vite-config' | ||
| import packageJson from './package.json' | ||
|
|
||
| const config = defineConfig({ | ||
| test: { | ||
| name: packageJson.name, | ||
| dir: './', | ||
| watch: false, | ||
| globals: true, | ||
| environment: 'node', | ||
| include: ['tests/**/*.test.ts'], | ||
| coverage: { | ||
| provider: 'v8', | ||
| reporter: ['text', 'json', 'html', 'lcov'], | ||
| exclude: [ | ||
| 'node_modules/', | ||
| 'dist/', | ||
| 'tests/', | ||
| '**/*.test.ts', | ||
| '**/*.config.ts', | ||
| '**/types.ts', | ||
| ], | ||
| include: ['src/**/*.ts'], | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| export default mergeConfig( | ||
| config, | ||
| tanstackViteConfig({ | ||
| entry: ['./src/index.ts', './src/production.ts'], | ||
| srcDir: './src', | ||
| cjs: false, | ||
| }), | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { defineConfig } from 'vitest/config' | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| watch: false, | ||
| }, | ||
| }) | ||
|
Comment on lines
+1
to
+7
Contributor
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Compare Vitest configurations in both files
echo "=== vite.config.ts ==="
cat packages/typescript/preact-ai-devtools/vite.config.ts
echo -e "\n=== vitest.config.ts ==="
cat packages/typescript/preact-ai-devtools/vitest.config.ts
echo -e "\n=== Check for other TanStack packages with similar pattern ==="
fd -t f "vitest.config.ts" packages/typescript/Repository: TanStack/ai Length of output: 1567 🏁 Script executed: #!/bin/bash
# Sample vitest.config.ts files from other packages
echo "=== ai-devtools vitest.config.ts ==="
cat packages/typescript/ai-devtools/vitest.config.ts
echo -e "\n=== ai-openai vitest.config.ts ==="
cat packages/typescript/ai-openai/vitest.config.ts
echo -e "\n=== ai-react vitest.config.ts ==="
cat packages/typescript/ai-react/vitest.config.ts
echo -e "\n=== Check corresponding vite.config.ts for ai-openai ==="
cat packages/typescript/ai-openai/vite.config.ts | head -20Repository: TanStack/ai Length of output: 2174 Remove redundant When both This pattern differs from other TanStack packages (ai-devtools, ai-openai, ai-react, etc.) which consolidate full test configuration into 🤖 Prompt for AI Agents |
||
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.
Add alt text to the header image.
The header image is missing alt text, which impacts accessibility for screen reader users.
♿ Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
2-2: Images should have alternate text (alt text)
(MD045, no-alt-text)
🤖 Prompt for AI Agents