Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// }

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "dotnet restore",
"postCreateCommand": "git config core.hooksPath .githooks",

// Configure tool-specific properties.
// Configure tool-specific properties.
Expand Down
415 changes: 1 addition & 414 deletions .github/CLAUDE.md

Large diffs are not rendered by default.

142 changes: 142 additions & 0 deletions .github/agent-guidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Agent Guidelines

Behavioural rules for AI agents working in this repo: how to plan, clarify, delegate and verify. Project facts (build, tests, gotchas) live in the root `CLAUDE.md`.

## Karpathy Guidelines

Behavioral guidelines to reduce common LLM coding mistakes.

**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.

### 0. Fast Path for Trivial Tasks

**For obvious, low-risk, reversible, text only ( no source code ), single-file changes, execute directly with minimal ceremony.**

- Do not create a plan, spawn or delegate to agents, run quorum review, inspect unrelated files, perform broad searches, or run Git archaeology.
- Read only the target and, when genuinely necessary, one directly relevant instruction or nearby example.
- Do not ask questions when the request and local convention determine the result; make the obvious reversible assumption.
- Use the minimum tool calls: inspect, edit, and verify once. Keep progress narration to one short update at most.
- If the preferred editing tool fails once because of an environment or tooling problem, use a safe direct fallback. Do not repeatedly debug the tool unless no safe fallback exists.
- Verification should be proportional to the change. For a simple text edit, rereading the changed content is sufficient.

This fast path overrides the planning, clarification, delegation, and quorum-review requirements below for trivial tasks. Higher-priority system, developer, safety, and explicitly invoked skill instructions still apply.

### 1. Clarify Before Executing

**Resolve ambiguity up front — before spawning agents or starting any autonomous work.**

Do this in order, then stop and ask before proceeding:

1. **Understand the request.** Read what was asked closely and state your assumptions explicitly.
2. **Inspect the codebase.** Check the relevant code, conventions, and existing patterns. Note anything that's unclear or that could be interpreted in more than one way.
3. **Ask.** Raise every consequential question now, batched together — don't pick an interpretation silently, and don't defer the question into the work itself.

Throughout:

- If multiple interpretations exist, present them — don't choose one silently.
- If a simpler approach exists, say so. Push back when warranted.
- Don't invent APIs. Confirm a function, flag, or endpoint exists — and check its signature — before calling it. If you can't verify it, say so rather than guessing.

Only once these questions are resolved do you move to execution (§4).

### 2. Simplicity First

**Minimum code that solves the problem. Nothing speculative.**

- No features beyond what was asked.
- No abstractions for single-use code.
- No "flexibility" or "configurability" that wasn't requested.
- No error handling for impossible scenarios.
- If you write 200 lines and it could be 50, rewrite it.

**Minimal comments**:

- avoid adding code comments unless necessary (i.e. only if the code itself is not self explanatory). When necessary, code comments must be as brief as possible to ensure readability and avoid overbloating.

Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.

### 3. Surgical Changes

**Touch only what you must. Clean up only your own mess.**

When editing existing code:

- Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently.
- If you spot problems outside your task — dead code, bugs — mention them; don't fix or delete them unless asked.

When your changes create orphans:

- Remove imports/variables/functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked.

The test: every changed line should trace directly to the user's request.

### 4. Goal-Driven Execution

**Define success criteria. Loop until verified.**

Begin only once §1's questions are resolved. Then turn the task into a verifiable goal with an observable check. A passing test is the strongest check; a clean typecheck, running it and inspecting output, or diffing against expected output also count.

- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"
- "Update the config" → "Apply it, start the service, and confirm the setting takes effect"

For multi-step tasks, state a brief plan:

```
1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]
```

When no obvious check exists (docs, exploration, some one-off scripts), ask how to verify success before starting. Don't report success you haven't actually observed.

Strong, agreed-upon criteria — settled in §1 — let you loop independently. Weak criteria ("make it work") force constant clarification, which is why §1 comes first.

### 5. Delegate Grunt Work Down a Tier

**Spend the capable model on judgment; push mechanical, low-context work to a cheaper model.**

Act as an orchestrator. Fan out grunt work — reading files, gathering context, simple searches, minor mechanical edits, other simple tool calls — to cheaper agents, then review their findings and any code changes yourself before acting on them. Keep the important and dangerous work — architecture, ambiguous decisions, risky or hard-to-reverse edits, final review — on the more capable model.

