Skip to content

Commit 8201162

Browse files
authored
Merge pull request #183 from Opencode-DCP/prettier
chore: add prettier for code formatting
2 parents 7a9b519 + f399b79 commit 8201162

26 files changed

+3269
-3130
lines changed

.github/workflows/pr-checks.yml

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
name: PR Checks
22

33
on:
4-
pull_request:
5-
branches: [master, dev]
4+
pull_request:
5+
branches: [master, dev]
66

77
jobs:
8-
validate:
9-
name: Type Check, Build & Audit
10-
runs-on: ubuntu-latest
11-
12-
steps:
13-
- name: Checkout code
14-
uses: actions/checkout@v4
15-
16-
- name: Setup Node.js
17-
uses: actions/setup-node@v4
18-
with:
19-
node-version: '20'
20-
cache: 'npm'
21-
22-
- name: Install dependencies
23-
run: npm ci
24-
25-
- name: Type check
26-
run: npm run typecheck
27-
28-
- name: Build
29-
run: npm run build
30-
31-
- name: Security audit
32-
run: npm audit --audit-level=high
33-
continue-on-error: false
8+
validate:
9+
name: Type Check, Build & Audit
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: "20"
20+
cache: "npm"
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Format check
26+
run: npm run format:check
27+
28+
- name: Type check
29+
run: npm run typecheck
30+
31+
- name: Build
32+
run: npm run build
33+
34+
- name: Security audit
35+
run: npm audit --audit-level=high
36+
continue-on-error: false

.prettierrc

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

README.md

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Add to your OpenCode config:
1313
```jsonc
1414
// opencode.jsonc
1515
{
16-
"plugin": ["@tarquinen/opencode-dcp@latest"]
16+
"plugin": ["@tarquinen/opencode-dcp@latest"],
1717
}
1818
```
1919

@@ -56,63 +56,63 @@ DCP uses its own config file:
5656

5757
```jsonc
5858
{
59-
// Enable or disable the plugin
60-
"enabled": true,
61-
// Enable debug logging to ~/.config/opencode/logs/dcp/
62-
"debug": false,
63-
// Notification display: "off", "minimal", or "detailed"
64-
"pruneNotification": "detailed",
65-
// Protect from pruning for <turns> message turns
66-
"turnProtection": {
67-
"enabled": false,
68-
"turns": 4
69-
},
70-
// LLM-driven context pruning tools
71-
"tools": {
72-
// Shared settings for all prune tools
73-
"settings": {
74-
// Nudge the LLM to use prune tools (every <nudgeFrequency> tool results)
75-
"nudgeEnabled": true,
76-
"nudgeFrequency": 10,
77-
// Additional tools to protect from pruning
78-
"protectedTools": []
59+
// Enable or disable the plugin
60+
"enabled": true,
61+
// Enable debug logging to ~/.config/opencode/logs/dcp/
62+
"debug": false,
63+
// Notification display: "off", "minimal", or "detailed"
64+
"pruneNotification": "detailed",
65+
// Protect from pruning for <turns> message turns
66+
"turnProtection": {
67+
"enabled": false,
68+
"turns": 4,
7969
},
80-
// Removes tool content from context without preservation (for completed tasks or noise)
81-
"discard": {
82-
"enabled": true
70+
// LLM-driven context pruning tools
71+
"tools": {
72+
// Shared settings for all prune tools
73+
"settings": {
74+
// Nudge the LLM to use prune tools (every <nudgeFrequency> tool results)
75+
"nudgeEnabled": true,
76+
"nudgeFrequency": 10,
77+
// Additional tools to protect from pruning
78+
"protectedTools": [],
79+
},
80+
// Removes tool content from context without preservation (for completed tasks or noise)
81+
"discard": {
82+
"enabled": true,
83+
},
84+
// Distills key findings into preserved knowledge before removing raw content
85+
"extract": {
86+
"enabled": true,
87+
// Show distillation content as an ignored message notification
88+
"showDistillation": false,
89+
},
8390
},
84-
// Distills key findings into preserved knowledge before removing raw content
85-
"extract": {
86-
"enabled": true,
87-
// Show distillation content as an ignored message notification
88-
"showDistillation": false
89-
}
90-
},
91-
// Automatic pruning strategies
92-
"strategies": {
93-
// Remove duplicate tool calls (same tool with same arguments)
94-
"deduplication": {
95-
"enabled": true,
96-
// Additional tools to protect from pruning
97-
"protectedTools": []
91+
// Automatic pruning strategies
92+
"strategies": {
93+
// Remove duplicate tool calls (same tool with same arguments)
94+
"deduplication": {
95+
"enabled": true,
96+
// Additional tools to protect from pruning
97+
"protectedTools": [],
98+
},
99+
// Prune write tool inputs when the file has been subsequently read
100+
"supersedeWrites": {
101+
"enabled": true,
102+
},
103+
// (Legacy) Run an LLM to analyze what tool calls are no longer relevant on idle
104+
"onIdle": {
105+
"enabled": false,
106+
// Additional tools to protect from pruning
107+
"protectedTools": [],
108+
// Override model for analysis (format: "provider/model")
109+
// "model": "anthropic/claude-haiku-4-5",
110+
// Show toast notifications when model selection fails
111+
"showModelErrorToasts": true,
112+
// When true, fallback models are not permitted
113+
"strictModelSelection": false,
114+
},
98115
},
99-
// Prune write tool inputs when the file has been subsequently read
100-
"supersedeWrites": {
101-
"enabled": true
102-
},
103-
// (Legacy) Run an LLM to analyze what tool calls are no longer relevant on idle
104-
"onIdle": {
105-
"enabled": false,
106-
// Additional tools to protect from pruning
107-
"protectedTools": [],
108-
// Override model for analysis (format: "provider/model")
109-
// "model": "anthropic/claude-haiku-4-5",
110-
// Show toast notifications when model selection fails
111-
"showModelErrorToasts": true,
112-
// When true, fallback models are not permitted
113-
"strictModelSelection": false
114-
}
115-
}
116116
}
117117
```
118118

