mirror of
https://ghproxy.cflmy.top/https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-11-28 08:09:35 +08:00
feat(forge-panel): let repositories declare review layers in .gitattributes
A repository's root .gitattributes now decides a file's review layer first: dsh-review-layer names test, interface, or implementation, and linguist-generated still places a file in the test layer. The testPaths and interfacePaths settings add globs before the built-in rules and are empty by default. The built-in rules follow the default conventions of common languages and tools instead of treating every JSON or YAML file and every name containing config as interface. This repository declares its own locale dictionaries, snapshot tree, pairing records, and types modules.
This commit is contained in:
1 parent
c9997e03c7
commit
0e971200c4
13 files changed
+246
-119
No files matched your search
@@ -16,3 +16,12 @@ docs/persistence-changes/historical-formats/*.schema.json linguist-generated=tru
|
||||
|
||||
# Unified patch blank context lines require their leading space.
|
||||
patches/*.patch whitespace=-blank-at-eol
|
||||
|
||||
# Review layers of the forge changes view (dsh-review-layer), for this repository's own conventions:
|
||||
# plugin locale dictionaries and the session snapshot tree hide with test files, generated bilingual
|
||||
# pairing records join them, and a package's types-only module is part of its interface.
|
||||
packages/*/*/locale/*.json dsh-review-layer=test
|
||||
locales.ts dsh-review-layer=test
|
||||
snapshots/** dsh-review-layer=test
|
||||
*.i18n.yaml dsh-review-layer=test
|
||||
packages/*/*/src/types.ts dsh-review-layer=interface
|
||||
@@ -253,7 +253,8 @@ const REVIEW_SECTIONS = {
|
||||
|
||||
/**
|
||||
* Pull request 7 with review layers: `src/panel.ts` and `docs/panel.md` are implementation, `package.json` is
|
||||
* interface, and the spec, the locale dictionary, and `docs/schema.json`, which `.gitattributes` marks generated, are tests.
|
||||
* interface, and the spec, the locale dictionary, which `.gitattributes` places in the test layer, and
|
||||
* `docs/schema.json`, which it marks generated, are tests.
|
||||
*/
|
||||
const REVIEW_DIFF = [PR7_DIFF.trimEnd(), ...REVIEW_SECTIONS.test, ...REVIEW_SECTIONS.schema, ''].join('\n')
|
||||
|
||||
@@ -266,7 +267,9 @@ async function writeReviewFixture(root: string): Promise<void> {
|
||||
[`${'1'.repeat(40)}...${HEAD7}`]: [...REVIEW_SECTIONS.test, ...REVIEW_SECTIONS.schema, ''].join('\n'),
|
||||
}))
|
||||
const contents = JSON.parse(await readFile(join(root, 'contents.json'), 'utf8')) as Record<string, string>
|
||||
for (const commit of ['2'.repeat(40), HEAD7]) contents[`.gitattributes@${commit}`] = 'docs/schema.json linguist-generated\n'
|
||||
for (const commit of ['2'.repeat(40), HEAD7]) {
|
||||
contents[`.gitattributes@${commit}`] = 'docs/schema.json linguist-generated\nlocale/*.json dsh-review-layer=test\n'
|
||||
}
|
||||
await writeFile(join(root, 'contents.json'), JSON.stringify(contents))
|
||||
}
|
||||
|
||||
|
||||
@@ -1065,7 +1065,7 @@ export interface CotTranslationPreferences {
|
||||
## `@deepseek-ai/dsh-experimental-client-ui-forge`
|
||||
|
||||
- `inject`: `forge` · `forgeSession` · `sessionProjections` · `workingDirectory` · `fs` · `subprocess` · `sandbox` · `sandboxPolicy` · `agents`
|
||||
- `source`: [`packages/experimental/client-ui-forge/src/types.ts:373`](../packages/experimental/client-ui-forge/src/types.ts)
|
||||
- `source`: [`packages/experimental/client-ui-forge/src/types.ts:374`](../packages/experimental/client-ui-forge/src/types.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Host settings of the forge panel Remote. */
|
||||
@@ -1096,11 +1096,14 @@ export interface Config {
|
||||
/** Most commits of the `branch` scope listed, oldest first. */
|
||||
maxCommits?: number
|
||||
/**
|
||||
* Globs of tests, snapshots, locale dictionaries, and lockfiles, matched against repository-relative paths with
|
||||
* dot files included; their files form the `test` layer, which the changes view can hide.
|
||||
* Globs of files in the `test` layer, which the changes view can hide, beside the built-in rules and checked before
|
||||
* them; matched against repository-relative paths with dot files included. A repository's `.gitattributes` overrides both.
|
||||
*/
|
||||
testPaths?: string[]
|
||||
/** Globs of package manifests, configuration, and type declarations, matched like `testPaths`; their files form the `interface` layer. */
|
||||
/**
|
||||
* Globs of files in the `interface` layer beside the built-in rules, matched like `testPaths`; checked after
|
||||
* `testPaths` and before the built-in rules.
|
||||
*/
|
||||
interfacePaths?: string[]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1067,7 +1067,7 @@ export interface CotTranslationPreferences {
|
||||
## `@deepseek-ai/dsh-experimental-client-ui-forge`
|
||||
|
||||
- `inject`: `forge` · `forgeSession` · `sessionProjections` · `workingDirectory` · `fs` · `subprocess` · `sandbox` · `sandboxPolicy` · `agents`
|
||||
- `source`: [`packages/experimental/client-ui-forge/src/types.ts:373`](../packages/experimental/client-ui-forge/src/types.ts)
|
||||
- `source`: [`packages/experimental/client-ui-forge/src/types.ts:374`](../packages/experimental/client-ui-forge/src/types.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Host settings of the forge panel Remote. */
|
||||
@@ -1098,11 +1098,14 @@ export interface Config {
|
||||
/** Most commits of the `branch` scope listed, oldest first. */
|
||||
maxCommits?: number
|
||||
/**
|
||||
* Globs of tests, snapshots, locale dictionaries, and lockfiles, matched against repository-relative paths with
|
||||
* dot files included; their files form the `test` layer, which the changes view can hide.
|
||||
* Globs of files in the `test` layer, which the changes view can hide, beside the built-in rules and checked before
|
||||
* them; matched against repository-relative paths with dot files included. A repository's `.gitattributes` overrides both.
|
||||
*/
|
||||
testPaths?: string[]
|
||||
/** Globs of package manifests, configuration, and type declarations, matched like `testPaths`; their files form the `interface` layer. */
|
||||
/**
|
||||
* Globs of files in the `interface` layer beside the built-in rules, matched like `testPaths`; checked after
|
||||
* `testPaths` and before the built-in rules.
|
||||
*/
|
||||
interfacePaths?: string[]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -696,8 +696,9 @@ type ForgeDiffStatus = 'added' | 'deleted' | 'modified' | 'renamed'
|
||||
|
||||
```ts type-equiv
|
||||
/**
|
||||
* Review layer of a changed file by its path: `test` for a path matching `testPaths` or one the repository's root
|
||||
* `.gitattributes` marks `linguist-generated`, else `interface` for a path matching `interfacePaths`, else `implementation`.
|
||||
* Review layer of a changed file: the layer the repository's root `.gitattributes` names with `dsh-review-layer`, else
|
||||
* `test` for a file it marks `linguist-generated`, else the first of `testPaths`, `interfacePaths`, and the built-in
|
||||
* test and interface rules that the path matches, else `implementation`.
|
||||
*/
|
||||
type ForgeFileLayer = 'interface' | 'implementation' | 'test'
|
||||
```
|
||||
|
||||
@@ -696,8 +696,9 @@ type ForgeDiffStatus = 'added' | 'deleted' | 'modified' | 'renamed'
|
||||
|
||||
```ts type-equiv
|
||||
/**
|
||||
* Review layer of a changed file by its path: `test` for a path matching `testPaths` or one the repository's root
|
||||
* `.gitattributes` marks `linguist-generated`, else `interface` for a path matching `interfacePaths`, else `implementation`.
|
||||
* Review layer of a changed file: the layer the repository's root `.gitattributes` names with `dsh-review-layer`, else
|
||||
* `test` for a file it marks `linguist-generated`, else the first of `testPaths`, `interfacePaths`, and the built-in
|
||||
* test and interface rules that the path matches, else `implementation`.
|
||||
*/
|
||||
type ForgeFileLayer = 'interface' | 'implementation' | 'test'
|
||||
```
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
en: d152484eb41ac6b4
|
||||
zh: 2f8a621b991260a1
|
||||
/deepseek-ai-dsh-experimental-client-ui-forge/use-this-package:
|
||||
en: dcde9f0c7c82ab08
|
||||
zh: 77a570133b45dbd9
|
||||
en: 670c60932708dbb1
|
||||
zh: 794bc60f93042c3f
|
||||
/deepseek-ai-dsh-experimental-client-ui-forge/understand-the-implementation:
|
||||
en: 1c8c6cfa6ad4b906
|
||||
zh: 15a0beb677f6e0fd
|
||||
en: f255ad3fc3316e7b
|
||||
zh: 1c4960a92141d6db
|
||||
/deepseek-ai-dsh-experimental-client-ui-forge/further-exploration:
|
||||
en: fa4d8c579ffc49ff
|
||||
zh: 5856ed7469e4585b
|
||||
@@ -30,8 +30,8 @@
|
||||
en: 2bc25a99e17789c4
|
||||
zh: 4bec723fbf249d28
|
||||
/deepseek-ai-dsh-experimental-client-ui-forge/known-limitations-and-deferred-work:
|
||||
en: 51f6e22d3f2b7d03
|
||||
zh: 252f1ba8b2941b60
|
||||
en: 2f96a33996a89344
|
||||
zh: a3ed868a4c2747c9
|
||||
/deepseek-ai-dsh-experimental-client-ui-forge/known-limitations-and-deferred-work/dev-note:
|
||||
en: e67f633dc6fe7773
|
||||
zh: 3bb0c20c93f16f98
|
||||
@@ -40,7 +40,7 @@ Panel text follows the application language: Chinese, English, Japanese, Spanish
|
||||
- **Local changes card** — whenever the `branch` scope changes files, independently of bound change requests, a card above the change requests names the ref it compares with, such as `HEAD → origin/main`, which is always the default base below, and shows the added and deleted lines and the number of files, which open the changes view; its file list, which names files as the changes view does, opens the view at one file. Create change request, offered when the code host repository is recognized and no open change request (including drafts) has the checked-out branch as its head, sends the Session a user message in the UI language that asks the Agent to create a change request for these changes, and a toast reports whether it was sent.
|
||||
- **Changes view** — The Changes row of an expanded change request card and the local changes card open a right-sidebar tab that lists the changed files. The local tab is named Local changes and shows Branch by default: the working tree and untracked files against the fork point. Its header names the checked-out branch, or the abbreviated commit on a detached HEAD, and the base branch, which opens a searchable menu: first Default, the base commit of the worktree the Session created, else the merge base of HEAD with the default branch of the code host remote, then remote-tracking and then local branches, each most recently committed first, without the checked-out branch and, outside a created worktree, without the remote-tracking branch Default already names. Typing filters the listed rows at once and lists the branches whose names contain the text, ignoring case, after a short pause; Enter chooses the first row. Choosing another branch compares with the merge base of HEAD and that branch. The tab keeps the choice while other scopes show; closing the tab or reloading the application returns it to Default. When the chosen branch is gone, its name is struck through, and when it shares no history with HEAD, the view says so as well; both offer Use the default base branch instead of Retry. A narrow view hides the note that uncommitted changes count, then the checked-out branch. Uncommitted compares them with HEAD, Unstaged with the index, and Staged compares the index with HEAD. A change request view shows the host's diff at its head and says how many commits the checked-out branch has beyond that head when it is the change request's head branch. The toolbar jumps to a file, totals the changed lines, refreshes, and switches between two columns and one and between wrapped and cut long lines. Visited changes tabs stay mounted across tab and Session switches, hiding the sidebar, and docking changes, preserving file folds, revealed large files, expanded context, layout, and scroll position while the diff is unchanged. Hidden changes views release their panel subscription and defer diff reads; returning reads again only when the latest head or local summary differs. A refresh that replaces the diff discards expanded context, and changed content may move the reading position. Temporary menus close when the view is hidden. Closing the tab or reloading the application discards this progress. Files are named before their directories, which use smaller subdued type and shorten first; hovering one shows its complete path, and both paths for a renamed file. Each file shows badges for a new, deleted, or renamed file, the last naming the old file name, or the old path when only the directory changed, and, in the Branch scope, an untracked one, and a menu that copies its path and opens the whole file in the sidebar for local changes or its page at the head in the browser for a change request. Unchanged lines between hunks collapse into rows that expand from the file's new side: the working tree, the index for Staged, or the head commit through the code host; a file that changed after the diff was read stays collapsed until the view reads again. A binary file and an untracked file over `maxDiffBytes` show a note instead of their lines, a file whose hunks draw more than 1,000 lines starts as one collapsed strip that names its changed lines and draws them when opened, and a file below files that change more than 5,000 lines starts collapsed. The view reads again on Refresh and the page refresh shortcut, on each navigation, when the change request's head moves, and when the Branch scope's summary changes; a change request's view first waits for the status that names its head, unless no provider serves it or that poll failed. While a read replaces changes already shown, the Refresh icon turns. A change request whose diff the code host or its provider refuses over a size limit, such as a GitHub diff over 300 files, says its changes are too large to show here and offers View in browser; another failed read offers Retry and, for a change request, View in browser. A change request's diff is downloaded once per head commit and base branch while it stays cached, so reopening, refreshing, and navigating at the same head read nothing from the host.
|
||||
|
||||
- **Review layers, test files, viewed files, and commits** — Above the file tree, the lens keeps All files or the files of one layer, Interface, Implementation, or Tests, each with its count; where no tree shows, the toolbar offers the lens as a menu. A file is in Tests when its path matches `testPaths` or the repository's root `.gitattributes` marks it `linguist-generated`, else in Interface when its path matches `interfacePaths`, such as package manifests, configuration, and type declarations, else in Implementation. Hide test files leaves Tests out of the file tree and the diff without listing them, and disables the Tests lens. Viewed on a file header marks that change of the file viewed and collapses it; the toolbar shows how many of the shown files are viewed, and `V` marks or clears the file being read: the file holding the focus or the text cursor, else the file at the top of the view. A file whose change differs from the change it was marked at shows Changed since viewed and expands again. Marks are kept in this browser per Session, source, path, and change digest, so they survive closing the tab and reloading. All commits beside Submit review, and beside the base branch in the Branch scope, lists the commits oldest first; a click shows one commit and a Shift click the commits from the last one clicked; the view then shows those commits' changes, reads unchanged lines at the last of them, and offers Add to input but no GitHub comment or review. Branch commits exclude uncommitted and untracked files. Another base or scope returns to all commits, and a chosen commit that is gone offers Show all commits.
|
||||
- **Review layers, test files, viewed files, and commits** — Above the file tree, the lens keeps All files or the files of one layer, Interface, Implementation, or Tests, each with its count; where no tree shows, the toolbar offers the lens as a menu. The repository decides first: a file whose root `.gitattributes` sets `dsh-review-layer=test`, `interface`, or `implementation` is in that layer, and one it marks `linguist-generated` is in Tests. Next come the optional `testPaths` and `interfacePaths` globs, which add to the built-in rules and are empty by default. The built-in rules then follow common conventions: test directories and files of Jest, Vitest, `go test`, pytest, RSpec, XCTest, and .NET, snapshots, locale catalogs, and lockfiles are Tests; package manifests, type declarations, headers, stubs, and interface definitions such as Protocol Buffers, GraphQL, and OpenAPI are Interface. Every other file is in Implementation. For example, `*_test.go dsh-review-layer=test` or `api/**/*.yaml dsh-review-layer=interface` in `.gitattributes` records a repository's own convention. Hide test files leaves Tests out of the file tree and the diff without listing them, and disables the Tests lens. Viewed on a file header marks that change of the file viewed and collapses it; the toolbar shows how many of the shown files are viewed, and `V` marks or clears the file being read: the file holding the focus or the text cursor, else the file at the top of the view. A file whose change differs from the change it was marked at shows Changed since viewed and expands again. Marks are kept in this browser per Session, source, path, and change digest, so they survive closing the tab and reloading. All commits beside Submit review, and beside the base branch in the Branch scope, lists the commits oldest first; a click shows one commit and a Shift click the commits from the last one clicked; the view then shows those commits' changes, reads unchanged lines at the last of them, and offers Add to input but no GitHub comment or review. Branch commits exclude uncommitted and untracked files. Another base or scope returns to all commits, and a chosen commit that is gone offers Show all commits.
|
||||
|
||||
The checks row initially shows the polling preview. While it is incomplete, the card uses the host’s aggregate outcome without a failure count and labels the loaded check count as partial. Opening the list loads the remaining pages for that PR through `changeRequestChecks`; its deadline is independent of polling. A failed read keeps the preview and offers Retry. Closing the list, changing the head, or unmounting cancels the read; late results are ignored. Reopening reads current details. The Remote requires a visible Session binding and rejects a response for a different head commit.
|
||||
|
||||
@@ -69,7 +69,7 @@ Restoration records `restoring` before mutation and `restored` only after succes
|
||||
|
||||
Each inspection also decides whether the worktree is missing: the Session's directory lies inside the created worktree, `ctx.fs.lstat` finds no directory there, and `show-ref` in the source repository tells whether the branch still exists.
|
||||
|
||||
`localDiff` takes the fork point from the created worktree's `baseCommit` when the Session works in it, else, for each remote in the code host order, from `symbolic-ref --quiet --short refs/remotes/<remote>/HEAD` and `merge-base HEAD`; without one the `branch` scope refuses with `forgePanel/no-fork-point`. A `branch` scope that names a base ref under `refs/heads/` or `refs/remotes/` instead takes `merge-base HEAD` with it once `show-ref --verify` finds the ref, refusing with `forgePanel/base-missing` when the ref does not exist and with `forgePanel/no-fork-point` when HEAD shares no history with it; another ref name is refused before Git runs. It runs `diff --no-ext-diff --no-textconv --submodule=short --ignore-submodules=dirty --no-color -M` with fixed `a/` and `b/` prefixes and `core.quotePath=false` against the fork point, against HEAD (the empty tree before the first commit), against the index, or with `--cached` against HEAD. Before patches and statistics, Git configuration is read to apply command-local clean/process filter overrides. A failed or truncated configuration read stops the comparison: `localDiff` reports `forgePanel/filter-config-failed`, with a retry after correcting Git configuration or the output limit; failed statistics leave the local changes card hidden. Filter enumeration uses `maxDiffBytes` for patches and `maxOutputBytes` for statistics. Untracked files, at most `maxUntrackedFiles` with the rest counted as omitted, come from `ls-files --others --exclude-standard -z` and are read through `ctx.fs` as new files, binary when their first 8,000 bytes hold a NUL byte or they are not UTF-8. A patch, file list, or file over `maxDiffBytes` refuses with `forgePanel/diff-too-large`, and a directory outside a checkout with `forgePanel/not-a-checkout`. The Host parses patches with jsdiff into files and hunks, so the browser receives no raw patch. It gives each file a digest of its paths, status, and hunks, plus the blob names of a binary change or the content of an untracked binary file, and a layer from picomatch matches of `testPaths` and `interfacePaths`, with dot files included, and from the `linguist-generated` lines of the root `.gitattributes`: the index for Staged, the working tree for the other local scopes, the last chosen commit for chosen commits, and the head or last chosen commit through `fileText` for a change request, where a missing file reads as none. `localCommits` lists the commits between the fork point with `log --topo-order --reverse`, at most `maxCommits`. A Branch scope with chosen commits compares the first one's first parent, or the empty tree for a root commit, with the last, refusing commits that are not full object names, not listed, or out of order with `forgePanel/commits-missing`; `localText` reads that last commit through `show`. `localText` reads the new side of one file, from the index through `show :<path>` for Staged and through `ctx.fs` otherwise, and refuses a path that leaves the checkout. `changeRequestDiff` and `changeRequestText` act only on a visible binding a provider serves, else they refuse with `forgePanel/not-bound`; they read the head commit of the binding's latest status through the provider's `diff` and `fileText`, refuse a `too-large` failure with `forgePanel/diff-too-large`, and refuse with `forgePanel/diff-failed` before a status was read or when the host refuses otherwise. The Host keeps the patches `changeRequestDiff` read with their attributes, one per change request at its head commit and base branch, and drops the least recently read once they exceed `maxCachedDiffBytes`; a later read at the same head and base answers from memory for any Session, and a failed read is not kept. `changeRequestCommits` returns the provider's `commits` list, or null when the provider does not read commits; `changeRequestDiff` with chosen commits finds them in that list and reads `compare` from the first one's parent to the last, uncached. The commits the checkout has beyond the head come from `symbolic-ref`, `cat-file -e`, and `rev-list --count`, and are null when the checked-out branch is not the head branch, the head commit is absent, or Git fails.
|
||||
`localDiff` takes the fork point from the created worktree's `baseCommit` when the Session works in it, else, for each remote in the code host order, from `symbolic-ref --quiet --short refs/remotes/<remote>/HEAD` and `merge-base HEAD`; without one the `branch` scope refuses with `forgePanel/no-fork-point`. A `branch` scope that names a base ref under `refs/heads/` or `refs/remotes/` instead takes `merge-base HEAD` with it once `show-ref --verify` finds the ref, refusing with `forgePanel/base-missing` when the ref does not exist and with `forgePanel/no-fork-point` when HEAD shares no history with it; another ref name is refused before Git runs. It runs `diff --no-ext-diff --no-textconv --submodule=short --ignore-submodules=dirty --no-color -M` with fixed `a/` and `b/` prefixes and `core.quotePath=false` against the fork point, against HEAD (the empty tree before the first commit), against the index, or with `--cached` against HEAD. Before patches and statistics, Git configuration is read to apply command-local clean/process filter overrides. A failed or truncated configuration read stops the comparison: `localDiff` reports `forgePanel/filter-config-failed`, with a retry after correcting Git configuration or the output limit; failed statistics leave the local changes card hidden. Filter enumeration uses `maxDiffBytes` for patches and `maxOutputBytes` for statistics. Untracked files, at most `maxUntrackedFiles` with the rest counted as omitted, come from `ls-files --others --exclude-standard -z` and are read through `ctx.fs` as new files, binary when their first 8,000 bytes hold a NUL byte or they are not UTF-8. A patch, file list, or file over `maxDiffBytes` refuses with `forgePanel/diff-too-large`, and a directory outside a checkout with `forgePanel/not-a-checkout`. The Host parses patches with jsdiff into files and hunks, so the browser receives no raw patch. It gives each file a digest of its paths, status, and hunks, plus the blob names of a binary change or the content of an untracked binary file, and a layer from the `dsh-review-layer` and `linguist-generated` lines of the root `.gitattributes`, later lines overriding earlier ones and a value other than a layer name leaving the layer unspecified, then from picomatch matches, with dot files included, of `testPaths`, `interfacePaths`, and the built-in rules in [`src/layers.ts`](src/layers.ts), with `.gitattributes` read from the index for Staged, the working tree for the other local scopes, the last chosen commit for chosen commits, and the head or last chosen commit through `fileText` for a change request, where a missing file reads as none. `localCommits` lists the commits between the fork point with `log --topo-order --reverse`, at most `maxCommits`. A Branch scope with chosen commits compares the first one's first parent, or the empty tree for a root commit, with the last, refusing commits that are not full object names, not listed, or out of order with `forgePanel/commits-missing`; `localText` reads that last commit through `show`. `localText` reads the new side of one file, from the index through `show :<path>` for Staged and through `ctx.fs` otherwise, and refuses a path that leaves the checkout. `changeRequestDiff` and `changeRequestText` act only on a visible binding a provider serves, else they refuse with `forgePanel/not-bound`; they read the head commit of the binding's latest status through the provider's `diff` and `fileText`, refuse a `too-large` failure with `forgePanel/diff-too-large`, and refuse with `forgePanel/diff-failed` before a status was read or when the host refuses otherwise. The Host keeps the patches `changeRequestDiff` read with their attributes, one per change request at its head commit and base branch, and drops the least recently read once they exceed `maxCachedDiffBytes`; a later read at the same head and base answers from memory for any Session, and a failed read is not kept. `changeRequestCommits` returns the provider's `commits` list, or null when the provider does not read commits; `changeRequestDiff` with chosen commits finds them in that list and reads `compare` from the first one's parent to the last, uncached. The commits the checkout has beyond the head come from `symbolic-ref`, `cat-file -e`, and `rev-list --count`, and are null when the checked-out branch is not the head branch, the head commit is absent, or Git fails.
|
||||
|
||||
`changeRequestStates` streams, for the Session list, the last known number, title, state, draft flag, checks rollup, review decision, and mergeability of every change request that a listed Session the caller may read binds: a `baseline` frame, then `changed` frames. One run serves every stream. Cancellation is observed before initialization and between frames; the last stream and plugin disposal await initialization and accepted writes, then close the run’s storage domain. A later run waits for that closure before reopening the domain and reading its stored states. Binding updates received during listing override its initial snapshot. It lists Sessions through `sessionQuery` without loading them, takes the visible bindings of a loaded Session from `ctx.forgeSession` and of another from its cached `forgeChangeRequests` summary, follows binding changes of loaded Sessions, and subscribes to each bound change request through `ctx.forge.watch`; closed requests use the idle polling cadence, and merged requests remain subscribed for explicit refresh. It stores every changed state in the `forge_panel_change_requests` storage domain under the SHA-256 digest of its URL and drops unbound stored states only when every listed Session has known bindings; a failed write is logged and the state stays in memory. The stream fails when the Host lacks the Session query, projection cache, storage, or Session store service.
|
||||
|
||||
@@ -140,7 +140,7 @@ None for a new worktree, as its notice belongs to the first request of the Sessi
|
||||
- **Very many branches** — the base branch menu reads every ref before it filters, so a search can reach any branch. Refs over `maxDiffBytes`, about 165,000 at the default, or a listing over `gitTimeoutMs`, leave the menu saying that branches could not be read; Default keeps working.
|
||||
- **Large changes** — a local patch over `maxDiffBytes` shows no files, and a change request diff over the size limit of the host or its provider shows no files and offers only View in browser. Without wrapping, the side-by-side view cuts long lines at the column edge.
|
||||
- **Viewed files on the code host** — viewed marks of a change request stay in this browser and are not read from or written to GitHub's viewed state (`markFileAsViewed`) until the provider's review operations exist; another browser or device starts without them.
|
||||
- **Review layers** — the Interface layer follows path globs only and keeps whole files; finding changed exports needs a language analyzer that a later lens extension point can supply. `linguist-generated` is read only from the root `.gitattributes`, without nested `.gitattributes` files or attribute macros.
|
||||
- **Review layers** — the built-in rules cover common conventions only, so a repository records others in `.gitattributes`; a path cannot show Rust's inline `#[cfg(test)]` modules or which declarations a language exports, and the Interface layer keeps whole files, so finding changed exports needs a language analyzer that a later lens extension point can supply. `linguist-generated` is read only from the root `.gitattributes`, without nested `.gitattributes` files or attribute macros.
|
||||
- **Chosen commits** — a change request lists at most `maxCommits` commits of the provider, 250 for GitHub, and a commit range is read from the host on every view; comments on chosen commits can only be added to the input, as a GitHub review addresses the head.
|
||||
- **Review page** — deferred: a left-navigation page that lists the user's change requests from the selected provider; the [decision note](../../../.agents/notes/implemented/feature/2026-10-09-forge-panel.md) records where it attaches.
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ kind: "package-reference"
|
||||
- **本地变更卡片**——`branch` 范围有文件变更时始终显示,不受已关联变更请求影响。变更请求列表上方的卡片显示比较的基准(例如 `HEAD → origin/main`,始终是下文的默认基准)以及新增、删除行数与文件数,点击打开变更视图;展开的文件列表像变更视图一样标出各个文件,点击某个文件时,变更视图定位到该文件。识别出代码托管仓库、且没有以当前检出分支为源分支的打开中变更请求(含草稿)时,卡片提供“创建变更请求”:它以界面语言向 Session 发送一条用户消息,请 Agent 为这些变更创建变更请求,并以 toast 报告是否已发送。
|
||||
- **变更视图**——展开的变更请求卡片上的“变更”一行与本地变更卡片会打开一个右侧边栏标签页,列出所有变更的文件。本地标签页名为“本地变更”,默认显示“分支”:工作树与未跟踪文件相对于分叉点的变更。它的标题栏写出当前检出的分支(分离 HEAD 时为缩写提交)与基准分支;点击基准分支打开可搜索的菜单:最前面是“默认”,即 Session 创建的 worktree 的基准提交,否则是 HEAD 与代码托管远端默认分支的合并基准;其后依次是远程跟踪分支与本地分支,各按最近提交排序,不含当前检出的分支,不在所创建的 worktree 中时也不含“默认”已经指向的远程跟踪分支。输入文字会立即筛选已列出的行,短暂停顿后列出名称包含该文字(不区分大小写)的分支;按 Enter 选择第一行。选择其他分支后,与 HEAD 和该分支的合并基准比较。标签页切换到其他范围时仍保留这个选择;关闭标签页或重新加载应用后回到“默认”。所选分支已不存在时,它的名称显示删除线;它与 HEAD 没有共同历史时,视图同样给出说明;两种情况都提供“使用默认基准分支”而不是“重试”。视图较窄时,先隐藏“包含未提交的修改”,再隐藏当前分支。“未提交”与 HEAD 比较,“未暂存”与暂存区比较,“已暂存”比较暂存区与 HEAD。变更请求的视图显示托管平台在其 head 处的 diff;当前检出分支就是该变更请求的源分支时,还会说明本地分支比该 head 多出几个提交。工具栏可以跳到某个文件、汇总变更行数、刷新,并在左右对比与单栏对比、自动换行与截断长行之间切换。访问过的变更标签页会在切换标签页与 Session、隐藏侧边栏及调整停靠位置时保持挂载,在 diff 未改变时保留文件折叠、大文件展开、上下文展开、布局与滚动位置。隐藏的变更视图释放面板订阅并推迟 diff 读取;返回时仅在最新 head 或本地摘要不同时重新读取。刷新替换 diff 后会丢弃展开的上下文,内容变化也可能移动阅读位置。视图隐藏时关闭临时菜单。关闭标签页或重新加载应用后不保留这些进度。文件名在前,目录在后,用更小的浅色字显示,空间不够时目录先缩短;悬停时显示完整路径,重命名的文件显示新旧两条路径。每个文件带有新文件、已删除、重命名的标记(重命名标记写出原文件名,只换了目录时写出原路径),“分支”范围下的未跟踪文件还标“未提交”;文件菜单可以复制路径,本地变更可在侧边栏打开整个文件,变更请求可在浏览器中查看该文件在 head 处的页面。hunk 之间未变更的行折叠成一行,点击后从文件的新版本展开:工作树、“已暂存”时为暂存区,或经托管平台读取的 head 提交;读取 diff 之后文件又有修改时不会展开,直到视图重新读取。二进制文件与超过 `maxDiffBytes` 的未跟踪文件只显示一条说明;hunk 超过 1,000 行的文件先显示为一条写出变更行数的折叠条,点击后才绘制;前面的文件累计变更超过 5,000 行后,其后的文件默认收起。刷新与页面刷新快捷键、每次导航、变更请求的 head 变化,以及“分支”范围的摘要变化时,视图都会重新读取;变更请求的视图会先等到给出 head 的状态再读取,除非没有提供方服务它或那次轮询失败。重新读取已显示的变更时,刷新图标会旋转。托管平台或其提供方因超过大小上限拒绝给出 diff 的变更请求(例如 GitHub 上超过 300 个文件的 diff)显示“变更太大,无法在这里显示”并提供“在浏览器中查看”;其他读取失败提供“重试”,变更请求还提供“在浏览器中查看”。变更请求的 diff 在缓存期间对每个 head 提交与目标分支只下载一次,因此在同一 head 下重新打开、刷新与导航都不会再从托管平台读取。
|
||||
|
||||
- **分层、测试文件、已审阅与提交**——文件树上方的分层透镜保留全部文件,或“接口”“实现”“测试”中一层的文件,并显示各自的数量;不显示文件树时,工具栏以菜单提供透镜。路径匹配 `testPaths` 或被仓库根目录 `.gitattributes` 标为 `linguist-generated` 的文件属于“测试”;否则路径匹配 `interfacePaths`(例如包清单、配置与类型声明)的文件属于“接口”;其余属于“实现”。“隐藏测试文件”让文件树与 diff 都不显示“测试”层,也不列出被隐藏的文件,同时停用“测试”透镜。文件标题上的“已审阅”把该文件的这次改动标为已审阅并折叠它;工具栏显示已显示文件中已审阅的数量,按 `V` 标记或取消当前阅读的文件:焦点或文本光标所在的文件,否则是视图顶部的文件。改动与标记时不同的文件显示“有新改动”并重新展开。标记按 Session、变更来源、路径与改动摘要保存在本浏览器中,关闭标签页或重新加载后仍在。“提交评审”左侧,以及“分支”范围中基准分支右侧的“全部提交”按从旧到新列出提交;单击只看一个提交,按住 Shift 单击看从上次单击的提交到这个提交的连续多个提交;此时视图显示这些提交的改动,在最后一个提交读取未变更的行,提供“添加到输入框”,但不提供 GitHub 评论或评审。“分支”的提交不含未提交与未跟踪的文件。换基准分支或范围后回到全部提交;所选提交已不存在时提供“查看全部提交”。
|
||||
- **分层、测试文件、已审阅与提交**——文件树上方的分层透镜保留全部文件,或“接口”“实现”“测试”中一层的文件,并显示各自的数量;不显示文件树时,工具栏以菜单提供透镜。仓库的声明优先:根目录 `.gitattributes` 把文件设为 `dsh-review-layer=test`、`interface` 或 `implementation` 时,文件属于对应的层;标为 `linguist-generated` 的文件属于“测试”。其次是可选的 `testPaths` 与 `interfacePaths`,它们追加在内置规则之前,默认为空。最后是按常见约定写的内置规则:Jest、Vitest、`go test`、pytest、RSpec、XCTest 与 .NET 的测试目录和文件、快照、本地化目录与 lockfile 属于“测试”;包清单、类型声明、头文件、类型存根与 Protocol Buffers、GraphQL、OpenAPI 等接口定义属于“接口”。其余文件属于“实现”。例如在 `.gitattributes` 中写 `*_test.go dsh-review-layer=test` 或 `api/**/*.yaml dsh-review-layer=interface`,即可记录仓库自己的约定。“隐藏测试文件”让文件树与 diff 都不显示“测试”层,也不列出被隐藏的文件,同时停用“测试”透镜。文件标题上的“已审阅”把该文件的这次改动标为已审阅并折叠它;工具栏显示已显示文件中已审阅的数量,按 `V` 标记或取消当前阅读的文件:焦点或文本光标所在的文件,否则是视图顶部的文件。改动与标记时不同的文件显示“有新改动”并重新展开。标记按 Session、变更来源、路径与改动摘要保存在本浏览器中,关闭标签页或重新加载后仍在。“提交评审”左侧,以及“分支”范围中基准分支右侧的“全部提交”按从旧到新列出提交;单击只看一个提交,按住 Shift 单击看从上次单击的提交到这个提交的连续多个提交;此时视图显示这些提交的改动,在最后一个提交读取未变更的行,提供“添加到输入框”,但不提供 GitHub 评论或评审。“分支”的提交不含未提交与未跟踪的文件。换基准分支或范围后回到全部提交;所选提交已不存在时提供“查看全部提交”。
|
||||
|
||||
检查行先显示轮询预览。不完整时,卡片使用托管平台的总体状态而不显示失败总数,并注明已加载的检查数量尚不完整。打开列表后,经 `changeRequestChecks` 单独读取该 PR 的后续页,时限独立于轮询。读取失败时保留预览并提供重试。关闭列表、head 变化或组件卸载会取消读取,忽略迟到结果;重新打开会读取当前详情。Remote 要求 URL 是该 Session 可见的绑定,并拒绝 head 提交不一致的响应。
|
||||
|
||||
@@ -69,7 +69,7 @@ worktree 请求是一条 `plugin:client-ui-forge/worktree` 记录,由 `forgeWo
|
||||
|
||||
每次检查还会判断 worktree 是否缺失:Session 的目录位于所创建的 worktree 内,`ctx.fs.lstat` 在那里找不到目录,再由源仓库中的 `show-ref` 判断分支是否还在。
|
||||
|
||||
Session 在所创建的 worktree 中工作时,`localDiff` 以它的 `baseCommit` 为分叉点;否则按代码托管远端的顺序,对每个远端依次运行 `symbolic-ref --quiet --short refs/remotes/<remote>/HEAD` 与 `merge-base HEAD` 找出分叉点;找不到时 `branch` 范围以 `forgePanel/no-fork-point` 拒绝。`branch` 范围指定了 `refs/heads/` 或 `refs/remotes/` 下的基准引用时,`show-ref --verify` 找到该引用后改用 `merge-base HEAD` 与它的结果;引用不存在时以 `forgePanel/base-missing` 拒绝,HEAD 与它没有共同历史时以 `forgePanel/no-fork-point` 拒绝;其他引用名在运行 Git 之前即被拒绝。它以固定的 `a/`、`b/` 前缀和 `core.quotePath=false` 运行 `diff --no-ext-diff --no-textconv --submodule=short --ignore-submodules=dirty --no-color -M`,分别与分叉点、HEAD(第一次提交之前为空树)、暂存区比较,或带 `--cached` 与 HEAD 比较。读取补丁与统计前会查询 Git 配置,应用命令级 clean/process filter 覆盖。配置读取失败或被截断时停止比较:`localDiff` 报告 `forgePanel/filter-config-failed`,修正 Git 配置或读取上限后可重试;统计失败时本地变更卡片保持隐藏。过滤器枚举在读取补丁时使用 `maxDiffBytes` 上限,统计时使用 `maxOutputBytes` 上限。未跟踪文件由 `ls-files --others --exclude-standard -z` 列出,最多 `maxUntrackedFiles` 个,其余计为未列出;它们经 `ctx.fs` 读取并作为新文件加入,前 8,000 字节含 NUL 字节或不是 UTF-8 时视为二进制。补丁、文件列表或文件超过 `maxDiffBytes` 时以 `forgePanel/diff-too-large` 拒绝,目录不在检出中时以 `forgePanel/not-a-checkout` 拒绝。宿主用 jsdiff 把补丁解析为文件与 hunk,浏览器不会收到原始补丁。Host 为每个文件计算由路径、状态与 hunk 组成的摘要(二进制改动加上 blob 名,未跟踪的二进制文件加上内容),并用 picomatch(包含点文件)匹配 `testPaths` 与 `interfacePaths`、读取根目录 `.gitattributes` 中的 `linguist-generated` 行来确定分层:“已暂存”读暂存区,其他本地范围读工作树,所选提交读最后一个提交,变更请求经 `fileText` 读 head 或最后一个所选提交,文件不存在时按没有处理。`localCommits` 用 `log --topo-order --reverse` 列出分叉点之后的提交,最多 `maxCommits` 个。带所选提交的“分支”范围比较第一个提交的第一个父提交(根提交用空树)与最后一个提交;不是完整对象名、不在列表中或顺序颠倒的提交以 `forgePanel/commits-missing` 拒绝;`localText` 经 `show` 读取那个最后的提交。`localText` 读取一个文件的新版本:“已暂存”经 `show :<path>` 从暂存区读取,其余经 `ctx.fs` 读取;离开检出的路径会被拒绝。`changeRequestDiff` 与 `changeRequestText` 只作用于该 Session 中由提供方服务的可见绑定,否则以 `forgePanel/not-bound` 拒绝;它们经提供方的 `diff` 与 `fileText` 读取绑定最新状态中的 head 提交,`too-large` 失败以 `forgePanel/diff-too-large` 拒绝,尚未读到状态或托管平台以其他原因拒绝时以 `forgePanel/diff-failed` 拒绝。Host 保留 `changeRequestDiff` 读到的补丁及其属性,每个变更请求一份,按 head 提交与目标分支区分,总量超过 `maxCachedDiffBytes` 时丢弃最久未读的;之后在同一 head 与目标分支下的读取不论来自哪个 Session 都从内存返回,读取失败的结果不保留。`changeRequestCommits` 返回提供方 `commits` 的列表,提供方不读取提交时返回 null;带所选提交的 `changeRequestDiff` 在该列表中找到它们,并从第一个提交的父提交到最后一个提交读取 `compare`,不缓存。本地分支比 head 多出的提交数由 `symbolic-ref`、`cat-file -e` 与 `rev-list --count` 得出;当前检出分支不是源分支、本地没有 head 提交或 Git 失败时为 null。
|
||||
Session 在所创建的 worktree 中工作时,`localDiff` 以它的 `baseCommit` 为分叉点;否则按代码托管远端的顺序,对每个远端依次运行 `symbolic-ref --quiet --short refs/remotes/<remote>/HEAD` 与 `merge-base HEAD` 找出分叉点;找不到时 `branch` 范围以 `forgePanel/no-fork-point` 拒绝。`branch` 范围指定了 `refs/heads/` 或 `refs/remotes/` 下的基准引用时,`show-ref --verify` 找到该引用后改用 `merge-base HEAD` 与它的结果;引用不存在时以 `forgePanel/base-missing` 拒绝,HEAD 与它没有共同历史时以 `forgePanel/no-fork-point` 拒绝;其他引用名在运行 Git 之前即被拒绝。它以固定的 `a/`、`b/` 前缀和 `core.quotePath=false` 运行 `diff --no-ext-diff --no-textconv --submodule=short --ignore-submodules=dirty --no-color -M`,分别与分叉点、HEAD(第一次提交之前为空树)、暂存区比较,或带 `--cached` 与 HEAD 比较。读取补丁与统计前会查询 Git 配置,应用命令级 clean/process filter 覆盖。配置读取失败或被截断时停止比较:`localDiff` 报告 `forgePanel/filter-config-failed`,修正 Git 配置或读取上限后可重试;统计失败时本地变更卡片保持隐藏。过滤器枚举在读取补丁时使用 `maxDiffBytes` 上限,统计时使用 `maxOutputBytes` 上限。未跟踪文件由 `ls-files --others --exclude-standard -z` 列出,最多 `maxUntrackedFiles` 个,其余计为未列出;它们经 `ctx.fs` 读取并作为新文件加入,前 8,000 字节含 NUL 字节或不是 UTF-8 时视为二进制。补丁、文件列表或文件超过 `maxDiffBytes` 时以 `forgePanel/diff-too-large` 拒绝,目录不在检出中时以 `forgePanel/not-a-checkout` 拒绝。宿主用 jsdiff 把补丁解析为文件与 hunk,浏览器不会收到原始补丁。Host 为每个文件计算由路径、状态与 hunk 组成的摘要(二进制改动加上 blob 名,未跟踪的二进制文件加上内容),并先按根目录 `.gitattributes` 中的 `dsh-review-layer` 与 `linguist-generated` 行确定分层(后面的行覆盖前面的行,不是层名的值视为未指定),再用 picomatch(包含点文件)依次匹配 `testPaths`、`interfacePaths` 与 [`src/layers.ts`](src/layers.ts) 中的内置规则。`.gitattributes` 的读取来源:“已暂存”读暂存区,其他本地范围读工作树,所选提交读最后一个提交,变更请求经 `fileText` 读 head 或最后一个所选提交,文件不存在时按没有处理。`localCommits` 用 `log --topo-order --reverse` 列出分叉点之后的提交,最多 `maxCommits` 个。带所选提交的“分支”范围比较第一个提交的第一个父提交(根提交用空树)与最后一个提交;不是完整对象名、不在列表中或顺序颠倒的提交以 `forgePanel/commits-missing` 拒绝;`localText` 经 `show` 读取那个最后的提交。`localText` 读取一个文件的新版本:“已暂存”经 `show :<path>` 从暂存区读取,其余经 `ctx.fs` 读取;离开检出的路径会被拒绝。`changeRequestDiff` 与 `changeRequestText` 只作用于该 Session 中由提供方服务的可见绑定,否则以 `forgePanel/not-bound` 拒绝;它们经提供方的 `diff` 与 `fileText` 读取绑定最新状态中的 head 提交,`too-large` 失败以 `forgePanel/diff-too-large` 拒绝,尚未读到状态或托管平台以其他原因拒绝时以 `forgePanel/diff-failed` 拒绝。Host 保留 `changeRequestDiff` 读到的补丁及其属性,每个变更请求一份,按 head 提交与目标分支区分,总量超过 `maxCachedDiffBytes` 时丢弃最久未读的;之后在同一 head 与目标分支下的读取不论来自哪个 Session 都从内存返回,读取失败的结果不保留。`changeRequestCommits` 返回提供方 `commits` 的列表,提供方不读取提交时返回 null;带所选提交的 `changeRequestDiff` 在该列表中找到它们,并从第一个提交的父提交到最后一个提交读取 `compare`,不缓存。本地分支比 head 多出的提交数由 `symbolic-ref`、`cat-file -e` 与 `rev-list --count` 得出;当前检出分支不是源分支、本地没有 head 提交或 Git 失败时为 null。
|
||||
|
||||
`changeRequestStates` 为会话列表推送调用方可读的、已列出的 Session 所绑定的每个变更请求的最近编号、标题、状态、草稿标记、检查汇总、评审结论与可合并性:先是一个 `baseline` 帧,之后是 `changed` 帧。所有流共用一次运行。初始化之前和帧之间均响应取消;最后一条流结束及插件卸载会等待初始化与已接受的写入完成,再关闭本次运行的存储域。后续运行会等待该域关闭后重新打开,并读取已存状态。列举期间收到的绑定更新优先于初始快照。它经 `sessionQuery` 列出 Session 而不加载它们,已加载 Session 的可见绑定取自 `ctx.forgeSession`,其他 Session 的取自缓存的 `forgeChangeRequests` 摘要;它跟随已加载 Session 的绑定变化,并经 `ctx.forge.watch` 订阅每个已绑定的变更请求;已关闭的按空闲间隔轮询,已合并的保留订阅以接收显式刷新结果。每个变化了的状态以其 URL 的 SHA-256 摘要为键存入 `forge_panel_change_requests` 存储域,仅在所有已列出 Session 的绑定均已知时删除无人绑定的已存状态;写入失败时记录日志,状态仍保留在内存中。宿主缺少 Session 查询、投影缓存、存储或 Session 存储服务时,流以失败结束。
|
||||
|
||||
@@ -140,7 +140,7 @@ Session 在所创建的 worktree 中工作时,`localDiff` 以它的 `baseCommi
|
||||
- **分支极多**——基准分支菜单在筛选前读取全部引用,这样搜索才能找到任意分支。引用超过 `maxDiffBytes`(默认约 165,000 个)或列出时间超过 `gitTimeoutMs` 时,菜单提示无法读取分支;“默认”仍可使用。
|
||||
- **大型变更**——本地补丁超过 `maxDiffBytes` 时不显示任何文件;超过托管平台或其提供方大小上限的变更请求 diff 不显示任何文件,只提供“在浏览器中查看”。不自动换行时,左右对比会在栏边截断长行。
|
||||
- **代码托管平台上的已审阅状态**——变更请求的已审阅标记只保存在本浏览器中,在提供方评审接口完成之前,不读取也不写入 GitHub 的已审阅状态(`markFileAsViewed`);换浏览器或设备后没有这些标记。
|
||||
- **分层**——“接口”层只按路径 glob 划分并保留整个文件;找出变更的导出需要语言分析器,可由之后的透镜扩展点提供。`linguist-generated` 只读取根目录的 `.gitattributes`,不读子目录中的 `.gitattributes`,也不展开属性宏。
|
||||
- **分层**——内置规则只覆盖常见约定,其他约定由仓库写在 `.gitattributes` 中;按路径无法识别 Rust 的内联 `#[cfg(test)]` 模块,也无法判断一种语言导出了哪些声明,“接口”层保留整个文件,找出变更的导出需要语言分析器,可由之后的透镜扩展点提供。`linguist-generated` 只读取根目录的 `.gitattributes`,不读子目录中的 `.gitattributes`,也不展开属性宏。
|
||||
- **所选提交**——变更请求最多列出提供方的 `maxCommits` 个提交(GitHub 为 250 个),每次查看提交范围都从托管平台读取;所选提交上的评论只能添加到输入框,因为 GitHub 评审针对 head。
|
||||
- **代码审查页**——待办:在左侧导航中新增一个页面,列出用户在所选提供方上的变更请求;[决策笔记](../../../.agents/notes/implemented/feature/2026-10-09-forge-panel.zh.md)记录了它的接入位置。
|
||||
|
||||
|
||||
@@ -49,26 +49,6 @@ declare module '@deepseek-ai/cordis' {
|
||||
/** Panel limits plus the branch and commit listing limits and the worktree branch prefix. */
|
||||
type ControllerConfig = PanelConfig & { readonly maxBranches: number; readonly maxCommits: number; readonly worktreePrefix: string }
|
||||
|
||||
/**
|
||||
* Tests, test data, snapshots, locale dictionaries, and lockfiles, after the review plugin's collapsed and
|
||||
* non-interface paths; `locales.ts` is the typed dictionary module of a DSH Client plugin.
|
||||
*/
|
||||
const TEST_PATHS = [
|
||||
'**/test/**', '**/tests/**', '**/__tests__/**', '**/__mocks__/**', '**/__fixtures__/**', '**/e2e/**',
|
||||
'**/*.spec.*', '**/*.test.*', '**/*.e2e.*',
|
||||
'**/__snapshots__/**', 'snapshots/**', '**/*.snap',
|
||||
'**/locale/*.json', '**/locales/**', '**/locales.ts',
|
||||
'**/pnpm-lock.yaml', '**/package-lock.json', '**/npm-shrinkwrap.json', '**/yarn.lock',
|
||||
] as const
|
||||
|
||||
/** Package manifests, type declarations, and configuration by extension, name, or directory, after the review plugin's scanner. */
|
||||
const INTERFACE_PATHS = [
|
||||
'**/package.json', '**/*.d.ts', '**/*.d.mts', '**/*.d.cts', '**/types.ts',
|
||||
'**/*.{json,jsonc,yaml,yml,toml,ini,conf,cfg,properties,xml,plist}',
|
||||
'**/.env', '**/.env.*', '**/.*rc', '**/.*rc.*', '**/*{config,settings,preferences,options}*',
|
||||
'**/{config,configs,settings,profiles}/**',
|
||||
] as const
|
||||
|
||||
/**
|
||||
* Serves the forge panel. Following a Session inspects the checkout of its
|
||||
* current directory using the Session's permissions and execution world, recognizes the
|
||||
@@ -101,8 +81,8 @@ export class ForgePanelController extends TypertRemoteService {
|
||||
maxUntrackedFiles: z.number().default(100),
|
||||
maxCachedDiffBytes: z.number().default(16_777_216),
|
||||
maxCommits: z.number().default(250),
|
||||
testPaths: z.array(z.string()).default([...TEST_PATHS]),
|
||||
interfacePaths: z.array(z.string()).default([...INTERFACE_PATHS]),
|
||||
testPaths: z.array(z.string()).default([]),
|
||||
interfacePaths: z.array(z.string()).default([]),
|
||||
})
|
||||
|
||||
private readonly home: Context
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* Review layers of changed files: the `testPaths` and `interfacePaths` globs of the panel's configuration, and the
|
||||
* `linguist-generated` attribute of a repository's root `.gitattributes`, which also places a file in the `test` layer.
|
||||
* Review layers of changed files. A repository's root `.gitattributes` decides first: its `dsh-review-layer`
|
||||
* attribute names a layer, and `linguist-generated` places a file in the `test` layer. The panel's `testPaths` and
|
||||
* `interfacePaths` configuration comes next, then the built-in rules, which follow the default file and directory
|
||||
* conventions of common languages and tools; every other file is in the `implementation` layer.
|
||||
*/
|
||||
|
||||
import picomatch from 'picomatch'
|
||||
@@ -10,11 +12,61 @@ import type { ForgeDiffFile, ForgeFileLayer } from './types.ts'
|
||||
/** Path of the attributes file read beside each diff, relative to the repository root. */
|
||||
export const ATTRIBUTES_PATH = '.gitattributes'
|
||||
|
||||
/** The attribute a repository sets to a layer name to place files in that layer. */
|
||||
export const LAYER_ATTRIBUTE = 'dsh-review-layer'
|
||||
|
||||
/** The attribute GitHub Linguist reads to treat a file as generated. */
|
||||
const GENERATED = 'linguist-generated'
|
||||
|
||||
const LAYERS: ReadonlySet<string> = new Set<ForgeFileLayer>(['interface', 'implementation', 'test'])
|
||||
|
||||
/** Whether an attribute value names a layer. */
|
||||
function isLayer(value: string): value is ForgeFileLayer {
|
||||
return LAYERS.has(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests, test data, snapshots, locale dictionaries, and lockfiles by the default conventions of their tools: test
|
||||
* directories, Jest and Vitest `*.spec.*` and `*.test.*` files, `go test` `*_test.go` files and `testdata/`
|
||||
* directories, pytest's `test_*.py`, `*_test.py`, and `conftest.py`, RSpec's `spec/` and `*_spec.rb`, SwiftPM's
|
||||
* `Tests/`, .NET `*.Tests/` projects, Jest and insta snapshots, i18next and Rails `locales/`, gettext catalogs,
|
||||
* Apple `.lproj` strings, Android string resources, and the lockfiles of npm, pnpm, Yarn, Bun, Cargo, Go modules,
|
||||
* Poetry, uv, Pipenv, Bundler, Composer, SwiftPM, NuGet, Gradle, pub, Mix, and Nix flakes.
|
||||
*/
|
||||
export const BUILT_IN_TEST_PATHS: readonly string[] = [
|
||||
'**/test/**', '**/tests/**', '**/Tests/**', '**/__tests__/**', '**/spec/**', '**/e2e/**', '**/testdata/**', '**/__mocks__/**',
|
||||
'**/__fixtures__/**', '**/*.Tests/**',
|
||||
'**/*.spec.*', '**/*.test.*', '**/*.e2e.*', '**/*_test.go', '**/test_*.py', '**/*_test.py', '**/conftest.py', '**/*_spec.rb',
|
||||
'**/__snapshots__/**', '**/*.snap',
|
||||
'**/locales/**', '**/*.po', '**/*.pot', '**/*.lproj/*.strings', '**/res/values-*/strings.xml',
|
||||
'**/package-lock.json', '**/npm-shrinkwrap.json', '**/pnpm-lock.yaml', '**/yarn.lock', '**/bun.lock', '**/bun.lockb', '**/Cargo.lock',
|
||||
'**/go.sum', '**/poetry.lock', '**/uv.lock', '**/Pipfile.lock', '**/Gemfile.lock', '**/composer.lock', '**/Package.resolved',
|
||||
'**/packages.lock.json', '**/gradle.lockfile', '**/pubspec.lock', '**/mix.lock', '**/flake.lock',
|
||||
]
|
||||
|
||||
/**
|
||||
* Package manifests of npm, Go modules, Cargo, Python packaging, Bundler and RubyGems, Maven, Gradle, MSBuild,
|
||||
* SwiftPM, Composer, pub, and Mix; TypeScript declarations, Python stubs, and C and C++ headers; and interface
|
||||
* definitions of Protocol Buffers, GraphQL, Thrift, and OpenAPI.
|
||||
*/
|
||||
export const BUILT_IN_INTERFACE_PATHS: readonly string[] = [
|
||||
'**/package.json', '**/go.mod', '**/Cargo.toml', '**/pyproject.toml', '**/setup.py', '**/setup.cfg', '**/Gemfile', '**/*.gemspec',
|
||||
'**/pom.xml', '**/build.gradle', '**/build.gradle.kts', '**/*.csproj', '**/Package.swift', '**/composer.json', '**/pubspec.yaml',
|
||||
'**/mix.exs',
|
||||
'**/*.d.ts', '**/*.d.mts', '**/*.d.cts', '**/*.pyi', '**/*.h', '**/*.hpp',
|
||||
'**/*.proto', '**/*.graphql', '**/*.graphqls', '**/*.thrift', '**/openapi.{json,yaml,yml}', '**/swagger.{json,yaml,yml}',
|
||||
]
|
||||
|
||||
type Matcher = (path: string) => boolean
|
||||
|
||||
/** What a repository's attributes say about one path. */
|
||||
interface PathAttributes {
|
||||
/** The layer `dsh-review-layer` names, or undefined while it is unspecified. */
|
||||
readonly layer: ForgeFileLayer | undefined
|
||||
/** Whether `linguist-generated` is set. */
|
||||
readonly generated: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile globs into one matcher; `*` matches dot files and never crosses `/`.
|
||||
* @param globs - picomatch globs.
|
||||
@@ -25,63 +77,84 @@ function matcherOf(globs: readonly string[]): Matcher {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read which paths a `.gitattributes` text marks `linguist-generated`. Lines apply in order, so a later line overrides
|
||||
* an earlier one; `linguist-generated` and `=true` set the attribute, `-linguist-generated` and `=false` unset it, and
|
||||
* `!linguist-generated` returns it to unspecified. A pattern without `/` matches a file name at any depth, and one with
|
||||
* `/` matches from the repository root. Macro definitions, quoted patterns, and patterns ending in `/`, which name
|
||||
* directories and so never match a file, are skipped.
|
||||
* Read the review attributes a `.gitattributes` text gives each path. Lines apply in order, so a later line overrides
|
||||
* an earlier one. `dsh-review-layer=<layer>` names `test`, `interface`, or `implementation`; another value,
|
||||
* `-dsh-review-layer`, and `!dsh-review-layer` leave the layer unspecified. `linguist-generated` and `=true` set
|
||||
* the generated attribute, `-linguist-generated` and `=false` unset it, and `!linguist-generated` returns it to
|
||||
* unspecified. A pattern without `/` matches a file name at any depth, and one with `/` matches from the repository
|
||||
* root. Macro definitions, quoted patterns, and patterns ending in `/`, which name directories and so never match a
|
||||
* file, are skipped.
|
||||
* @param attributes - the text of the root `.gitattributes`, empty without one.
|
||||
* @returns whether a repository-relative path is generated.
|
||||
* @returns the attributes of a repository-relative path.
|
||||
*/
|
||||
export function generatedMatcher(attributes: string): Matcher {
|
||||
const rules: { readonly match: Matcher; readonly generated: boolean | undefined }[] = []
|
||||
export function attributesOf(attributes: string): (path: string) => PathAttributes {
|
||||
// `undefined` leaves an attribute as earlier lines set it, and `null` returns it to unspecified.
|
||||
const rules: {
|
||||
readonly match: Matcher
|
||||
readonly layer: ForgeFileLayer | null | undefined
|
||||
readonly generated: boolean | null | undefined
|
||||
}[] = []
|
||||
for (const raw of attributes.split(/\r?\n/)) {
|
||||
const [pattern, ...fields] = raw.trim().split(/\s+/)
|
||||
if (pattern === undefined || pattern === '' || pattern.startsWith('#') || pattern.startsWith('[attr]')
|
||||
|| pattern.startsWith('"') || pattern.endsWith('/')) continue
|
||||
let generated: boolean | null | undefined = null
|
||||
let layer: ForgeFileLayer | null | undefined
|
||||
let generated: boolean | null | undefined
|
||||
for (const field of fields) {
|
||||
if (field === GENERATED || field === `${GENERATED}=true`) generated = true
|
||||
else if (field === `-${GENERATED}` || field === `${GENERATED}=false`) generated = false
|
||||
else if (field === `!${GENERATED}`) generated = undefined
|
||||
else if (field === `!${GENERATED}`) generated = null
|
||||
else if (field.startsWith(`${LAYER_ATTRIBUTE}=`)) {
|
||||
const value = field.slice(LAYER_ATTRIBUTE.length + 1)
|
||||
layer = isLayer(value) ? value : null
|
||||
} else if (field === `-${LAYER_ATTRIBUTE}` || field === `!${LAYER_ATTRIBUTE}`) layer = null
|
||||
}
|
||||
if (generated === null) continue
|
||||
if (layer === undefined && generated === undefined) continue
|
||||
const anchored = pattern.replace(/^\//, '')
|
||||
rules.push({ match: picomatch(anchored, { dot: true, basename: !pattern.includes('/') }), generated })
|
||||
rules.push({ match: picomatch(anchored, { dot: true, basename: !pattern.includes('/') }), layer, generated })
|
||||
}
|
||||
return (path) => {
|
||||
let generated: boolean | undefined
|
||||
for (const rule of rules) if (rule.match(path)) generated = rule.generated
|
||||
return generated === true
|
||||
let layer: ForgeFileLayer | null | undefined
|
||||
let generated: boolean | null | undefined
|
||||
for (const rule of rules) {
|
||||
if (!rule.match(path)) continue
|
||||
if (rule.layer !== undefined) layer = rule.layer
|
||||
if (rule.generated !== undefined) generated = rule.generated
|
||||
}
|
||||
return { layer: layer ?? undefined, generated: generated === true }
|
||||
}
|
||||
}
|
||||
|
||||
/** Classifies changed files into review layers by the panel's path globs and a repository's attributes. */
|
||||
/** Classifies changed files into review layers by a repository's attributes, the panel's globs, and the built-in rules. */
|
||||
export class FileLayers {
|
||||
private readonly test: Matcher
|
||||
private readonly interface: Matcher
|
||||
private readonly rules: readonly { readonly layer: ForgeFileLayer; readonly match: Matcher }[]
|
||||
|
||||
/**
|
||||
* @param testPaths - globs of the `test` layer.
|
||||
* @param interfacePaths - globs of the `interface` layer.
|
||||
* @param testPaths - configured globs of the `test` layer, checked before the built-in rules.
|
||||
* @param interfacePaths - configured globs of the `interface` layer, checked after `testPaths` and before the built-in rules.
|
||||
*/
|
||||
constructor(testPaths: readonly string[], interfacePaths: readonly string[]) {
|
||||
this.test = matcherOf(testPaths)
|
||||
this.interface = matcherOf(interfacePaths)
|
||||
this.rules = [
|
||||
{ layer: 'test', match: matcherOf(testPaths) },
|
||||
{ layer: 'interface', match: matcherOf(interfacePaths) },
|
||||
{ layer: 'test', match: matcherOf(BUILT_IN_TEST_PATHS) },
|
||||
{ layer: 'interface', match: matcherOf(BUILT_IN_INTERFACE_PATHS) },
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* Place each file in its layer: `test` first, then `interface`, else `implementation`.
|
||||
* Place each file in its layer: the layer its attributes name, else `test` for a generated file, else the first
|
||||
* configured or built-in rule its path matches, else `implementation`.
|
||||
* @param files - parsed files.
|
||||
* @param attributes - the text of the repository's root `.gitattributes`, empty without one.
|
||||
* @returns the files in the same order with their layers.
|
||||
*/
|
||||
classify(files: readonly ParsedDiffFile[], attributes: string): ForgeDiffFile[] {
|
||||
const generated = generatedMatcher(attributes)
|
||||
const attributesAt = attributesOf(attributes)
|
||||
return files.map((file) => {
|
||||
const layer: ForgeFileLayer = this.test(file.path) || generated(file.path) ? 'test'
|
||||
: this.interface(file.path) ? 'interface' : 'implementation'
|
||||
return { ...file, layer }
|
||||
const { layer, generated } = attributesAt(file.path)
|
||||
const ruled = layer ?? (generated ? 'test' : this.rules.find(rule => rule.match(file.path))?.layer) ?? 'implementation'
|
||||
return { ...file, layer: ruled }
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -287,8 +287,9 @@ export interface ForgeDiffHunk {
|
||||
export type ForgeDiffStatus = 'added' | 'deleted' | 'modified' | 'renamed'
|
||||
|
||||
/**
|
||||
* Review layer of a changed file by its path: `test` for a path matching `testPaths` or one the repository's root
|
||||
* `.gitattributes` marks `linguist-generated`, else `interface` for a path matching `interfacePaths`, else `implementation`.
|
||||
* Review layer of a changed file: the layer the repository's root `.gitattributes` names with `dsh-review-layer`, else
|
||||
* `test` for a file it marks `linguist-generated`, else the first of `testPaths`, `interfacePaths`, and the built-in
|
||||
* test and interface rules that the path matches, else `implementation`.
|
||||
*/
|
||||
export type ForgeFileLayer = 'interface' | 'implementation' | 'test'
|
||||
|
||||
@@ -397,11 +398,14 @@ export interface Config {
|
||||
/** Most commits of the `branch` scope listed, oldest first. */
|
||||
maxCommits?: number
|
||||
/**
|
||||
* Globs of tests, snapshots, locale dictionaries, and lockfiles, matched against repository-relative paths with
|
||||
* dot files included; their files form the `test` layer, which the changes view can hide.
|
||||
* Globs of files in the `test` layer, which the changes view can hide, beside the built-in rules and checked before
|
||||
* them; matched against repository-relative paths with dot files included. A repository's `.gitattributes` overrides both.
|
||||
*/
|
||||
testPaths?: string[]
|
||||
/** Globs of package manifests, configuration, and type declarations, matched like `testPaths`; their files form the `interface` layer. */
|
||||
/**
|
||||
* Globs of files in the `interface` layer beside the built-in rules, matched like `testPaths`; checked after
|
||||
* `testPaths` and before the built-in rules.
|
||||
*/
|
||||
interfacePaths?: string[]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,39 @@
|
||||
/** Review layers of changed files: path globs and the `linguist-generated` attribute of a root `.gitattributes`. */
|
||||
/** Review layers of changed files: repository attributes, configured globs, and the built-in rules, in that order. */
|
||||
import { execFile } from 'node:child_process'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { promisify } from 'node:util'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { untrackedFile } from '../src/diff.ts'
|
||||
import { FileLayers, generatedMatcher } from '../src/layers.ts'
|
||||
import { attributesOf, FileLayers } from '../src/layers.ts'
|
||||
|
||||
const run = promisify(execFile)
|
||||
const file = (path: string) => untrackedFile(path, new Uint8Array())
|
||||
const layersOf = (layers: FileLayers, paths: readonly string[], attributes = ''): string[] =>
|
||||
layers.classify(paths.map(file), attributes).map(item => `${item.path} ${item.layer}`)
|
||||
|
||||
describe('attributesOf', () => {
|
||||
const read = attributesOf([
|
||||
'# comment',
|
||||
'',
|
||||
'[attr]binary -diff -merge -text',
|
||||
'"quoted name.json" linguist-generated',
|
||||
'build/ linguist-generated',
|
||||
'*.schema.json linguist-generated=true',
|
||||
'docs/kept.schema.json -linguist-generated',
|
||||
'docs/reset.schema.json !linguist-generated',
|
||||
'docs/off.schema.json linguist-generated=false',
|
||||
'/root.gen.ts linguist-generated',
|
||||
'gen/*.ts text linguist-generated',
|
||||
'other.txt text',
|
||||
'api/*.yaml dsh-review-layer=interface',
|
||||
'api/legacy.yaml -dsh-review-layer',
|
||||
'api/odd.yaml dsh-review-layer=docs',
|
||||
'api/reset.yaml !dsh-review-layer',
|
||||
'*.snap.ts dsh-review-layer=test linguist-generated',
|
||||
].join('\r\n'))
|
||||
|
||||
describe('generatedMatcher', () => {
|
||||
it('applies lines in order, with unset and unspecified values overriding an earlier set', () => {
|
||||
const generated = generatedMatcher([
|
||||
'# comment',
|
||||
'',
|
||||
'[attr]binary -diff -merge -text',
|
||||
'"quoted name.json" linguist-generated',
|
||||
'build/ linguist-generated',
|
||||
'*.schema.json linguist-generated=true',
|
||||
'docs/kept.schema.json -linguist-generated',
|
||||
'docs/reset.schema.json !linguist-generated',
|
||||
'docs/off.schema.json linguist-generated=false',
|
||||
'/root.gen.ts linguist-generated',
|
||||
'gen/*.ts text linguist-generated',
|
||||
'other.txt text',
|
||||
].join('\r\n'))
|
||||
|
||||
const generated = (path: string): boolean => read(path).generated
|
||||
expect(generated('a.schema.json')).toBe(true)
|
||||
expect(generated('docs/deep/a.schema.json')).toBe(true)
|
||||
expect(generated('docs/kept.schema.json')).toBe(false)
|
||||
@@ -34,32 +48,68 @@ describe('generatedMatcher', () => {
|
||||
expect(generated('other.txt')).toBe(false)
|
||||
})
|
||||
|
||||
it('reads a layer name, and leaves an unset, reset, or unknown layer unspecified', () => {
|
||||
expect(read('api/v1.yaml')).toEqual({ layer: 'interface', generated: false })
|
||||
expect(read('api/legacy.yaml').layer).toBeUndefined()
|
||||
expect(read('api/odd.yaml').layer).toBeUndefined()
|
||||
expect(read('api/reset.yaml').layer).toBeUndefined()
|
||||
expect(read('src/a.snap.ts')).toEqual({ layer: 'test', generated: true })
|
||||
})
|
||||
|
||||
it('marks nothing without attributes', () => {
|
||||
expect(generatedMatcher('')('a.ts')).toBe(false)
|
||||
expect(attributesOf('')('a.ts')).toEqual({ layer: undefined, generated: false })
|
||||
})
|
||||
|
||||
it('agrees with git check-attr on this repository\'s own review layer lines', async () => {
|
||||
const paths = [
|
||||
'packages/experimental/client-ui-forge/locale/en.json', 'packages/experimental/client-ui-forge/src/client/locales.ts',
|
||||
'packages/experimental/client-ui-forge/src/types.ts', 'packages/typert/generator/tests/fixtures/remote-model/packages/domain/src/types.ts',
|
||||
'packages/client/locale/package.json', 'snapshots/session/headless.snapshot.ts', 'README.i18n.yaml', 'docs/persistence-schema.json',
|
||||
]
|
||||
const { stdout } = await run('git', ['check-attr', 'dsh-review-layer', 'linguist-generated', '--', ...paths])
|
||||
const expected = paths.map((path) => {
|
||||
const value = (name: string): string | undefined => new RegExp(`^${path.replaceAll('.', '\\.')}: ${name}: (.*)$`, 'm').exec(stdout)?.[1]
|
||||
const layer = value('dsh-review-layer')
|
||||
return { layer: layer === 'unspecified' ? undefined : layer, generated: value('linguist-generated') === 'true' }
|
||||
})
|
||||
const read = attributesOf(await readFile(new URL('../../../../.gitattributes', import.meta.url), 'utf8'))
|
||||
expect(paths.map(path => read(path))).toEqual(expected)
|
||||
})
|
||||
})
|
||||
|
||||
describe('FileLayers', () => {
|
||||
const file = (path: string) => untrackedFile(path, new Uint8Array())
|
||||
|
||||
it('places a file in the test layer first, then the interface layer, else the implementation layer', () => {
|
||||
const layers = new FileLayers(['**/*.spec.*', '**/locale/*.json'], ['**/package.json', '**/*.json'])
|
||||
const classified = layers.classify(
|
||||
['src/a.ts', 'src/a.spec.ts', 'package.json', 'locale/en.json', 'docs/schema.json', '.github/x.json'].map(file),
|
||||
'docs/schema.json linguist-generated\n',
|
||||
)
|
||||
|
||||
expect(classified.map(item => [item.path, item.layer])).toEqual([
|
||||
['src/a.ts', 'implementation'],
|
||||
['src/a.spec.ts', 'test'],
|
||||
['package.json', 'interface'],
|
||||
['locale/en.json', 'test'],
|
||||
['docs/schema.json', 'test'],
|
||||
['.github/x.json', 'interface'],
|
||||
it('follows the built-in conventions of common languages and tools', () => {
|
||||
expect(layersOf(new FileLayers([], []), [
|
||||
'pkg/server_test.go', 'pkg/testdata/in.txt', 'app/test_api.py', 'app/api_test.py', 'conftest.py', 'spec/models/user_spec.rb',
|
||||
'Tests/AppTests/AppTests.swift', 'App.Tests/UnitTest1.cs', 'src/a.spec.ts', 'src/__snapshots__/a.snap', 'config/locales/en.yml',
|
||||
'po/zh_CN.po', 'App/en.lproj/Localizable.strings', 'app/src/main/res/values-zh/strings.xml', 'Cargo.lock', 'go.sum', 'uv.lock',
|
||||
'go.mod', 'Cargo.toml', 'pyproject.toml', 'lib.gemspec', 'build.gradle.kts', 'App.csproj', 'Package.swift', 'include/api.h',
|
||||
'stubs/api.pyi', 'api/service.proto', 'schema.graphql', 'openapi.yaml', 'index.d.ts', 'package.json',
|
||||
'src/main.rs', 'docs/config-catalog.md', 'tsconfig.json', 'README.i18n.yaml',
|
||||
])).toEqual([
|
||||
'pkg/server_test.go test', 'pkg/testdata/in.txt test', 'app/test_api.py test', 'app/api_test.py test', 'conftest.py test',
|
||||
'spec/models/user_spec.rb test', 'Tests/AppTests/AppTests.swift test', 'App.Tests/UnitTest1.cs test', 'src/a.spec.ts test',
|
||||
'src/__snapshots__/a.snap test', 'config/locales/en.yml test', 'po/zh_CN.po test', 'App/en.lproj/Localizable.strings test',
|
||||
'app/src/main/res/values-zh/strings.xml test', 'Cargo.lock test', 'go.sum test', 'uv.lock test',
|
||||
'go.mod interface', 'Cargo.toml interface', 'pyproject.toml interface', 'lib.gemspec interface', 'build.gradle.kts interface',
|
||||
'App.csproj interface', 'Package.swift interface', 'include/api.h interface', 'stubs/api.pyi interface', 'api/service.proto interface',
|
||||
'schema.graphql interface', 'openapi.yaml interface', 'index.d.ts interface', 'package.json interface',
|
||||
'src/main.rs implementation', 'docs/config-catalog.md implementation', 'tsconfig.json implementation', 'README.i18n.yaml implementation',
|
||||
])
|
||||
})
|
||||
|
||||
it('places every file in the implementation layer without globs or attributes', () => {
|
||||
expect(new FileLayers([], []).classify([file('a.spec.ts')], '')).toMatchObject([{ layer: 'implementation' }])
|
||||
it('checks repository attributes, then configured globs, then the built-in rules', () => {
|
||||
const layers = new FileLayers(['**/fixtures/**'], ['**/cordis.yml', '**/*.spec.ts'])
|
||||
expect(layersOf(layers, [
|
||||
'src/a.spec.ts', 'tests/fixtures/cordis.yml', 'apps/cordis.yml', 'docs/schema.json', 'tests/keep.ts', 'src/api.ts', 'src/gen.ts',
|
||||
], [
|
||||
'docs/schema.json linguist-generated',
|
||||
'tests/keep.ts dsh-review-layer=implementation',
|
||||
'src/api.ts dsh-review-layer=interface',
|
||||
'src/gen.ts linguist-generated dsh-review-layer=implementation',
|
||||
].join('\n'))).toEqual([
|
||||
'src/a.spec.ts interface', 'tests/fixtures/cordis.yml test', 'apps/cordis.yml interface', 'docs/schema.json test',
|
||||
'tests/keep.ts implementation', 'src/api.ts interface', 'src/gen.ts implementation',
|
||||
])
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user