Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 42 additions & 29 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
{
"name": "CLI devcontainer",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
"features": {
"ghcr.io/devcontainers/features/dotnet": {
"version": "10.0",
"additionalVersions": ["8.0"]
},
"ghcr.io/devcontainers/features/node": {
"version": "12"
},
"ghcr.io/devcontainers/features/github-cli": {},
"ghcr.io/nils-geistmann/devcontainers-features/zsh": {
"plugins": "git dotnet node npm"
}
"name": "CLI devcontainer",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
"capAdd": ["SYS_PTRACE"],
"features": {
"ghcr.io/devcontainers/features/dotnet": {
"version": "10.0",
"additionalVersions": ["6.0", "8.0"]
},
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csdevkit",
"mhutchie.git-graph",
"actboy168.tasks",
"esbenp.prettier-vscode",
"EditorConfig.EditorConfig",
"redhat.vscode-yaml",
"davidanson.vscode-markdownlint",
"github.vscode-github-actions"
]
}
"ghcr.io/devcontainers/features/node": {
"version": "18",
"additionalVersions": ["20"]
},
"postCreateCommand": "npm ci && echo \"alias 'cmf=/workspaces/cli/cmf-cli/bin/Debug/cmf'\" >> /home/$USER/.bashrc"
}
"ghcr.io/devcontainers/features/github-cli": {},
"ghcr.io/nils-geistmann/devcontainers-features/zsh": {
"plugins": "git dotnet node npm"
},
"ghcr.io/stuartleeks/dev-container-features/shell-history": {}
},
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csdevkit",
"mhutchie.git-graph",
"actboy168.tasks",
"esbenp.prettier-vscode",
"EditorConfig.EditorConfig",
"redhat.vscode-yaml",
"davidanson.vscode-markdownlint",
"github.vscode-github-actions"
]
},
"settings": {
"dotnet.defaultSolution": "src/cmf-cli.slnx",
"editor.formatOnSave": true,
"editor.rulers": [120],
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true
}
},
"remoteEnv": {
"DOTNET_CLI_TELEMETRY_OPTOUT": "1"
},
"postCreateCommand": "npm ci && echo \"alias 'cmf=/workspaces/cli/cmf-cli/bin/Debug/cmf'\" >> /home/$USER/.bashrc"
}
79 changes: 79 additions & 0 deletions .github/agents/cmf-cli-dotnet.agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
name: cmf-cli-dotnet
description: .NET/C# developer for the cmf-cli repository. Use this agent when implementing CLI commands, fixing C# bugs, writing tests, or refactoring code in core/, cmf-cli/, features/, or tests/.
tools:
- codebase
- editFiles
- fetch
- findTestFiles
- problems
- runCommands
- runTasks
- runTests
- search
- usages
---

You are a senior .NET/C# developer working exclusively on the **Critical Manufacturing CLI** (`cmf-cli` repository).

## Repository Layout

- `core/` – shared CLI infrastructure (base commands, utilities, services, constants)
- `cmf-cli/` – main executable (commands, handlers, builders, factories)
- `features/` – CLI feature implementations (src + test sub-folders)
- `tests/` – automated tests (MSTest + FluentAssertions + Moq)
- `docs/` – documentation (update when behaviour changes)

Always explore the relevant folder before modifying code. Prefer existing abstractions in `core/` over creating new ones.

## Skills

Apply the **dotnet-best-practices** skill for all C# code you write or review.

## C# Conventions

- Follow existing namespace structure: `Cmf.CLI.{Feature}` or `Cmf.Common.CLI.{Area}`
- Use primary constructor syntax for dependency injection
- Use async/await for I/O and long-running tasks; return `Task` or `Task<T>`
- Use `ResourceManager` for user-facing strings (see `CliMessages.resx` / `CoreMessages.resx`)
- Keep methods small and focused; avoid large classes
- Prefer `ArgumentNullException.ThrowIfNull` for guard clauses

## CLI Command Design

Every command must have:
- A clear `[CmfCommand]` attribute with description, examples, and parent binding
- Input argument/option validation with helpful error messages
- A corresponding test in `tests/Specs/`

Follow the pattern in existing commands under `cmf-cli/Commands/`.

## Testing Rules

- Framework: **MSTest** with **FluentAssertions** assertions
- Pattern: **Arrange / Act / Assert**
- Mock dependencies with **Moq**
- Cover both success and failure scenarios, including null-argument validation
- Never break existing tests; update them when behaviour intentionally changes

## Safety Constraints

