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 .claude/agent-memory/archgate-developer/MEMORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ Non-enforceable lessons — environment/CI/platform quirks no static rule can re
- **Cross-command I/O sharing: export from the existing command file, don't create shared files** — When two commands need to share I/O functions (console.log with styleText), you CANNOT put them in `src/helpers/` (ARCH-002 forbids console.log in helpers) or create a new file under `src/commands/<parent>/` without a register function (ARCH-001 requires register\*Command export, ARCH-016 requires docs heading). The correct pattern: export the shared functions from the command file that already defines them (e.g., `plugin/install.ts` exports `installForEditor()` and `printManualInstructions()`) and import them in the other command. Applied in `upgrade.ts` importing from `./plugin/install`.
- **macOS `/var` → `/private/var` symlink breaks temp dir path comparisons in tests** — On macOS, `/var` is a symlink to `/private/var`. `mkdtempSync(join(tmpdir(), ...))` returns `/var/folders/...` but `process.cwd()` after `chdir()` resolves the symlink to `/private/var/folders/...`. Tests that compare `tempDir` against paths derived from `process.cwd()` or `findProjectRoot()` will fail. Fix: always wrap `mkdtempSync` with `realpathSync` in test setup: `tempDir = realpathSync(mkdtempSync(join(tmpdir(), "archgate-test-")))`. This normalizes the path upfront. Discovered in v0.38.0/v0.39.0 release builds — PR CI runs on ubuntu-latest only, so macOS-specific issues are invisible until the release workflow.
- **jq on Windows Git Bash emits CRLF line endings** — `jq -r` output ends lines with `\r\n`. In sh scripts, command substitution strips only trailing newlines, so parsed values carry a trailing `\r` (and multi-line lists get `\r` on every entry except the last). Symptom: charset validations reject valid values, or URLs get an embedded CR. Fix: pipe jq (and grep/sed fallbacks) through `tr -d '\r'`. Bit us in `install.sh` resolve_version — the release-walk skipped every tag except the last one.
- **`archgate review-context` misses uncommitted changes when a base ref is detected** — `getFilesChangedSinceRef` (src/engine/git-files.ts) runs `git diff base...HEAD`, which only sees COMMITTED changes. During a normal dev session (Write/Edit tools, nothing committed), `review-context` lists the branch's committed files but silently omits the working-tree edits actually under review. Workaround: scope reviewer sub-agents manually from `git status` / `git diff --name-only main`. Tracked in issue #403; candidate CLI fix: union `base...HEAD` with `getChangedFiles()` (staged+unstaged).
- **Don't test that well-known tools exist on PATH** — Tests like `expect(resolveCommand("bun")).toBe("bun")` assert CI environment state, not application logic. They fail when the runner installs tools via shims (e.g., proto on macOS ARM64 where `Bun.which` returns null). Delete such tests entirely — the "returns null for non-existent command" tests already cover `resolveCommand`'s actual logic, and WSL-specific tests cover the `.exe` fallback path.

## Translation Quality

- **Docs have TWO locales: `nb/` AND `pt-br/`** — Editing any English docs page requires updating BOTH `docs/src/content/docs/nb/<path>` and `docs/src/content/docs/pt-br/<path>` in the same changeset (GEN-002 `i18n-translation-drift` is an error-severity rule). Don't stop at nb. Also: locale pages can silently lack whole sections present in English (e.g., a section might exist in English but be entirely absent from a locale page) — the drift rule only checks that the file was touched, not content parity, so compare section structure when editing.
- **Norwegian (nb/) diacritical patterns to scan for** — When reviewing or editing `docs/src/content/docs/nb/` translations, scan for three corruption patterns: (1) stripped diacriticals (`monster` for `mønster`, `a` for `å`), (2) ASCII approximations (`aa` for `å`, `oe` for `ø`, `ae` for `æ`), (3) HTML entities (`&aring;` for `å`, `&oslash;` for `ø`, `&aelig;` for `æ`). GEN-002 mandates correct characters but automated rules only check structural i18n (page parity, link prefixes, translation drift) — diacritical correctness requires manual/AI review. Common Norwegian words to watch: må, når, på, også, både, får, bør, før, første, følger, kjører, mønster, nøkkel, verktøy, nødvendig, støtter, foreslår, påvirkning, forårsaker, primær, erklæring, miljø, overføring.

