Skip to content

Commit 4bb266c

Browse files
catomeanclaude
andauthored
chore: add a formatter (#21)
* chore: add a formatter, matching the style this repo already writes singleQuote=true was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (12 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 714b0da commit 4bb266c

17 files changed

Lines changed: 123 additions & 74 deletions

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Bulk reformats. `git config blame.ignoreRevsFile .git-blame-ignore-revs`
2+
6e12c84d059bb4f261a25a27a57c44e58f658bca # prettier, 12 files

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
version: 2
1212
updates:
1313
- package-ecosystem: npm
14-
directory: "/"
14+
directory: '/'
1515
schedule:
1616
interval: weekly
1717
open-pull-requests-limit: 5
@@ -20,7 +20,7 @@ updates:
2020
update-types: [minor, patch]
2121

2222
- package-ecosystem: github-actions
23-
directory: "/"
23+
directory: '/'
2424
schedule:
2525
interval: weekly
2626
open-pull-requests-limit: 3

.prettierignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Build output and vendored trees — formatting these is noise.
2+
node_modules
3+
.next
4+
dist
5+
build
6+
out
7+
coverage
8+
.turbo
9+
.vercel
10+
*.min.js
11+
*.min.css
12+
13+
# Generated during a build, so it is absent locally and present in CI — which
14+
# makes a clean local --check no evidence at all. Contentlayer's output also
15+
# uses import assertions, which prettier's parser rejects outright.
16+
.contentlayer
17+
.astro
18+
.svelte-kit
19+
storybook-static
20+
test-results
21+
playwright-report
22+
23+
# Lockfiles are generated; prettier would rewrite them wholesale.
24+
package-lock.json
25+
pnpm-lock.yaml
26+
yarn.lock
27+
28+
# Markdown is deliberately out of scope for now. Prettier rewraps prose, which
29+
# is where it is most opinionated and least useful, and it would bury the real
30+
# diff. Remove this line when you want docs formatted too.
31+
*.md

.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"printWidth": 100,
5+
"tabWidth": 2,
6+
"trailingComma": "all",
7+
"arrowParens": "always",
8+
"endOfLine": "lf"
9+
}

eslint.config.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// library code, and a bespoke rule set would be a second opinion to maintain
33
// for no benefit. The floor is "lint runs and can fail", not "lint encodes
44
// taste".
5-
import js from '@eslint/js'
6-
import globals from 'globals'
7-
import tseslint from 'typescript-eslint'
5+
import js from '@eslint/js';
6+
import globals from 'globals';
7+
import tseslint from 'typescript-eslint';
88

99
export default tseslint.config(
1010
{
@@ -22,4 +22,4 @@ export default tseslint.config(
2222
files: ['test/**/*.js', 'scripts/**/*.{js,mjs}'],
2323
languageOptions: { globals: { ...globals.node, ...globals.nodeBuiltin } },
2424
},
25-
)
25+
);

package-lock.json

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,17 @@
4444
"lint": "eslint .",
4545
"typecheck": "tsc -p tsconfig.json --noEmit",
4646
"test": "node --test test/*.test.js",
47-
"verify": "npm run lint && npm run typecheck && npm run build && npm test",
48-
"prepare": "npm run build"
47+
"verify": "npm run format:check && npm run lint && npm run typecheck && npm run build && npm test",
48+
"prepare": "npm run build",
49+
"format": "prettier --write .",
50+
"format:check": "prettier --check ."
4951
},
5052
"devDependencies": {
5153
"@eslint/js": "^9.39.5",
5254
"@types/node": "^22.10.2",
5355
"eslint": "^9.39.5",
5456
"globals": "^15.15.0",
57+
"prettier": "3.9.6",
5558
"typescript": "^5.8.2",
5659
"typescript-eslint": "^8.67.0"
5760
}

src/ai.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ export function whenMentioned(aliases: readonly string[]): RespondPolicy {
6767
// addressed to it.
6868
const patterns = aliases
6969
.filter(Boolean)
70-
.map(a => new RegExp(`(^|\\W)${a.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(\\W|$)`, 'i'));
70+
.map((a) => new RegExp(`(^|\\W)${a.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(\\W|$)`, 'i'));
7171
return ({ visible, self }) => {
7272
const last = visible[visible.length - 1];
7373
if (!last || last.authorId === self.actorId) return false;
74-
return patterns.some(re => re.test(last.body));
74+
return patterns.some((re) => re.test(last.body));
7575
};
7676
}
7777

@@ -84,7 +84,7 @@ export function whenMentioned(aliases: readonly string[]): RespondPolicy {
8484
* clinical thread unusable the moment an assistant joined.
8585
*/
8686
export function defaultRespondPolicy(ctx: AiTurnContext): boolean {
87-
const active = ctx.thread.participants.filter(p => !p.leftAt);
87+
const active = ctx.thread.participants.filter((p) => !p.leftAt);
8888
if (active.length <= 2) return afterEveryMessage(ctx);
8989
return whenMentioned([ctx.self.role ?? 'assistant', 'ai'])(ctx);
9090
}
@@ -98,12 +98,9 @@ function trailingSelfMessages(visible: readonly Message[], actorId: string): num
9898
return n;
9999
}
100100

101-
function renderTranscript(
102-
ctx: AiTurnContext,
103-
label: (p: Participant) => string
104-
): string {
101+
function renderTranscript(ctx: AiTurnContext, label: (p: Participant) => string): string {
105102
return ctx.visible
106-
.map(m => {
103+
.map((m) => {
107104
const author = findParticipant(ctx.thread, m.authorId);
108105
const who = author ? label(author) : 'unknown';
109106
return `${who}: ${m.body}`;
@@ -124,7 +121,7 @@ function renderTranscript(
124121
export async function runAiTurn(
125122
thread: Thread,
126123
allMessages: readonly Message[],
127-
config: AiParticipantConfig
124+
config: AiParticipantConfig,
128125
): Promise<AiTurnResult> {
129126
const self = findParticipant(thread, config.actorId);
130127
if (!self) return { status: 'skipped', reason: 'not a participant in this thread' };

src/index.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,5 @@ export { unreadCount, unreadMessages, unreadThreadCount } from './unread.js';
2222

2323
export { compareMessages, isPending, mergeMessages } from './merge.js';
2424

25-
export {
26-
afterEveryMessage,
27-
defaultRespondPolicy,
28-
runAiTurn,
29-
whenMentioned,
30-
} from './ai.js';
31-
export type {
32-
AiParticipantConfig,
33-
AiTurnContext,
34-
AiTurnResult,
35-
RespondPolicy,
36-
} from './ai.js';
25+
export { afterEveryMessage, defaultRespondPolicy, runAiTurn, whenMentioned } from './ai.js';
26+
export type { AiParticipantConfig, AiTurnContext, AiTurnResult, RespondPolicy } from './ai.js';

src/merge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function compareMessages(a: Message, b: Message): number {
2626
*/
2727
export function mergeMessages(
2828
existing: readonly Message[],
29-
incoming: readonly Message[]
29+
incoming: readonly Message[],
3030
): Message[] {
3131
const byId = new Map<string, Message>();
3232
const idByClientId = new Map<string, string>();

0 commit comments

Comments
 (0)