Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
TypeScript
mods: tests name their tier with tier(), and /diff's two answers and the tests on them use an ASCII apostrophe
poteatee5d2e59942d
diff --git a/mods/README.md b/mods/README.mdindex eb2b22a6..bdee1f5c 100644--- a/mods/README.md+++ b/mods/README.md@@ -31,9 +31,9 @@ would be, and nothing is beneath them: a call they leave unanswered throws,naming its event.```ts-import { expect, seat, test } from 'claude-code/testing'+import { expect, test, tier } from 'claude-code/testing'-seat('builtin')+tier('builtin')test('outside a git repository /diff says so and opens nothing', async ($, on) => {const opened: string[] = []@@ -52,7 +52,7 @@ test('outside a git repository /diff says so and opens nothing', async ($, on) =origin: { kind: 'composer' },})- expect(text).toMatch(/isn.t in a git repository/)+ expect(text).toContain("isn't in a git repository")expect(opened).toEqual([])})```diff --git a/mods/diff/hooks/names/texts/git-unanswered-text.ts b/mods/diff/hooks/names/texts/git-unanswered-text.tsindex 79631d77..e167dda0 100644--- a/mods/diff/hooks/names/texts/git-unanswered-text.ts+++ b/mods/diff/hooks/names/texts/git-unanswered-text.ts@@ -5,5 +5,5 @@* cannot start has answered, and gets the not-a-repository text.*/export const GIT_UNANSWERED_TEXT =- 'The diff panel couldn’t read git state — git didn’t answer; run /diff ' ++ "The diff panel couldn't read git state — git didn't answer; run /diff " +'again'diff --git a/mods/diff/hooks/names/texts/not-in-repository-text.ts b/mods/diff/hooks/names/texts/not-in-repository-text.tsindex b9d8bdfe..4d828365 100644--- a/mods/diff/hooks/names/texts/not-in-repository-text.ts+++ b/mods/diff/hooks/names/texts/not-in-repository-text.ts@@ -1,6 +1,7 @@/**- * `/diff`'s answer outside a git repository, worded as the built-in words it.+ * `/diff`'s answer outside a git repository, worded as the built-in words it+ * but for its apostrophe, which is ASCII.*/export const NOT_IN_REPOSITORY_TEXT =- 'The diff panel shows git changes — the current directory isn’t in a ' ++ "The diff panel shows git changes — the current directory isn't in a " +'git repository'diff --git a/mods/diff/tests/boot-probe.test.ts b/mods/diff/tests/boot-probe.test.tsindex 57d63f18..8fbedd94 100644--- a/mods/diff/tests/boot-probe.test.ts+++ b/mods/diff/tests/boot-probe.test.ts@@ -3,9 +3,9 @@ import type {ProcessRunResult,SessionStartInput,} from 'claude-code'-import { clock, expect, seat, test } from 'claude-code/testing'+import { clock, expect, test, tier } from 'claude-code/testing'-seat('builtin')+tier('builtin')const SESSION: SessionStartInput = {surface: 'terminal',@@ -52,7 +52,7 @@ test('/diff at boot joins the boot probe, then asks again', async ($, on) => {await bootingexpect(await ran).toEqual({- text: expect.stringMatching(/isn.t in a git repository/),+ text: expect.stringContaining("isn't in a git repository"),})expect(probes, 'then one more of its own').toHaveLength(2)})diff --git a/mods/diff/tests/command.test.ts b/mods/diff/tests/command.test.tsindex c2b5e1d5..57f79206 100644--- a/mods/diff/tests/command.test.ts+++ b/mods/diff/tests/command.test.ts@@ -3,9 +3,9 @@ import type {ProcessRunResult,SessionStartInput,} from 'claude-code'-import { expect, seat, test } from 'claude-code/testing'+import { expect, test, tier } from 'claude-code/testing'-seat('builtin')+tier('builtin')const SESSION: SessionStartInput = {surface: 'terminal',@@ -37,7 +37,7 @@ test('outside a git repository /diff says so and opens nothing', async ($, on) =await $.session.start(SESSION)const { text } = await $.command.run(DIFF)- expect(text).toMatch(/isn.t in a git repository/)+ expect(text).toContain("isn't in a git repository")expect(opened).toEqual([])})@@ -51,7 +51,7 @@ test('a git that never answers is not "no repository"', async ($, on) => {await $.session.start(SESSION)const { text } = await $.command.run(DIFF)- expect(text).toMatch(/git didn.t answer/)+ expect(text).toContain("git didn't answer")})test('with the built-in holding /diff, the plugin stands down', async ($, on) => {diff --git a/mods/diff/tests/pane.test.ts b/mods/diff/tests/pane.test.tsindex 6f0481c8..168d041b 100644--- a/mods/diff/tests/pane.test.ts+++ b/mods/diff/tests/pane.test.ts@@ -11,12 +11,12 @@ import {clock,expect,memoryStore,- seat,test,textOf,+ tier,} from 'claude-code/testing'-seat('builtin')+tier('builtin')const SESSION: SessionStartInput = {surface: 'terminal',diff --git a/mods/sec-default/tests/sec-default.test.ts b/mods/sec-default/tests/sec-default.test.tsindex d3b6ea4d..0f56c5c3 100644--- a/mods/sec-default/tests/sec-default.test.ts+++ b/mods/sec-default/tests/sec-default.test.ts@@ -7,9 +7,9 @@ import type {ToolInfo,} from 'claude-code'import type { Plugin } from 'claude-code/testing'-import { expect, seat, test } from 'claude-code/testing'+import { expect, test, tier } from 'claude-code/testing'-seat('prepend')+tier('prepend')const SESSION: SessionStartInput = {surface: 'terminal',@@ -116,7 +116,7 @@ const dropping: Plugin = {}/**- * The organization's own plugin, seated last, which signs the section.+ * The organization's own plugin, in its last tier, which signs the section.*/const signing: Plugin = {name: 'signing',diff --git a/mods/telemetry/tests/telemetry.test.ts b/mods/telemetry/tests/telemetry.test.tsindex 0fe9a9fb..958f8799 100644--- a/mods/telemetry/tests/telemetry.test.ts+++ b/mods/telemetry/tests/telemetry.test.ts@@ -6,11 +6,11 @@ import type {SessionAuthorization,} from 'claude-code'import type { Plugin } from 'claude-code/testing'-import { expect, memoryEnv, seat, test } from 'claude-code/testing'+import { expect, memoryEnv, test, tier } from 'claude-code/testing'import type { LogEntry } from '../hooks/telemetry-types'-seat('builtin')+tier('builtin')const BEARER: SessionAuthorization = { handle: 'the-handle', kind: 'bearer' }const ACCEPTED: HttpResponse = { status: 200, ok: true, headers: {}, text: '' }diff --git a/mods/types/claude-code.d.ts b/mods/types/claude-code.d.tsindex 929287fd..9e07ea9e 100644--- a/mods/types/claude-code.d.ts+++ b/mods/types/claude-code.d.ts@@ -19,7 +19,7 @@// Also here: 'claude-code/testing', the kit a plugin's *.test.ts files// import under `claude plugin test <dir>`: `test(name, async ($, on) =>// { ... })`, where `$` is the engine's own and the hooks `on` registers-// sit beneath every plugin; with seat, describe, expect and clock.+// sit beneath every plugin; with tier, describe, expect and clock.//// Typing a plugin against it:// export const register: Register = (on, options) => { ... }@@ -8300,22 +8300,15 @@ declare module 'claude-code/testing' {*/export type TestBody = ($: Engine, on: import('claude-code').On) => unknown- /**- * Where a plugin is seated: the organization's first (`prepend`), the- * person's own (`user`), the organization's last (`append`), or built in- * (`builtin`), in the engine's own chain order.- */- export type Seat = Exclude<import('claude-code').Tier, 'core'>-/*** A plugin a test writes inline, loaded as a plugin folder is: its name,- * where it is seated (`user` when not given), and its hooks module's+ * the tier it loads in (`user` when not given), and its hooks module's* `register`, written `register(on) { ... }`. `register` is* self-contained, as a module's is: it closes over nothing of the test file.*/export type Plugin = {name: string- tier?: Seat+ tier?: Exclude<import('claude-code').Tier, 'core'>register: import('claude-code').Register}@@ -8342,10 +8335,10 @@ declare module 'claude-code/testing' {export function describe(name: string, body: () => void): void/**- * Where the plugin under test is seated, once for the file, at its top- * level: the tier it ships in. Unsaid, it is the person's own (`user`).+ * The tier the plugin under test loads in, once for the file, at its top+ * level: `prepend`, `user` (when unsaid), `append` or `builtin`.*/- export function seat(tier: Seat): void+ export function tier(tier: Exclude<import('claude-code').Tier, 'core'>): void/*** The time `$.clock` reads in a test, which moves only when the test says: