Repository navigation
Add TypeScript AppHost skill and Ollama test #1378
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| --- | ||
| name: aspire-typescript-apphost | ||
| description: Generate a TypeScript AppHost from an existing C# example AppHost, then add a TypeScriptAppHostTest-based integration test. | ||
| --- | ||
|
|
||
| # Aspire TypeScript AppHost Generator | ||
|
|
||
| Use this skill when the user wants to create a TypeScript AppHost (`apphost.mts`) from an existing C# example AppHost and add/update the corresponding integration test. | ||
|
|
||
| ## Prompting rule | ||
|
|
||
| - Ask for the integration **only when this skill is actively running** and only if the user did not provide it. | ||
| - Do not ask for integration selection before this skill is invoked. | ||
|
|
||
| ## Goal | ||
|
|
||
| For one integration, produce: | ||
|
|
||
| 1. A TypeScript AppHost example beside the existing C# AppHost example. | ||
| 2. A test in the integration's `tests/CommunityToolkit.Aspire.Hosting.<Integration>.Tests` project that uses `TypeScriptAppHostTest.Run(...)`. | ||
|
|
||
| ## Workflow | ||
|
|
||
| 1. Resolve the integration | ||
| - If the user already specified an integration, use it. | ||
| - Otherwise, prompt for it at runtime. | ||
|
|
||
| 2. Locate the source AppHost and test project | ||
| - Source C# example path pattern: | ||
| - `examples/<example>/CommunityToolkit.Aspire.Hosting.<Integration>.AppHost/Program.cs` | ||
| - Target TypeScript example path pattern: | ||
| - `examples/<example>/CommunityToolkit.Aspire.Hosting.<Integration>.AppHost.TypeScript/` | ||
| - Test project path: | ||
| - `tests/CommunityToolkit.Aspire.Hosting.<Integration>.Tests/` | ||
|
|
||
| 3. Create or update the TypeScript AppHost folder | ||
| - Required files: | ||
| - `apphost.mts` | ||
| - `aspire.config.json` | ||
| - `package.json` | ||
| - `tsconfig.json` | ||
| - `eslint.config.mjs` | ||
| - `package-lock.json` | ||
| - Keep template/config conventions aligned with existing TypeScript AppHost examples in this repo. | ||
| - Use TypeScript API method names generated for Aspire exports (for overloads, use the exported TypeScript name, not guessed C# casing). | ||
|
|
||
| 4. Translate C# AppHost logic to TypeScript | ||
| - Preserve resource naming and behavior where practical. | ||
| - Use TypeScript Aspire methods and options shapes. | ||
| - Keep path handling and package mapping valid for the example location. | ||
|
|
||
| 5. Add the integration TypeScript AppHost test | ||
| - Add `TypeScriptAppHostTests.cs` in the integration test project if missing. | ||
| - Use: | ||
| - `TypeScriptAppHostTest.Run(...)` | ||
| - `appHostProject` = `<Integration>.AppHost.TypeScript` folder name | ||
| - `packageName` = integration package name | ||
| - `exampleName` = example folder name | ||
| - `waitForResources` = resources required to verify startup in Aspire | ||
| - Follow existing test style and attributes (`[RequiresDocker]` when applicable). | ||
|
|
||
| 6. Validate changes | ||
| - Run the relevant test project to ensure the TypeScript AppHost compiles and starts via the shared validation flow. | ||
|
|
||
| ## Guardrails | ||
|
|
||
| - Do not edit generated `.aspire/modules/` files. | ||
| - Do not change unrelated examples or tests. | ||
| - Keep all changes scoped to the selected integration plus the skill files. | ||
24 changes: 24 additions & 0 deletions
24
examples/ollama/CommunityToolkit.Aspire.Hosting.Ollama.AppHost.TypeScript/apphost.mts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { createBuilder } from "./.aspire/modules/aspire.mjs"; | ||
|
|
||
| const builder = await createBuilder(); | ||
|
|
||
| const ollama = await builder.addOllama("ollama"); | ||
|
|
||
| await ollama.withOpenWebUI(); | ||
|
|
||
| const phi3 = await ollama.addNamedModel("phi3", "phi3"); | ||
| const llama = await ollama.addHuggingFaceModel( | ||
| "llama", | ||
| "bartowski/Llama-3.2-1B-Instruct-GGUF:IQ4_XS", | ||
| ); | ||
|
|
||
| const ollama2 = await builder.addOllama("ollama2"); | ||
| await ollama2.withDataVolume(); | ||
| await ollama2.withOpenWebUI(); | ||
|
|
||
| const tinyllama = await ollama2.addNamedModel("tinyllama", "tinyllama"); | ||
|
|
||
| await phi3.connectionStringExpression(); | ||
| await llama.connectionStringExpression(); | ||
| await tinyllama.connectionStringExpression(); | ||
|
|
||
| await builder.build().run(); | ||
21 changes: 21 additions & 0 deletions
21
examples/ollama/CommunityToolkit.Aspire.Hosting.Ollama.AppHost.TypeScript/aspire.config.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "appHost": { | ||
| "path": "apphost.mts", | ||
| "language": "typescript/nodejs" | ||
| }, | ||
| "sdk": { | ||
| "version": "13.4.0-preview.1.26275.15" | ||
| }, | ||
| "profiles": { | ||
| "https": { | ||
| "applicationUrl": "https://localhost:29750;http://localhost:28931", | ||
| "environmentVariables": { | ||
| "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:10975", | ||
| "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:13319" | ||
| } | ||
| } | ||
| }, | ||
| "packages": { | ||
| "CommunityToolkit.Aspire.Hosting.Ollama": "../../../src/CommunityToolkit.Aspire.Hosting.Ollama/CommunityToolkit.Aspire.Hosting.Ollama.csproj" | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
examples/ollama/CommunityToolkit.Aspire.Hosting.Ollama.AppHost.TypeScript/eslint.config.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // @ts-check | ||
|
|
||
| import { defineConfig } from "eslint/config"; | ||
| import tseslint from "typescript-eslint"; | ||
|
|
||
| export default defineConfig({ | ||
| files: ["apphost.mts"], | ||
| extends: [tseslint.configs.base], | ||
| languageOptions: { | ||
| parserOptions: { | ||
| projectService: true, | ||
| }, | ||
| }, | ||
| rules: { | ||
| "@typescript-eslint/no-floating-promises": [ | ||
| "error", | ||
| { checkThenables: true }, | ||
| ], | ||
| }, | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.