Skip to content

Commit b0d6f69

Browse files
fix: lint fixes
1 parent 59094c0 commit b0d6f69

File tree

9 files changed

+95
-47
lines changed

9 files changed

+95
-47
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ yarn dev
101101
102102
The server will run over HTTP by default. If you place `cert.pem` and
103103
`key.pem` in a `.certs` directory at the project root (see the HTTPS section
104-
below), it will automatically use those files and start with HTTPS. Pretty cool.
104+
below), it will automatically use those files and start with HTTPS. Pretty cool.
105105
106106
## Usage
107107

knip.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
2-
"$schema": "https://unpkg.com/knip@5/schema.json",
3-
"entry": [
4-
"src/**/*.svelte",
5-
"src/**/*.ts",
6-
"!**/*.test.ts",
7-
"!**/*.spec.ts",
8-
"!**/*.d.ts",
9-
"!**/__tests__/**",
10-
"!**/tests/**",
11-
"!**/mocks/**"
12-
],
13-
"project": ["src/**/*.ts", "src/**/*.svelte"],
14-
"ignore": [
15-
"**/{.svelte-kit,node_modules,__tests__,tests,test,mocks,__mocks__}/**",
16-
"**/*.{test,spec,d}.{ts,js}",
17-
"vite.config.ts",
18-
"src/hooks.server.ts",
19-
"pino-pretty",
20-
"src/lib/types.ts"
21-
],
22-
"ignoreDependencies": ["pino-pretty"]
2+
"$schema": "https://unpkg.com/knip@5/schema.json",
3+
"entry": [
4+
"src/**/*.svelte",
5+
"src/**/*.ts",
6+
"!**/*.test.ts",
7+
"!**/*.spec.ts",
8+
"!**/*.d.ts",
9+
"!**/__tests__/**",
10+
"!**/tests/**",
11+
"!**/mocks/**"
12+
],
13+
"project": ["src/**/*.ts", "src/**/*.svelte"],
14+
"ignore": [
15+
"**/{.svelte-kit,node_modules,__tests__,tests,test,mocks,__mocks__}/**",
16+
"**/*.{test,spec,d}.{ts,js}",
17+
"vite.config.ts",
18+
"src/hooks.server.ts",
19+
"pino-pretty",
20+
"src/lib/types.ts"
21+
],
22+
"ignoreDependencies": ["pino-pretty"]
2323
}

src/lib/config.ts

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,61 @@ await db.exec(`CREATE TABLE IF NOT EXISTS settings (
2020
)`)
2121

2222
const defaultSettings: Record<string, { value?: string; description: string }> = {
23-
PARTNER_PHONE: { value: env.PARTNER_PHONE, description: "Your partner's phone number in the Messages app" },
24-
HISTORY_LOOKBACK_HOURS: { value: env.HISTORY_LOOKBACK_HOURS, description: 'How many hours of prior conversation history to search for extra context' },
25-
CUSTOM_CONTEXT: { value: env.CUSTOM_CONTEXT, description: 'To guide the AI\'s personality and behavior (Example: "Act as my therapist suggesting replies to my partner" or "You are a helpful assistant")' },
26-
OPENAI_API_KEY: { value: env.OPENAI_API_KEY, description: 'Available at https://platform.openai.com/api-keys' },
23+
PARTNER_PHONE: {
24+
value: env.PARTNER_PHONE,
25+
description: "Your partner's phone number in the Messages app",
26+
},
27+
HISTORY_LOOKBACK_HOURS: {
28+
value: env.HISTORY_LOOKBACK_HOURS,
29+
description: 'How many hours of prior conversation history to search for extra context',
30+
},
31+
CUSTOM_CONTEXT: {
32+
value: env.CUSTOM_CONTEXT,
33+
description:
34+
'To guide the AI\'s personality and behavior (Example: "Act as my therapist suggesting replies to my partner" or "You are a helpful assistant")',
35+
},
36+
OPENAI_API_KEY: {
37+
value: env.OPENAI_API_KEY,
38+
description: 'Available at https://platform.openai.com/api-keys',
39+
},
2740
OPENAI_MODEL: { value: env.OPENAI_MODEL, description: 'gpt-4 or any other OpenAI model' },
28-
OPENAI_TEMPERATURE: { value: env.OPENAI_TEMPERATURE, description: 'Controls the randomness of the responses' },
29-
OPENAI_TOP_P: { value: env.OPENAI_TOP_P, description: 'Lets the responses be a little more adventurous' },
30-
OPENAI_FREQUENCY_PENALTY: { value: env.OPENAI_FREQUENCY_PENALTY, description: 'Keeps the suggestions from repeating themselves' },
31-
OPENAI_PRESENCE_PENALTY: { value: env.OPENAI_PRESENCE_PENALTY, description: 'Nudges the AI to bring up fresh ideas' },
32-
ANTHROPIC_API_KEY: { value: env.ANTHROPIC_API_KEY, description: 'Available at https://console.anthropic.com/api-keys' },
33-
ANTHROPIC_MODEL: { value: env.ANTHROPIC_MODEL, description: 'claude-3-opus-20240229 or another Anthropic model' },
34-
ANTHROPIC_TEMPERATURE: { value: env.ANTHROPIC_TEMPERATURE, description: "Controls the randomness of Claude's responses" },
35-
GROK_API_KEY: { value: env.GROK_API_KEY, description: 'Available at https://console.grok.ai/api-keys' },
41+
OPENAI_TEMPERATURE: {
42+
value: env.OPENAI_TEMPERATURE,
43+
description: 'Controls the randomness of the responses',
44+
},
45+
OPENAI_TOP_P: {
46+
value: env.OPENAI_TOP_P,
47+
description: 'Lets the responses be a little more adventurous',
48+
},
49+
OPENAI_FREQUENCY_PENALTY: {
50+
value: env.OPENAI_FREQUENCY_PENALTY,
51+
description: 'Keeps the suggestions from repeating themselves',
52+
},
53+
OPENAI_PRESENCE_PENALTY: {
54+
value: env.OPENAI_PRESENCE_PENALTY,
55+
description: 'Nudges the AI to bring up fresh ideas',
56+
},
57+
ANTHROPIC_API_KEY: {
58+
value: env.ANTHROPIC_API_KEY,
59+
description: 'Available at https://console.anthropic.com/api-keys',
60+
},
61+
ANTHROPIC_MODEL: {
62+
value: env.ANTHROPIC_MODEL,
63+
description: 'claude-3-opus-20240229 or another Anthropic model',
64+
},
65+
ANTHROPIC_TEMPERATURE: {
66+
value: env.ANTHROPIC_TEMPERATURE,
67+
description: "Controls the randomness of Claude's responses",
68+
},
69+
GROK_API_KEY: {
70+
value: env.GROK_API_KEY,
71+
description: 'Available at https://console.grok.ai/api-keys',
72+
},
3673
GROK_MODEL: { value: env.GROK_MODEL, description: 'grok-1 or another Grok model' },
37-
GROK_TEMPERATURE: { value: env.GROK_TEMPERATURE, description: 'Controls the randomness of Grok\'s responses' },
74+
GROK_TEMPERATURE: {
75+
value: env.GROK_TEMPERATURE,
76+
description: "Controls the randomness of Grok's responses",
77+
},
3878
KHOJ_API_URL: { value: env.KHOJ_API_URL, description: 'https://khoj.dev' },
3979
KHOJ_AGENT: { value: env.KHOJ_AGENT, description: 'optional specific agent to use' },
4080
}

