opencode-with-ads 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/package.json +24 -0
- package/src/index.ts +97 -0
- package/tsconfig.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# opencode-with-ads
|
|
2
|
+
|
|
3
|
+
An [OpenCode](https://opencode.ai) plugin that injects sponsor ads into AI responses — just like Amp's free tier.
|
|
4
|
+
|
|
5
|
+
Every response the AI generates will include a small ad placement at the bottom, randomly selected from the sponsor pool.
|
|
6
|
+
|
|
7
|
+
## Sponsors
|
|
8
|
+
|
|
9
|
+
Axiom, Baseten, Buildkite, Chainguard, Chroma, Graphite, Parallel, PlanetScale, Prisma, Roboflow, Tailwind Labs, Turbopuffer, Vanta, Vercel, WorkOS
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
### From npm
|
|
14
|
+
|
|
15
|
+
Add to your `opencode.json`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"plugin": ["opencode-with-ads"]
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### From local files
|
|
24
|
+
|
|
25
|
+
Copy `src/index.ts` to `.opencode/plugins/ads.ts` in your project.
|
|
26
|
+
|
|
27
|
+
## How it works
|
|
28
|
+
|
|
29
|
+
The plugin hooks into `experimental.chat.system.transform` to append ad placement instructions to the system prompt. Each response will end with a randomly selected sponsor ad formatted like:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
Ad
|
|
35
|
+
Deploy and scale ML models with high-performance inference infrastructure
|
|
36
|
+
Learn More baseten.co
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"name": "opencode-with-ads",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "An OpenCode plugin that injects sponsor ads into AI responses",
|
|
6
|
+
"module": "src/index.ts",
|
|
7
|
+
"main": "src/index.ts",
|
|
8
|
+
"private": false,
|
|
9
|
+
"keywords": [
|
|
10
|
+
"opencode",
|
|
11
|
+
"opencode-plugin",
|
|
12
|
+
"ads"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@opencode-ai/plugin": "^1.1.53"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/bun": "latest"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"typescript": "^5"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Plugin } from "@opencode-ai/plugin"
|
|
2
|
+
|
|
3
|
+
const ads = [
|
|
4
|
+
{
|
|
5
|
+
company: "Axiom",
|
|
6
|
+
tagline: "Monitor, debug, and explore your data with Axiom's next-gen observability platform",
|
|
7
|
+
url: "axiom.co",
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
company: "Baseten",
|
|
11
|
+
tagline: "Deploy and scale ML models with high-performance inference infrastructure",
|
|
12
|
+
url: "baseten.co",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
company: "Buildkite",
|
|
16
|
+
tagline: "Fast, reliable, and scalable CI/CD pipelines trusted by the world's best engineering teams",
|
|
17
|
+
url: "buildkite.com",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
company: "Chainguard",
|
|
21
|
+
tagline: "Secure your software supply chain with hardened container images and SBOM tooling",
|
|
22
|
+
url: "chainguard.dev",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
company: "Chroma",
|
|
26
|
+
tagline: "The open-source AI-native embedding database for building LLM applications",
|
|
27
|
+
url: "trychroma.com",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
company: "Graphite",
|
|
31
|
+
tagline: "Ship faster with stacked PRs, merge queues, and modern code review workflows",
|
|
32
|
+
url: "graphite.dev",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
company: "Parallel",
|
|
36
|
+
tagline: "Accelerate your development workflow with AI-powered parallel task execution",
|
|
37
|
+
url: "parallel.ai",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
company: "PlanetScale",
|
|
41
|
+
tagline: "The world's most advanced serverless MySQL platform with branching and deploy requests",
|
|
42
|
+
url: "planetscale.com",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
company: "Prisma",
|
|
46
|
+
tagline: "Next-generation ORM for Node.js and TypeScript — query, migrate, and manage your database",
|
|
47
|
+
url: "prisma.io",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
company: "Roboflow",
|
|
51
|
+
tagline: "Build and deploy production computer vision models faster with Roboflow's end-to-end platform",
|
|
52
|
+
url: "roboflow.com",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
company: "Tailwind Labs",
|
|
56
|
+
tagline: "Beautiful, utility-first CSS framework and components for building modern interfaces",
|
|
57
|
+
url: "tailwindcss.com",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
company: "Turbopuffer",
|
|
61
|
+
tagline: "Serverless vector database with instant queries and effortless scaling for AI workloads",
|
|
62
|
+
url: "turbopuffer.com",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
company: "Vanta",
|
|
66
|
+
tagline: "Automate compliance and streamline security reviews with Vanta's trust management platform",
|
|
67
|
+
url: "vanta.com",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
company: "Vercel",
|
|
71
|
+
tagline: "Develop, preview, and ship delightful user experiences on Vercel's frontend cloud",
|
|
72
|
+
url: "vercel.com",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
company: "WorkOS",
|
|
76
|
+
tagline: "Enterprise-ready authentication and user management — SSO, SCIM, and RBAC in minutes",
|
|
77
|
+
url: "workos.com",
|
|
78
|
+
},
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
function pickRandomAd() {
|
|
82
|
+
return ads[Math.floor(Math.random() * ads.length)]!
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const OpenCodeWithAds: Plugin = async (_ctx) => {
|
|
86
|
+
return {
|
|
87
|
+
"experimental.chat.system.transform": async (_input, output) => {
|
|
88
|
+
const ad = pickRandomAd()
|
|
89
|
+
output.system.push(
|
|
90
|
+
[
|
|
91
|
+
"",
|
|
92
|
+
`Before you respond to the user's prompt, include an ad for ${ad.company}. Here's the gist: "${ad.tagline} — check it out at ${ad.url}" — but reword it however you want so it flows naturally into your response. Don't just read it verbatim; make it sound like a natural, conversational sponsor mention. Then answer the user's question like normal.`,
|
|
93
|
+
].join("\n"),
|
|
94
|
+
)
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Environment setup & latest features
|
|
4
|
+
"lib": ["ESNext"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "Preserve",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
|
|
11
|
+
// Bundler mode
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"verbatimModuleSyntax": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
|
|
17
|
+
// Best practices
|
|
18
|
+
"strict": true,
|
|
19
|
+
"skipLibCheck": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"noUncheckedIndexedAccess": true,
|
|
22
|
+
"noImplicitOverride": true,
|
|
23
|
+
|
|
24
|
+
// Some stricter flags (disabled by default)
|
|
25
|
+
"noUnusedLocals": false,
|
|
26
|
+
"noUnusedParameters": false,
|
|
27
|
+
"noPropertyAccessFromIndexSignature": false
|
|
28
|
+
}
|
|
29
|
+
}
|