## Validation Pipeline
Expand Down
34 changes: 17 additions & 17 deletions docs/public/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -849,11 +849,11 @@ The `check` function receives a `RuleContext` object that provides everything a

### Project Information

| Property | Type | Description |
| ------------------ | ---------- | ---------------------------------------------------------------------------------- |
| `ctx.projectRoot` | `string` | Absolute path to the project root directory |
| `ctx.scopedFiles` | `string[]` | Files matching the ADR's `files` globs, or all project files if no globs are set |
| `ctx.changedFiles` | `string[]` | Files changed in git (auto-detected from branch diff, or from `--staged`/`--base`) |
| Property | Type | Description |
| ------------------ | ---------- | ----------------------------------------------------------------------------------- |
| `ctx.projectRoot` | `string` | Absolute path to the project root directory |
| `ctx.scopedFiles` | `string[]` | Files matching the ADR's `files` globs, or all project files if no globs are set |
| `ctx.changedFiles` | `string[]` | Files changed in git (branch diff plus uncommitted changes, or `--staged`/`--base`) |

### File Operations

Expand Down Expand Up @@ -957,7 +957,7 @@ Rules execute with the following guarantees:
- **Parallel across ADRs** -- Rules from different ADRs run concurrently for faster execution.
- **Sequential within an ADR** -- Rules belonging to the same ADR run one after another, so earlier rules can establish context for later ones.
- **Scoped files are pre-resolved** -- The `ctx.scopedFiles` array is populated before your `check` function is called, based on the ADR's `files` globs.
- **Changed files auto-detected** -- `ctx.changedFiles` is automatically populated with the branch diff against the base branch (e.g., `main`). Use `--staged` for pre-commit hooks (staged files only) or `--base <ref>` for an explicit base. This enables cross-file dependency rules to work locally, not just in CI.
- **Changed files auto-detected** -- `ctx.changedFiles` is automatically populated with the branch diff against the base branch (e.g., `main`) plus uncommitted working-tree changes (staged, unstaged, and untracked non-ignored files). Use `--staged` for pre-commit hooks (staged files only) or `--base <ref>` for an explicit base. This enables cross-file dependency rules to work locally, not just in CI.