When delegation is available, use a less capable, cheaper model for genuinely simple, mechanical, low-risk work. Keep tasks requiring substantial context or judgment on the primary, more capable model.

Match the model to the task: pick the cheapest tier that can do the job well, and skip an intermediate tier when the work is simple enough for a lower one.

Guidelines:

- Only delegate work that is genuinely low-context and low-risk. If doing it well requires the capable model's judgment, keep it.
- Give each agent a self-contained task with clear success criteria (per §4) so you can verify its output without redoing the work.
- Never merge a delegated finding or edit unblocked — review it first. The cheaper model did the legwork; you own the decision.

### 6. Quorum Review for Big Changes

**For bigger changes, three agents check the work and two of three must agree before it counts as a success.**

This applies to any change that is large, or that spans multiple files. For trivial, single-file edits, skip it and use §4's normal verification.

- Spawn **three independent agents** to review the completed change, each judging against the success criteria settled in §1/§4.
- **Vary each agent's prompt slightly so they are not identical.** Give them the same context and criteria, but frame each reviewer differently — a distinct persona or emphasis (e.g. one as a correctness-focused engineer, one probing edge cases, one checking that it actually satisfies the request). Don't hand all three the same "You are a systems engineer…" opening.
- The change is a success only when **at least two of the three agree** it is correct and complete.
- If the vote fails (two or more say it's wrong or incomplete), treat it as not done: address their objections, then re-run the quorum.
- Keep their judgments independent so the vote is meaningful, and read their reasoning yourself before accepting the verdict.

### 7. Reporting Results

- Keep straightforward findings and small fixes in chat.
- If a review has four or more substantive findings, or the detailed response would exceed roughly 25 lines, write the full results to a clearly named Markdown file in the repository.
- In chat, provide only a short summary and a link to that report.
- Do not create a report file for a simple bug, small change, or brief explanation.

## Other Working Rules

### Documentation

Docs must be code-grounded and reconciled against the actual source and live config, then reader-tested before delivery. Don't document from assumption.

### Refactoring

For "behavior-preserving" refactors, explicitly confirm equivalence and flag any unintended logic changes before applying.
12 changes: 12 additions & 0 deletions .github/workflows/test_dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # PR merge commit plus its parents, for the format check
- name: Check resx key parity
run: pwsh -NoProfile -File tools/Test-ResxKeyParity.ps1
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Check whitespace formatting of changed C# files
if: github.event_name == 'pull_request'
shell: pwsh
run: |
# Scoped to the PR's changed files: the existing code base has ~480 pre-existing whitespace violations.
$files = @(git diff --name-only --diff-filter=ACMR HEAD^1 HEAD -- 'src/*.cs')
if ($files.Count -eq 0) { Write-Host 'No changed C# files.'; exit 0 }
dotnet format whitespace src/LogExpert.sln --verify-no-changes --include $files
- name: Restore dependencies
run: dotnet restore
working-directory: src
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ temp.txt

# roots docs folder should be empty
/docs/*
!/docs/CODING_STANDARDS.md

# test project logs should be ignored, this is for rolling logfile tests
/src/tools/LogRotator/logs/*
Expand Down
81 changes: 81 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# CLAUDE.md

LogExpert: Windows log viewer/tail tool in C# / Windows Forms (.NET 10, `net10.0-windows`), Nuke build, NUnit + Moq tests, plugin-based columnizers. Main solution: `src/LogExpert.sln`. Entry point: `src/LogExpert/Program.cs`.

Before planning, delegating or reviewing a multi-file change, read [.github/agent-guidelines.md](.github/agent-guidelines.md) (clarify-first, simplicity, delegation, quorum-of-3 review).
For repo layout, CI pipelines and the full architecture overview, see [.github/copilot-instructions.md](.github/copilot-instructions.md).

## Environment

- Windows only. Python: `py -I`. Python is often unavailable; prefer PowerShell and built-in tooling.
- Check that `gh` (and any other external tool) is installed before planning around it. Active GitHub account: `brunerpat`.
- Line endings: the working tree is CRLF (only `usedComponents.json` is pinned to LF in `.gitattributes`). Never use `sed` or other text tools that strip CRs; they produce whole-file churn. After a bulk rename, check no reference was missed.

## Build and test

```powershell
./build.ps1 # default target Test (restore, compile, test)
./build.ps1 --target Clean Compile
./build.ps1 --target Test
./build.ps1 --target Clean Pack CreateSetup --configuration Release
./build.ps1 --help # list targets; --plan previews
```

Targets live in `build/Build.cs`. Directly, from `src/`: `dotnet restore`, `dotnet build --no-restore`, `dotnet test --no-build --verbosity normal`, or one project: `dotnet test src/LogExpert.Tests/LogExpert.Tests.csproj`. Output goes to `bin/(Debug|Release)/`. SDK pinned in `global.json`.

Local checks that CI also runs:

- `pwsh -File tools/Test-ResxKeyParity.ps1`: resource keys must match across `Resources.resx`, `Resources.de.resx`, `Resources.zh-CN.resx` and `Resources.Designer.cs`. Add every new string to all three resx files.
- `dotnet format whitespace src/LogExpert.sln --verify-no-changes --include <changed .cs files>`: CI checks only the files a PR changes, because the existing code has many old violations.

Testing: TDD for bug fixes (failing test first). Then run the **full suite**, not only the new test; timing and filesystem tests can pass alone and fail together.

### Known flaky UI tests (on `Development` as of 2026-09-26, @ d9845e24)

Don't chase these as regressions; check whether they're fixed before relying on this.

- `MarkerWindowTests.InactiveWindow_KeepsItsOwnSearchWhenAnotherWindowSearches` **hangs** the test host (0 % CPU, a LogExpert window left open) in about 1/3 to 1/2 of runs when another LogTabWindow test runs before it in the same process. It passes alone.
- `SelectionPainterTests.PaintedBlock_HasNoInternalEdge_AndErasesOldEdgesAfterSelectionChanges` **fails** deterministically (pixel colour assertion).
- Run UI tests with `--blame-hang --blame-hang-timeout 90s --blame-hang-dump-type none` so a hang names the test. For a clean full run, add `--filter "FullyQualifiedName!~InactiveWindow_KeepsItsOwnSearch"` and treat the painter failure as known.

## Code style and review

- `src/.editorconfig` is the source of truth for formatting and analyzer severities. Match it; don't override it.
- Nullable reference types and ImplicitUsings are on; assemblies are signed (`Key.snk`). Package versions are in `src/Directory.Packages.props`.
- When reviewing code, apply [docs/CODING_STANDARDS.md](docs/CODING_STANDARDS.md).
- Before reviewing a PR, check for `docs/improve/review-pr-<n>.md`. If it exists, build on it instead of starting over. Save each finished review there.

## Architecture pointers

- `src/LogExpert.Core/Classes/Log/`: log reading (`PositionAwareStreamReaderBase` and its implementations, `LogBuffer`). Keep position tracking intact for tail mode.
- `src/LogExpert.UI/`: WinForms UI. Main window: `src/LogExpert.UI/Dialogs/LogTabWindow/`. Strings come from `src/LogExpert.Resources`.
- `src/ColumnizerLib/ILogLineColumnizer.cs`: plugin interface. New columnizer: a `*Columnizer` project referencing `ColumnizerLib`, added to `src/LogExpert.sln`, with a test project.
- `src/LogExpert/Program.cs`: single-instance mutex plus named-pipe IPC (`LogExpertInstanceMutex{sessionId}`).
- Plugin hashes: `src/PluginRegistry/PluginHashGenerator.targets` writes `obj/<Configuration>/BuiltInPluginHashes.g.cs` on every build. Build-order-only `ProjectReference`s in `src/PluginRegistry/LogExpert.PluginRegistry.csproj` make sure plugins build first. The table is not committed: nothing to regenerate, verify or commit. Verification is skipped in Debug (`PluginHashCalculator.BypassHashVerification`). See `src/docs/PLUGIN_HASH_MANAGEMENT.md`.

## Common gotchas

1. Linux/macOS builds fail (Windows Desktop SDK).
2. The SDK version must match `global.json`.
3. Plugin not loading: plugins must be in `plugins/` or `pluginsx86/` next to the exe.
4. High DPI: `AutoScaleMode` belongs on forms only, never on individual controls.
5. IPC failures: named pipes need the right Windows permissions and session isolation.
6. BOM-less files fall back to the encoding from `EncodingOptions`.
7. Plugin hashes are only verified in Release builds.
8. Test dark mode as well as light mode (`ColorMode` preference: Light/Dark/System; see `SetColorMode()` in `Program.cs`).

## Dont Do that

Hard rules. Never do these:

- **Don't add a `Co-Authored-By` trailer** (or any other agent/AI attribution) to commit messages. The `.githooks/commit-msg` hook strips them; enable it with `git config core.hooksPath .githooks`.
- **Don't attempt Linux/macOS builds.**
- **Don't use `AutoScaleMode` or `AutoScaleDimensions` on individual controls**, only on forms.
- **Don't override or fight `src/.editorconfig` rules.**

## Git and CI

- Default branch `Development`; PRs target it. GitHub Actions run on push and PR to `Development`. AppVeyor is disabled for now.
- Issues are read-only for agents: see `docs/agents/issue-tracker.md`, `docs/agents/triage-labels.md`, and `docs/agents/domain.md` (single `CONTEXT.md` + `docs/adr/`).

When told not to do something, add it to "Dont Do that".
26 changes: 26 additions & 0 deletions docs/CODING_STANDARDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Coding Standards

Rules for judging a change at review time. Formatting and analyzer severities are enforced by `src/.editorconfig`, so they are not repeated here.

## Comments

- **No XML doc comments (`///`) on internal or private members, or on test classes and test methods.** `CS1591` is turned off in `src/.editorconfig` on purpose.
- Add code comments only when the code can't explain itself, and keep them as short as possible.

## Scope of a change

- Every changed line should trace back to the request. Don't "improve" adjacent code, comments or formatting, and don't refactor what isn't broken.
- Match the existing style of the file, even if you would do it differently.
- Remove imports, variables and functions that the change itself made unused. Leave pre-existing dead code alone and mention it instead.

## Design

- Minimum code that solves the problem: no speculative features, configurability, or abstractions for single-use code.
- No error handling for impossible scenarios.
- "Behaviour-preserving" refactors must actually preserve behaviour. Flag any logic change explicitly.

## Repo-specific

- High DPI: `AutoScaleMode` / `AutoScaleDimensions` go on forms only, never on individual controls.
- User-visible strings go in the resx files under `src/LogExpert.Resources` (and the plugin `Resources.resx` files), with the same keys in `de` and `zh-CN`. CI runs `tools/Test-ResxKeyParity.ps1`.
- Bug fixes come with a test that reproduces the bug.
2 changes: 1 addition & 1 deletion src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ resharper_braces_for_foreach = required
resharper_braces_for_ifelse = required
resharper_braces_for_while = required
resharper_csharp_align_multiline_parameter = true
resharper_csharp_insert_final_newline = true
resharper_csharp_insert_final_newline = false
resharper_csharp_max_line_length = 500
resharper_csharp_use_indent_from_vs = false
resharper_csharp_wrap_lines = false
Expand Down
9 changes: 9 additions & 0 deletions src/LogExpert.Resources/Resources.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,15 @@ Damit die anderen Fenster beim Auswählen einer Zeile (Mausklick oder Pfeiltaste
<data name="SettingsDialog_UI_RadioButton_radioButtonSessionApplicationStartupDir" xml:space="preserve">
<value>Applikationsstartupverzeichnis</value>
</data>
<data name="SettingsDialog_UI_DataGridView_columnHeaderColumnizerMaskType" xml:space="preserve">
<value>Typ</value>
</data>
<data name="SettingsDialog_UI_DataGridView_columnTooltipColumnizerMaskType" xml:space="preserve">
<value>Glob verwendet die Platzhalter * und ?. Regex verwendet die .NET-Syntax für reguläre Ausdrücke.</value>
</data>
<data name="SettingsDialog_UI_DataGridView_columnTooltipColumnizerMaskStale" xml:space="preserve">
<value>Columnizer '{0}' ist nicht installiert – dieser Eintrag wird übersprungen.</value>
</data>
<data name="SettingsDialog_UI_DataGridViewTextBoxColumn_FileMask" xml:space="preserve">
<value>Dateinamenmaske (Regex)</value>
</data>
Expand Down
Loading
Loading