@@ -128,6 +128,7 @@ By default, these tools are always protected from pruning across all strategies:
128128
`task`, `todowrite`, `todoread`, `discard`, `extract`, `batch`
129129

130130
The `protectedTools` arrays in each section add to this default list:
131+
131132
- `tools.settings.protectedTools` — Protects tools from the `discard` and `extract` tools
132133
- `strategies.deduplication.protectedTools` — Protects tools from deduplication
133134
- `strategies.onIdle.protectedTools` — Protects tools from on-idle analysis

index.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const plugin: Plugin = (async (ctx) => {
1414
}
1515

1616
// Suppress AI SDK warnings
17-
if (typeof globalThis !== 'undefined') {
18-
(globalThis as any).AI_SDK_LOG_WARNINGS = false
17+
if (typeof globalThis !== "undefined") {
18+
;(globalThis as any).AI_SDK_LOG_WARNINGS = false
1919
}
2020

2121
const logger = new Logger(config.debug)
@@ -26,7 +26,10 @@ const plugin: Plugin = (async (ctx) => {
2626
})
2727

2828
return {
29-
"experimental.chat.system.transform": async (_input: unknown, output: { system: string[] }) => {
29+
"experimental.chat.system.transform": async (
30+
_input: unknown,
31+
output: { system: string[] },
32+
) => {
3033
const discardEnabled = config.tools.discard.enabled
3134
const extractEnabled = config.tools.extract.enabled
3235

@@ -48,7 +51,7 @@ const plugin: Plugin = (async (ctx) => {
4851
ctx.client,
4952
state,
5053
logger,
51-
config
54+
config,
5255
),
5356
tool: {
5457
...(config.tools.discard.enabled && {
@@ -57,7 +60,7 @@ const plugin: Plugin = (async (ctx) => {
5760
state,
5861
logger,
5962
config,
60-
workingDirectory: ctx.directory
63+
workingDirectory: ctx.directory,
6164
}),
6265
}),
6366
...(config.tools.extract.enabled && {
@@ -66,7 +69,7 @@ const plugin: Plugin = (async (ctx) => {
6669
state,
6770
logger,
6871
config,
69-
workingDirectory: ctx.directory
72+
workingDirectory: ctx.directory,
7073
}),
7174
}),
7275
},
@@ -83,7 +86,9 @@ const plugin: Plugin = (async (ctx) => {
8386
...opencodeConfig.experimental,
8487
primary_tools: [...existingPrimaryTools, ...toolsToAdd],
8588
}
86-
logger.info(`Added ${toolsToAdd.map(t => `'${t}'`).join(" and ")} to experimental.primary_tools via config mutation`)
89+
logger.info(
90+
`Added ${toolsToAdd.map((t) => `'${t}'`).join(" and ")} to experimental.primary_tools via config mutation`,
91+
)
8792
}
8893
},
8994
event: createEventHandler(ctx.client, config, state, logger, ctx.directory),

0 commit comments

Comments
 (0)