- Do NOT change licensing or publishing workflows
- Do NOT introduce breaking changes to existing CLI commands
- Do NOT remove commands without providing a migration path
- Do NOT add external NuGet dependencies without justification

## Build & Validate

Use the workspace **build** task (`dotnet build cmf-cli/cmf.csproj`) to verify changes compile.
Use the **runTests** tool or `dotnet test tests/tests.csproj` to validate test results.
Always check for compiler errors and warnings (`problems` tool) after editing.

## Commit Messages

Follow [Conventional Commits](https://www.conventionalcommits.org/):
- `feat(scope): description` for new features
- `fix(scope): description` for bug fixes
- `test(scope): description` for test additions
- `docs(scope): description` for documentation updates
- `refactor(scope): description` for refactors
85 changes: 85 additions & 0 deletions .github/agents/skills/dotnet-best-practices/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
name: dotnet-best-practices
description: 'Ensure .NET/C# code meets best practices for the solution/project.'
---

# .NET/C# Best Practices

Your task is to ensure .NET/C# code in ${selection} meets the best practices specific to this solution/project. This includes:

## Documentation & Structure

- Create comprehensive XML documentation comments for all public classes, interfaces, methods, and properties
- Include parameter descriptions and return value descriptions in XML comments
- Follow the established namespace structure: {Core|Console|App|Service}.{Feature}

## Design Patterns & Architecture

- Use primary constructor syntax for dependency injection (e.g., `public class MyClass(IDependency dependency)`)
- Implement the Command Handler pattern with generic base classes (e.g., `CommandHandler<TOptions>`)
- Use interface segregation with clear naming conventions (prefix interfaces with 'I')
- Follow the Factory pattern for complex object creation.

## Dependency Injection & Services

- Use constructor dependency injection with null checks via ArgumentNullException
- Register services with appropriate lifetimes (Singleton, Scoped, Transient)
- Use Microsoft.Extensions.DependencyInjection patterns
- Implement service interfaces for testability

## Resource Management & Localization

- Use ResourceManager for localized messages and error strings
- Separate LogMessages and ErrorMessages resource files
- Access resources via `_resourceManager.GetString("MessageKey")`

## Async/Await Patterns

- Use async/await for all I/O operations and long-running tasks
- Return Task or Task<T> from async methods
- Use ConfigureAwait(false) where appropriate
- Handle async exceptions properly

## Testing Standards

- Use MSTest framework with FluentAssertions for assertions
- Follow AAA pattern (Arrange, Act, Assert)
- Use Moq for mocking dependencies
- Test both success and failure scenarios
- Include null parameter validation tests

## Configuration & Settings

- Use strongly-typed configuration classes with data annotations
- Implement validation attributes (Required, NotEmptyOrWhitespace)
- Use IConfiguration binding for settings
- Support appsettings.json configuration files

## Semantic Kernel & AI Integration

- Use Microsoft.SemanticKernel for AI operations
- Implement proper kernel configuration and service registration
- Handle AI model settings (ChatCompletion, Embedding, etc.)
- Use structured output patterns for reliable AI responses

## Error Handling & Logging

- Use structured logging with Microsoft.Extensions.Logging
- Include scoped logging with meaningful context
- Throw specific exceptions with descriptive messages
- Use try-catch blocks for expected failure scenarios

## Performance & Security

- Use C# 12+ features and .NET 8 optimizations where applicable
- Implement proper input validation and sanitization
- Use parameterized queries for database operations
- Follow secure coding practices for AI/ML operations

## Code Quality

- Ensure SOLID principles compliance
- Avoid code duplication through base classes and utilities
- Use meaningful names that reflect domain concepts
- Keep methods focused and cohesive
- Implement proper disposal patterns for resources
18 changes: 8 additions & 10 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12, 18]
node-version: [18, 20]
steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
dotnet-version: 8.0.x

- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
Expand All @@ -40,13 +38,13 @@ jobs:
run: |
dotnet build --configuration Release

- name: Test (Node 12)
if: matrix.node-version == 12
run: dotnet test --configuration Release --no-build --no-restore --verbosity normal --filter "TestCategory!=Node18" --collect:"XPlat Code Coverage" --logger trx --results-directory TestResults

- name: Test (Node 18)
- name: Test ${{ matrix.node-version }}
if: matrix.node-version == 18
run: dotnet test --configuration Release --no-build --no-restore --verbosity normal --filter "TestCategory!=Node12" --collect:"XPlat Code Coverage" --logger trx --results-directory TestResults
run: dotnet test --configuration Release --no-build --no-restore --verbosity normal --filter "TestCategory!=Node20" --collect:"XPlat Code Coverage" --logger trx --results-directory TestResults

- name: Test ${{ matrix.node-version }}
if: matrix.node-version == 20
run: dotnet test --configuration Release --no-build --no-restore --verbosity normal --filter "TestCategory!=Node18" --collect:"XPlat Code Coverage" --logger trx --results-directory TestResults

- name: Merge Coverage Reports
run: |
Expand Down
13 changes: 1 addition & 12 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
registry-url: https://registry.npmjs.org/
- uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: '8.0.x'
dotnet-version: '10.0.x'
- name: install zip
uses: montudor/action-zip@v0.1.0
- run: npm install
Expand All @@ -33,9 +33,6 @@ jobs:
- name: Create artifact linux-x64
run: zip -X -r ../cmf-cli.linux-x64.zip .
working-directory: dist/linux-x64
- name: Create artifact osx-x64
run: zip -X -r ../cmf-cli.osx-x64.zip .
working-directory: dist/osx-x64
- name: Publish win-x64 to release
uses: JasonEtco/upload-to-release@master
with:
Expand All @@ -48,21 +45,13 @@ jobs:
args: dist/cmf-cli.linux-x64.zip application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish osx-x64 to release
uses: JasonEtco/upload-to-release@master
with:
args: dist/cmf-cli.osx-x64.zip application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get version from npm package
id: package-version
run: echo "version=$(node -p "require('./npm/package.json').version")" >> $GITHUB_OUTPUT
- name: Upload win-x64 to criticalmanufacturing.io
run: curl -v --user "${{secrets.CRITICALMANUFACTURING_IO_USER}}:${{secrets.CRITICALMANUFACTURING_IO_TOKEN}}" --upload-file dist/cmf-cli.win-x64.zip https://criticalmanufacturing.io/repository/tools/cmf-cli.win-x64-${{ steps.package-version.outputs.version }}.zip
- name: Upload linux-x64 to criticalmanufacturing.io
run: curl -v --user "${{secrets.CRITICALMANUFACTURING_IO_USER}}:${{secrets.CRITICALMANUFACTURING_IO_TOKEN}}" --upload-file dist/cmf-cli.linux-x64.zip https://criticalmanufacturing.io/repository/tools/cmf-cli.linux-x64-${{ steps.package-version.outputs.version }}.zip
- name: Upload osx-x64 to criticalmanufacturing.io
run: curl -v --user "${{secrets.CRITICALMANUFACTURING_IO_USER}}:${{secrets.CRITICALMANUFACTURING_IO_TOKEN}}" --upload-file dist/cmf-cli.osx-x64.zip https://criticalmanufacturing.io/repository/tools/cmf-cli.osx-x64-${{ steps.package-version.outputs.version }}.zip
- run: npm run publish
if: "github.event.release.prerelease"
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
with:
dotnet-version: |
6.0.x
8.0.x
10.0.x
- name: Setup node versions
uses: actions/setup-node@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ staged_files=$(git diff --cached --name-only)
# Check if any changes are in cmf-cli, core, or tests folders
if echo "$staged_files" | grep -qE "^(cmf-cli|core|tests)/"; then
echo "Changes detected in cmf-cli, core, or tests folders. Running tests..."
dotnet test --filter "(TestCategory!=LongRunning)&(TestCategory!=Node12)"
dotnet test --filter "(TestCategory!=LongRunning)"
else
echo "No changes in cmf-cli, core, or tests folders. Skipping tests."
fi
42 changes: 0 additions & 42 deletions cmf-cli.sln

This file was deleted.

6 changes: 6 additions & 0 deletions cmf-cli.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Solution>
<Project Name="cmf-cli" Path="cmf-cli/cmf.csproj" />
<Project Name="core" Path="core/core.csproj" />
<Project Name="schema-gen" Path="schema-gen/schema-gen.csproj" />
<Project Name="tests" Path="tests/tests.csproj" />
</Solution>
2 changes: 1 addition & 1 deletion cmf-cli/Commands/BaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static void AddPluginCommands(Command command)
var cmdInstance = new Command(commandPlugin.Key);
var commandHandler = new PluginCommand(commandPlugin.Key, commandPlugin.Value);
commandHandler.Configure(cmdInstance);
command.AddCommand(cmdInstance);
command.Add(cmdInstance);
}
}
}
Expand Down
Loading