create-message-kit 1.2.26 → 1.2.27

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/index.js CHANGED
@@ -7,7 +7,7 @@ import { default as fs } from "fs-extra";
7
7
  import { isCancel } from "@clack/prompts";
8
8
  import { detect } from "detect-package-manager";
9
9
  import pc from "picocolors";
10
- const defVersion = "1.2.26";
10
+ const defVersion = "1.2.27";
11
11
  const __dirname = dirname(fileURLToPath(import.meta.url));
12
12
 
13
13
  // Read package.json to get the version
@@ -49,6 +49,8 @@ Powered by XMTP`;
49
49
  // Create .gitignore
50
50
  createGitignore(destDir);
51
51
 
52
+ // Create .data directory
53
+ createDataDir(destDir);
52
54
  // Create .env file
53
55
  createEnvFile(destDir);
54
56
 
@@ -77,6 +79,12 @@ Powered by XMTP`;
77
79
 
78
80
  program.parse(process.argv);
79
81
 
82
+ async function createDataDir(destDir) {
83
+ if (!fs.existsSync(resolve(destDir, ".data"))) {
84
+ fs.mkdirSync(resolve(destDir, ".data"));
85
+ }
86
+ }
87
+
80
88
  async function updatePackagejson(destDir, templateType) {
81
89
  // Remove 'templates/' prefix if it exists in templateType
82
90
  const cleanTemplatePath = templateType.replace("templates/", "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-message-kit",
3
- "version": "1.2.26",
3
+ "version": "1.2.27",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
  import { ensUrl } from "../index.js";
9
- import { XMTPContext } from "@xmtp/message-kit";
9
+ import { Context } from "@xmtp/message-kit";
10
10
  import type { Skill } from "@xmtp/message-kit";
11
11
 
12
12
  // Define Skill
@@ -25,7 +25,7 @@ export const checkDomain: Skill[] = [
25
25
  ];
26
26
 
27
27
  // Handler Implementation
28
- export async function handler(context: XMTPContext) {
28
+ export async function handler(context: Context) {
29
29
  const {
30
30
  message: {
31
31
  content: {
@@ -55,7 +55,7 @@ export async function handler(context: XMTPContext) {
55
55
  ### Generate a payment request
56
56
 
57
57
 
58
- import { XMTPContext } from "@xmtp/message-kit";
58
+ import { Context } from "@xmtp/message-kit";
59
59
  import type { Skill } from "@xmtp/message-kit";
60
60
 
61
61
  // Define Skill
@@ -92,7 +92,7 @@ export const paymentRequest: Skill[] = [
92
92
  ];
93
93
 
94
94
  // Handler Implementation
95
- export async function handler(context: XMTPContext) {
95
+ export async function handler(context: Context) {
96
96
  const {
97
97
  message: {
98
98
  content: {
@@ -125,12 +125,12 @@ Each app consists of the following files:
125
125
  agent/
126
126
  ├── src/
127
127
  │ └── index.ts
128
- │ └── prompt.ts
129
- │ └── plugins/
128
+ │ └── prompt.ts # Optional
129
+ │ └── plugins/ # Optional
130
130
  │ └── ...
131
- │ └── skills/
131
+ │ └── skills/ # Optional
132
132
  │ └── ...
133
- │ └── vibes/
133
+ │ └── vibes/ # Optional
134
134
  │ └── ...
135
135
  ├── tsconfig.json
136
136
  ├── package.json
@@ -142,14 +142,14 @@ agent/
142
142
  This is the main function that runs the listener.
143
143
 
144
144
  ```jsx
145
- import { Agent, run, XMTPContext } from "@xmtp/message-kit";
145
+ import { Agent, run, Context } from "@xmtp/message-kit";
146
146
 
147
147
  const agent: Agent = {
148
148
  name: "Agent Name",
149
149
  tag: "@bot",
150
150
  description: "Agent Description",
151
151
  skills: [skill1, skill2],
152
- onMessage: async (context: XMTPContext) => {
152
+ onMessage: async (context: Context) => {
153
153
  /* Logs every message in a conversation.
154
154
  If not declared, the agent will automatically use the defined skills.
155
155
  Alternatively, you can implement your own logic here. */
@@ -1,5 +1,4 @@
1
1
  import { run, Agent } from "@xmtp/message-kit";
2
- import { systemPrompt } from "./prompt.js";
3
2
  import { checkDomain } from "./skills/check.js";
4
3
  import { cool } from "./skills/cool.js";
5
4
  import { info } from "./skills/info.js";
@@ -12,7 +11,6 @@ export const agent: Agent = {
12
11
  tag: "@bot",
13
12
  description: "A ens agent with a lot of skills.",
14
13
  skills: [checkDomain, cool, info, register, renew, pay],
15
- systemPrompt: systemPrompt,
16
14
  };
17
15
 
18
16
  run(agent);
@@ -1,4 +1,4 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
  import type { Skill } from "@xmtp/message-kit";
3
3
 
4
4
  const ensUrl = "https://app.ens.domains/";
@@ -20,7 +20,7 @@ export const checkDomain: Skill[] = [
20
20
  // [!endregion define]
21
21
 
22
22
  // [!region handle]
23
- export async function handler(context: XMTPContext) {
23
+ export async function handler(context: Context) {
24
24
  const {
25
25
  message: {
26
26
  content: {
@@ -1,4 +1,4 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
 
3
3
  import type { Skill } from "@xmtp/message-kit";
4
4
 
@@ -15,7 +15,7 @@ export const cool: Skill[] = [
15
15
  },
16
16
  },
17
17
  ];
18
- export async function handler(context: XMTPContext) {
18
+ export async function handler(context: Context) {
19
19
  const {
20
20
  message: {
21
21
  content: {
@@ -1,4 +1,4 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
 
3
3
  import type { Skill } from "@xmtp/message-kit";
4
4
 
@@ -26,7 +26,7 @@ export const info: Skill[] = [
26
26
  // [!endregion define]
27
27
 
28
28
  // [!region handle]
29
- export async function handler(context: XMTPContext) {
29
+ export async function handler(context: Context) {
30
30
  const {
31
31
  message: {
32
32
  sender,
@@ -1,4 +1,4 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
  import type { Skill } from "@xmtp/message-kit";
3
3
 
4
4
  export const pay: Skill[] = [
@@ -44,7 +44,7 @@ export const pay: Skill[] = [
44
44
  },
45
45
  },
46
46
  ];
47
- export async function handler(context: XMTPContext) {
47
+ export async function handler(context: Context) {
48
48
  const {
49
49
  message: {
50
50
  content: {
@@ -63,10 +63,8 @@ export async function handler(context: XMTPContext) {
63
63
  }
64
64
  if (skill === "tip") {
65
65
  let tipAmount = 1;
66
- await context.send("Sure, here is the tip link: ");
67
66
  await context.requestPayment(receiverAddress, tipAmount);
68
67
  } else if (skill === "pay") {
69
- await context.send("Sure, here is the payment link: ");
70
68
  await context.requestPayment(receiverAddress, amount, token);
71
69
  }
72
70
  }
@@ -1,4 +1,4 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
 
3
3
  const ensUrl = "https://app.ens.domains/";
4
4
  import type { Skill } from "@xmtp/message-kit";
@@ -18,7 +18,7 @@ export const register: Skill[] = [
18
18
  },
19
19
  ];
20
20
 
21
- export async function handler(context: XMTPContext) {
21
+ export async function handler(context: Context) {
22
22
  const {
23
23
  message: {
24
24
  content: {
@@ -1,4 +1,4 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
 
3
3
  import type { Skill } from "@xmtp/message-kit";
4
4
 
@@ -19,7 +19,7 @@ export const renew: Skill[] = [
19
19
  },
20
20
  ];
21
21
 
22
- export async function handler(context: XMTPContext) {
22
+ export async function handler(context: Context) {
23
23
  const {
24
24
  message: {
25
25
  sender,
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
  import { ensUrl } from "../index.js";
9
- import { XMTPContext } from "@xmtp/message-kit";
9
+ import { Context } from "@xmtp/message-kit";
10
10
  import type { Skill } from "@xmtp/message-kit";
11
11
 
12
12
  // Define Skill
@@ -25,7 +25,7 @@ export const checkDomain: Skill[] = [
25
25
  ];
26
26
 
27
27
  // Handler Implementation
28
- export async function handler(context: XMTPContext) {
28
+ export async function handler(context: Context) {
29
29
  const {
30
30
  message: {
31
31
  content: {
@@ -55,7 +55,7 @@ export async function handler(context: XMTPContext) {
55
55
  ### Generate a payment request
56
56
 
57
57
 
58
- import { XMTPContext } from "@xmtp/message-kit";
58
+ import { Context } from "@xmtp/message-kit";
59
59
  import type { Skill } from "@xmtp/message-kit";
60
60
 
61
61
  // Define Skill
@@ -92,7 +92,7 @@ export const paymentRequest: Skill[] = [
92
92
  ];
93
93
 
94
94
  // Handler Implementation
95
- export async function handler(context: XMTPContext) {
95
+ export async function handler(context: Context) {
96
96
  const {
97
97
  message: {
98
98
  content: {
@@ -125,12 +125,12 @@ Each app consists of the following files:
125
125
  agent/
126
126
  ├── src/
127
127
  │ └── index.ts
128
- │ └── prompt.ts
129
- │ └── plugins/
128
+ │ └── prompt.ts # Optional
129
+ │ └── plugins/ # Optional
130
130
  │ └── ...
131
- │ └── skills/
131
+ │ └── skills/ # Optional
132
132
  │ └── ...
133
- │ └── vibes/
133
+ │ └── vibes/ # Optional
134
134
  │ └── ...
135
135
  ├── tsconfig.json
136
136
  ├── package.json
@@ -142,14 +142,14 @@ agent/
142
142
  This is the main function that runs the listener.
143
143
 
144
144
  ```jsx
145
- import { Agent, run, XMTPContext } from "@xmtp/message-kit";
145
+ import { Agent, run, Context } from "@xmtp/message-kit";
146
146
 
147
147
  const agent: Agent = {
148
148
  name: "Agent Name",
149
149
  tag: "@bot",
150
150
  description: "Agent Description",
151
151
  skills: [skill1, skill2],
152
- onMessage: async (context: XMTPContext) => {
152
+ onMessage: async (context: Context) => {
153
153
  /* Logs every message in a conversation.
154
154
  If not declared, the agent will automatically use the defined skills.
155
155
  Alternatively, you can implement your own logic here. */
@@ -1,30 +1,13 @@
1
1
  // [!region index]
2
- import {
3
- run,
4
- agentReply,
5
- parsePrompt,
6
- XMTPContext,
7
- Agent,
8
- } from "@xmtp/message-kit";
9
- import { systemPrompt } from "./prompt.js";
2
+ import { run, agentReply, Context, Agent } from "@xmtp/message-kit";
10
3
 
11
4
  export const agent: Agent = {
12
5
  name: "GPT Bot",
13
- tag: "@bot",
14
6
  description: "Use GPT to generate text responses.",
15
- onMessage: async (context: XMTPContext) => {
16
- const {
17
- message: {
18
- sender,
19
- content: { text },
20
- },
21
- agent,
22
- } = context;
7
+ tag: "@bot",
8
+ onMessage: async (context: Context) => {
23
9
  // [!endregion index]
24
-
25
- let prompt = await parsePrompt(systemPrompt, sender.address, agent);
26
- await agentReply(context, prompt);
27
-
10
+ await agentReply(context);
28
11
  // [!region final]
29
12
  },
30
13
  };
@@ -1,11 +0,0 @@
1
- export const systemPrompt = `
2
- {vibe}
3
-
4
- {rules}
5
-
6
- {user_context}
7
-
8
- {skills}
9
-
10
- {issues}
11
- `;
@@ -1,9 +0,0 @@
1
- export const systemPrompt = `
2
- You are a helpful and playful agent called {agent_name} that lives inside a web3 messaging app called Converse.
3
-
4
- {rules}
5
-
6
- {user_context}
7
-
8
- {issues}
9
- `;