src/lib/history.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { queryMessagesDb } from './iMessages'
44
import { logger } from './logger'
55
import { formatMessagesAsText } from './utils'
66

7-
87
export const fetchRelevantHistory = async (messages: Message[]): Promise<string> => {
98
try {
109
const lookbackHours = Number.parseInt(settings.HISTORY_LOOKBACK_HOURS || '0')

src/lib/iMessages.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ const CHAT_DB_PATH = path.join(os.homedir(), 'Library', 'Messages', 'chat.db')
1111

1212
const buildQuery = (startDate: string, endDate: string) => {
1313
logger.debug({ startDate, endDate }, 'Getting messages')
14-
const params = [settings.PARTNER_PHONE, isoToAppleNanoseconds(startDate), isoToAppleNanoseconds(endDate)]
14+
const params = [
15+
settings.PARTNER_PHONE,
16+
isoToAppleNanoseconds(startDate),
17+
isoToAppleNanoseconds(endDate),
18+
]
1519

1620
const query = `
1721
SELECT

src/lib/openAi.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ const getConfig = (): OpenAIConfig => ({
1313
model: settings.OPENAI_MODEL || DEFAULT_MODEL,
1414
temperature: Number(settings.OPENAI_TEMPERATURE || DEFAULT_TEMPERATURE),
1515
topP: settings.OPENAI_TOP_P ? Number(settings.OPENAI_TOP_P) : undefined,
16-
frequencyPenalty: settings.OPENAI_FREQUENCY_PENALTY ? Number(settings.OPENAI_FREQUENCY_PENALTY) : undefined,
17-
presencePenalty: settings.OPENAI_PRESENCE_PENALTY ? Number(settings.OPENAI_PRESENCE_PENALTY) : undefined,
16+
frequencyPenalty: settings.OPENAI_FREQUENCY_PENALTY
17+
? Number(settings.OPENAI_FREQUENCY_PENALTY)
18+
: undefined,
19+
presencePenalty: settings.OPENAI_PRESENCE_PENALTY
20+
? Number(settings.OPENAI_PRESENCE_PENALTY)
21+
: undefined,
1822
apiUrl: API_URL,
1923
apiKey: settings.OPENAI_API_KEY,
2024
})

src/lib/providers/registry.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const PROVIDER_REGISTRY: Omit<ProviderConfig, 'isAvailable'>[] = [
4343
// }
4444
]
4545

46-
4746
/**
4847
* Get all available AI providers based on configured settings
4948
*/

src/routes/+page.server.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ export const actions: Actions = {
4747
provider === 'khoj'
4848
? getKhojReply
4949
: provider === 'anthropic'
50-
? getAnthropicReply
51-
: provider === 'grok'
52-
? getGrokReply
53-
: getOpenaiReply
50+
? getAnthropicReply
51+
: provider === 'grok'
52+
? getGrokReply
53+
: getOpenaiReply
5454

5555
let messages: Message[]
5656
try {
@@ -102,12 +102,12 @@ export const actions: Actions = {
102102

103103
return {
104104
success: true,
105-
settings
105+
settings,
106106
}
107107
} catch (error) {
108108
logger.error('Error saving settings:', error)
109109
return fail(500, {
110-
error: 'Failed to save settings. Please try again.'
110+
error: 'Failed to save settings. Please try again.',
111111
})
112112
}
113113
},

tests/lib/prompts.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ describe('prompts', () => {
1111
describe('PERMANENT_CONTEXT', () => {
1212
it('should include custom context and instructions', () => {
1313
expect(systemContext()).toContain('Test custom context for prompts')
14-
expect(systemContext()).toContain('mimic my vocabulary and tone when suggesting replies')
14+
expect(systemContext()).toContain(
15+
'mimic my vocabulary and tone when suggesting replies'
16+
)
1517
})
1618
})
1719

0 commit comments

Comments
 (0)