The editor plugins for [Claude Code](/guides/claude-code-plugin/) and [Cursor](/guides/cursor-integration/) run `archgate check` automatically after every code change. The agent reads the applicable ADRs, writes compliant code, and validates -- no manual check commands needed. [Sign up for beta access](https://plugins.archgate.dev).

Expand Down Expand Up @@ -2795,7 +2795,7 @@ Use `ctx.scopedFiles` when your rule should only apply to files the ADR governs.

### ctx.changedFiles

An array of file paths that differ from the base branch. Auto-detected by default, or populated from `--staged` / `--base <ref>`. Useful for incremental checking and cross-file dependency rules.
An array of file paths that differ from the base branch, including uncommitted working-tree changes (staged, unstaged, and untracked non-ignored files). Auto-detected by default, or populated from `--staged` / `--base <ref>`. Useful for incremental checking and cross-file dependency rules.

```typescript
// Incremental checking -- only validate changed files
Expand Down Expand Up @@ -2981,7 +2981,7 @@ ARCH-006/no-unapproved-deps
}
```

2. **Use `ctx.changedFiles` for incremental checking.** `ctx.changedFiles` is auto-populated with the branch diff (or staged files with `--staged`). Filter `ctx.scopedFiles` against it to check only what changed, or use it directly for cross-file dependency rules.
2. **Use `ctx.changedFiles` for incremental checking.** `ctx.changedFiles` is auto-populated with the branch diff plus uncommitted working-tree changes (or staged files with `--staged`). Filter `ctx.scopedFiles` against it to check only what changed, or use it directly for cross-file dependency rules.

3. **Keep rules focused on one concern.** A rule that checks both naming conventions and import patterns should be split into two rules with separate IDs.

Expand Down Expand Up @@ -3818,17 +3818,17 @@ archgate check --ci

## Changed files detection

By default, `archgate check` auto-detects the base branch and populates `ctx.changedFiles` with the branch diff (`git diff <base>...HEAD`). This enables cross-file dependency rules to work locally -- not just in CI.
By default, `archgate check` auto-detects the base branch and populates `ctx.changedFiles` with the branch diff (`git diff <base>...HEAD`) plus any uncommitted working-tree changes (staged, unstaged, and untracked non-ignored files). This enables cross-file dependency rules to work locally -- not just in CI -- and ensures edits that haven't been committed yet are still checked.

The base ref is resolved in priority order:

| Priority | Source | `changedFiles` populated with |
| -------- | ------------------------------------ | -------------------------------- |
| 1 | `--staged` | Git staging area only |
| 2 | `--base <ref>` | `git diff <ref>...HEAD` |
| 3 | `.archgate/config.json` `baseBranch` | `git diff <resolved-ref>...HEAD` |
| 4 | Git auto-detect | `git diff <detected-ref>...HEAD` |
| 5 | Detection fails | Empty (full-scan mode) |
| Priority | Source | `changedFiles` populated with |
| -------- | ------------------------------------ | ------------------------------------------------------- |
| 1 | `--staged` | Git staging area only |
| 2 | `--base <ref>` | `git diff <ref>...HEAD` + working-tree changes |
| 3 | `.archgate/config.json` `baseBranch` | `git diff <resolved-ref>...HEAD` + working-tree changes |
| 4 | Git auto-detect | `git diff <detected-ref>...HEAD` + working-tree changes |
| 5 | Detection fails | Empty (full-scan mode) |

Auto-detection tries `origin/HEAD`, then `origin/main`, `origin/master`, local `main`, and local `master`. To set a project default, add `baseBranch` to `.archgate/config.json`:

Expand Down Expand Up @@ -4854,7 +4854,7 @@ Files matching the ADR's `files` glob patterns from its frontmatter. If the ADR
changedFiles: string[];
```

Files that have been modified according to git. By default, this is auto-populated with the branch diff against the detected base branch (e.g., `origin/main`). When `--staged` is used, this contains only staged files. When `--base <ref>` is used, this contains all files changed since that ref. Empty when base detection fails or no changes are found. Use this to build cross-file dependency rules (e.g., "if file A changed, file B must also change").
Files that have been modified according to git. By default, this is auto-populated with the branch diff against the detected base branch (e.g., `origin/main`) plus any uncommitted working-tree changes (staged, unstaged, and untracked non-ignored files). When `--staged` is used, this contains only staged files. When `--base <ref>` is used, this contains all files changed since that ref plus uncommitted working-tree changes. Empty when base detection fails or no changes are found. Use this to build cross-file dependency rules (e.g., "if file A changed, file B must also change").

#### report

Expand Down
12 changes: 6 additions & 6 deletions docs/src/content/docs/concepts/rules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ The `check` function receives a `RuleContext` object that provides everything a

### Project Information

| Property | Type | Description |
| ------------------ | ---------- | ---------------------------------------------------------------------------------- |
| `ctx.projectRoot` | `string` | Absolute path to the project root directory |
| `ctx.scopedFiles` | `string[]` | Files matching the ADR's `files` globs, or all project files if no globs are set |
| `ctx.changedFiles` | `string[]` | Files changed in git (auto-detected from branch diff, or from `--staged`/`--base`) |
| Property | Type | Description |
| ------------------ | ---------- | ----------------------------------------------------------------------------------- |
| `ctx.projectRoot` | `string` | Absolute path to the project root directory |
| `ctx.scopedFiles` | `string[]` | Files matching the ADR's `files` globs, or all project files if no globs are set |
| `ctx.changedFiles` | `string[]` | Files changed in git (branch diff plus uncommitted changes, or `--staged`/`--base`) |

### File Operations

Expand Down Expand Up @@ -163,7 +163,7 @@ Rules execute with the following guarantees:
- **Parallel across ADRs** -- Rules from different ADRs run concurrently for faster execution.
- **Sequential within an ADR** -- Rules belonging to the same ADR run one after another, so earlier rules can establish context for later ones.
- **Scoped files are pre-resolved** -- The `ctx.scopedFiles` array is populated before your `check` function is called, based on the ADR's `files` globs.
- **Changed files auto-detected** -- `ctx.changedFiles` is automatically populated with the branch diff against the base branch (e.g., `main`). Use `--staged` for pre-commit hooks (staged files only) or `--base <ref>` for an explicit base. This enables cross-file dependency rules to work locally, not just in CI.
- **Changed files auto-detected** -- `ctx.changedFiles` is automatically populated with the branch diff against the base branch (e.g., `main`) plus uncommitted working-tree changes (staged, unstaged, and untracked non-ignored files). Use `--staged` for pre-commit hooks (staged files only) or `--base <ref>` for an explicit base. This enables cross-file dependency rules to work locally, not just in CI.

:::tip[Run checks automatically with editor plugins]
The editor plugins for [Claude Code](/guides/claude-code-plugin/) and [Cursor](/guides/cursor-integration/) run `archgate check` automatically after every code change. The agent reads the applicable ADRs, writes compliant code, and validates -- no manual check commands needed. [Sign up for beta access](https://plugins.archgate.dev).
Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/guides/writing-rules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Use `ctx.scopedFiles` when your rule should only apply to files the ADR governs.

### ctx.changedFiles

An array of file paths that differ from the base branch. Auto-detected by default, or populated from `--staged` / `--base <ref>`. Useful for incremental checking and cross-file dependency rules.
An array of file paths that differ from the base branch, including uncommitted working-tree changes (staged, unstaged, and untracked non-ignored files). Auto-detected by default, or populated from `--staged` / `--base <ref>`. Useful for incremental checking and cross-file dependency rules.

```typescript
// Incremental checking -- only validate changed files
Expand Down Expand Up @@ -285,7 +285,7 @@ ARCH-006/no-unapproved-deps
}
```

2. **Use `ctx.changedFiles` for incremental checking.** `ctx.changedFiles` is auto-populated with the branch diff (or staged files with `--staged`). Filter `ctx.scopedFiles` against it to check only what changed, or use it directly for cross-file dependency rules.
2. **Use `ctx.changedFiles` for incremental checking.** `ctx.changedFiles` is auto-populated with the branch diff plus uncommitted working-tree changes (or staged files with `--staged`). Filter `ctx.scopedFiles` against it to check only what changed, or use it directly for cross-file dependency rules.

3. **Keep rules focused on one concern.** A rule that checks both naming conventions and import patterns should be split into two rules with separate IDs.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/nb/concepts/rules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Når `archgate check` kjøres, betyr exit code 1 at minst ett brudd med alvorlig
| ------------------ | ---------- | -------------------------------------------------------------------------------------------- |
| `ctx.projectRoot` | `string` | Absolutt sti til prosjektets rotmappe |
| `ctx.scopedFiles` | `string[]` | Filer som matcher ADR-ens `files`-glober, eller alle prosjektfiler hvis ingen glober er satt |
| `ctx.changedFiles` | `string[]` | Filer endret i git (auto-oppdaget fra branch-diff, eller fra `--staged`/`--base`) |
| `ctx.changedFiles` | `string[]` | Filer endret i git (branch-diff pluss ikke-committede endringer, eller `--staged`/`--base`) |

### Filoperasjoner

Expand Down Expand Up @@ -163,7 +163,7 @@ Regler kjøres med følgende garantier:
- **Parallelt mellom ADR-er** -- Regler fra forskjellige ADR-er kjøres samtidig for raskere kjøring.
- **Sekvensielt innenfor en ADR** -- Regler som tilhører samme ADR kjøres etter hverandre, slik at tidligere regler kan etablere kontekst for senere.
- **Avgrensede filer er forhåndsløst** -- `ctx.scopedFiles`-arrayet er fylt ut før `check`-funksjonen din kalles, basert på ADR-ens `files`-glober.
- **Endrede filer auto-oppdaget** -- `ctx.changedFiles` fylles automatisk med branch-diffen mot base-branchen (f.eks. `main`). Bruk `--staged` for pre-commit hooks (kun staged-filer) eller `--base <ref>` for en eksplisitt base. Dette gjør at kryss-fil-avhengighetsregler fungerer lokalt, ikke bare i CI.
- **Endrede filer auto-oppdaget** -- `ctx.changedFiles` fylles automatisk med branch-diffen mot base-branchen (f.eks. `main`) pluss ikke-committede endringer i arbeidstreet (stagede, ustagede og usporede ikke-ignorerte filer). Bruk `--staged` for pre-commit hooks (kun staged-filer) eller `--base <ref>` for en eksplisitt base. Dette gjør at kryss-fil-avhengighetsregler fungerer lokalt, ikke bare i CI.

:::tip[Kjør sjekker automatisk med editorplugins]
Editorpluginene for [Claude Code](/guides/claude-code-plugin/) og [Cursor](/guides/cursor-integration/) kjører `archgate check` automatisk etter hver kodeendring. Agenten leser de gjeldende ADR-ene, skriver samsvarende kode og validerer -- ingen manuelle sjekkkommandoer nødvendig. [Registrer deg for beta-tilgang](https://plugins.archgate.dev).
Expand Down
Loading
Loading