create-message-kit 1.1.7-beta.13 → 1.1.7-beta.15

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
@@ -32,9 +32,7 @@ Powered by XMTP`;
32
32
 
33
33
  const { templateType, displayName, destDir } = await gatherProjectInfo();
34
34
 
35
- // Replace dot files
36
- //replaceDotfiles(destDir);
37
-
35
+ addPackagejson(destDir, displayName);
38
36
  // Create .gitignore
39
37
  createGitignore(destDir);
40
38
 
@@ -62,7 +60,15 @@ Powered by XMTP`;
62
60
  });
63
61
 
64
62
  program.parse(process.argv);
65
-
63
+ async function addPackagejson(destDir, name) {
64
+ fs.copySync(
65
+ resolve(__dirname, "templates/package.template.json"),
66
+ resolve(destDir, "package.json"),
67
+ {
68
+ name: name,
69
+ },
70
+ );
71
+ }
66
72
  async function gatherProjectInfo() {
67
73
  const templateOptions = [
68
74
  { value: "gm", label: "GM" },
@@ -151,15 +157,6 @@ function createTsconfig(destDir) {
151
157
  spaces: 2,
152
158
  });
153
159
  }
154
- function replaceDotfiles(destDir) {
155
- for (const file of fs.readdirSync(destDir)) {
156
- if (!file.startsWith("_")) continue;
157
- fs.renameSync(
158
- resolve(destDir, file),
159
- resolve(destDir, `.${file.slice(1)}`),
160
- );
161
- }
162
- }
163
160
 
164
161
  function updatePackageJson(destDir, name) {
165
162
  const pkgJson = fs.readJsonSync(resolve(destDir, "package.json"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-message-kit",
3
- "version": "1.1.7-beta.13",
3
+ "version": "1.1.7-beta.15",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -16,6 +16,7 @@ export async function handleEns(
16
16
  content: { command, params },
17
17
  },
18
18
  } = context;
19
+ console.log(command, params);
19
20
  if (command == "reset") {
20
21
  clearMemory();
21
22
  return { code: 200, message: "Conversation reset." };
@@ -1,57 +1,51 @@
1
1
  import { skills } from "./skills.js";
2
2
  import {
3
- getUserInfo,
4
3
  UserInfo,
5
4
  PROMPT_USER_CONTENT,
6
5
  PROMPT_RULES,
7
6
  PROMPT_SKILLS_AND_EXAMPLES,
7
+ PROMPT_REPLACE_VARIABLES,
8
8
  } from "@xmtp/message-kit";
9
9
 
10
10
  export async function agent_prompt(userInfo: UserInfo) {
11
- let { address, ensDomain, converseUsername, preferredName } = userInfo;
12
-
13
- //Update the name of the agent with predefined prompt
14
- let systemPrompt = PROMPT_RULES.replace("{NAME}", skills?.[0]?.tag ?? "@ens");
15
-
16
- //Add user context to the prompt
17
- systemPrompt += PROMPT_USER_CONTENT(userInfo);
18
-
19
- //Add skills and examples to the prompt
20
- systemPrompt += PROMPT_SKILLS_AND_EXAMPLES(skills, "@ens");
11
+ let systemPrompt =
12
+ PROMPT_RULES +
13
+ PROMPT_USER_CONTENT(userInfo) +
14
+ PROMPT_SKILLS_AND_EXAMPLES(skills, "@ens");
21
15
 
22
16
  systemPrompt += `
23
17
 
24
18
  ## Example responses:
25
19
 
26
20
  1. Check if the user does not have a ENS domain
27
- Hey ${preferredName}! it looks like you don't have a ENS domain yet! \n\Let me start by checking your Converse username with the .eth suffix\n/check ${converseUsername}.eth
21
+ Hey {PREFERRED_NAME}! it looks like you don't have a ENS domain yet! \n\Let me start by checking your Converse username with the .eth suffix\n/check {CONVERSE_USERNAME}.eth
28
22
 
29
23
  2. If the user has a ENS domain
30
- Hello ${preferredName} ! I'll help you get your ENS domain.\n Let's start by checking your ENS domain ${ensDomain}. Give me a moment.\n/check ${ensDomain}
24
+ Hello {PREFERRED_NAME} ! I'll help you get your ENS domain.\n Let's start by checking your ENS domain {ENS_DOMAIN}. Give me a moment.\n/check {ENS_DOMAIN}
31
25
 
32
26
  3. Check if the ENS domain is available
33
- Hello! I'll help you get your domain.\n Let's start by checking your ENS domain ${ensDomain}. Give me a moment.\n/check ${ensDomain}
27
+ Hello! I'll help you get your domain.\n Let's start by checking your ENS domain {ENS_DOMAIN}. Give me a moment.\n/check {ENS_DOMAIN}
34
28
 
35
29
  4. If the ENS domain is available,
36
- Looks like ${ensDomain} is available! Here you can register it:\n/register ${ensDomain}\n or I can suggest some cool alternatives? Le me know!
30
+ Looks like {ENS_DOMAIN} is available! Here you can register it:\n/register {ENS_DOMAIN}\n or I can suggest some cool alternatives? Le me know!
37
31
 
38
32
  5. If the ENS domain is already registered, let me suggest 5 cool alternatives
39
- Looks like ${ensDomain} is already registered!\n What about these cool alternatives?\n/cool ${ensDomain}
33
+ Looks like {ENS_DOMAIN} is already registered!\n What about these cool alternatives?\n/cool {ENS_DOMAIN}
40
34
 
41
35
  6. If the user wants to register a ENS domain, use the command "/register [domain]"
42
- Looks like ${ensDomain} is available! Let me help you register it\n/register ${ensDomain}
36
+ Looks like {ENS_DOMAIN} is available! Let me help you register it\n/register {ENS_DOMAIN}
43
37
 
44
38
  7. If the user wants to directly to tip to the ENS domain owner, use directly the command "/tip [domain]", this will return a url but a button to send the tip
45
- Here is the url to send the tip:\n/tip ${ensDomain}
39
+ Here is the url to send the tip:\n/tip {ENS_DOMAIN}
46
40
 
47
41
  8. If the user wants to get information about the ENS domain, use the command "/info [domain]"
48
- Hello! I'll help you get info about ${ensDomain}.\n Give me a moment.\n/info ${ensDomain}
42
+ Hello! I'll help you get info about {ENS_DOMAIN}.\n Give me a moment.\n/info {ENS_DOMAIN}
49
43
 
50
44
  9. If the user wants to renew their domain, use the command "/renew [domain]"
51
- Hello! I'll help you get your ENS domain.\n Let's start by checking your ENS domain ${ensDomain}. Give me a moment.\n/renew ${ensDomain}
45
+ Hello! I'll help you get your ENS domain.\n Let's start by checking your ENS domain {ENS_DOMAIN}. Give me a moment.\n/renew {ENS_DOMAIN}
52
46
 
53
47
  10. If the user wants cool suggestions about a domain, use the command "/cool [domain]"
54
- Here are some cool suggestions for your domain.\n/cool ${ensDomain}
48
+ Here are some cool suggestions for your domain.\n/cool {ENS_DOMAIN}
55
49
 
56
50
  ## Most common bugs
57
51
 
@@ -59,5 +53,12 @@ export async function agent_prompt(userInfo: UserInfo) {
59
53
  But you forgot to add the command at the end of the message.
60
54
  You should have said something like: "Looks like vitalik.eth is registered! What about these cool alternatives?\n/cool vitalik.eth
61
55
  `;
56
+ systemPrompt = PROMPT_REPLACE_VARIABLES(
57
+ systemPrompt,
58
+ userInfo?.address ?? "",
59
+ userInfo,
60
+ "@ens",
61
+ );
62
+ console.log(systemPrompt);
62
63
  return systemPrompt;
63
64
  }
@@ -22,7 +22,6 @@ export const skills: SkillGroup[] = [
22
22
  },
23
23
  {
24
24
  command: "/exists",
25
- adminOnly: true,
26
25
  examples: ["/exists"],
27
26
  handler: handleEns,
28
27
  triggers: ["/exists"],
@@ -1,3 +1,2 @@
1
1
  KEY= # the private key of the bot wallet
2
- OPEN_AI_API_KEY= # openai api key
3
- STACK_API_KEY= # stack api key
2
+ OPEN_AI_API_KEY= # openai api key
@@ -6,6 +6,7 @@ export async function handler(context: HandlerContext) {
6
6
  message: {
7
7
  content: { command },
8
8
  },
9
+ group,
9
10
  } = context;
10
11
 
11
12
  if (command == "help") {
@@ -18,6 +19,7 @@ export async function handler(context: HandlerContext) {
18
19
  "\nUse these skills to interact with specific apps.";
19
20
  context.send(intro);
20
21
  } else if (command == "id") {
21
- context.send(context.group?.id);
22
+ console.log(group?.id);
23
+ context.send(group?.id);
22
24
  }
23
25
  }
@@ -6,7 +6,7 @@ run(async (context: HandlerContext) => {
6
6
 
7
7
  if (!group) {
8
8
  context.send(
9
- "This This bot only works in group chats. Please add this bot to a group to continue",
9
+ "This bot only works in group chats. Please add this bot to a group to continue",
10
10
  );
11
11
  }
12
12
  });
@@ -2,13 +2,13 @@ import { handler as tipping } from "./handler/tipping.js";
2
2
  import { handler as agent } from "./handler/agent.js";
3
3
  import { handler as transaction } from "./handler/transaction.js";
4
4
  import { handler as games } from "./handler/game.js";
5
- import { handler as loyalty } from "./handler/loyalty.js";
6
5
  import { handler as groupHelp } from "./handler/helpers.js";
7
6
  import type { SkillGroup } from "@xmtp/message-kit";
8
7
 
9
8
  export const skills: SkillGroup[] = [
10
9
  {
11
10
  name: "Tipping",
11
+ tag: "@bot",
12
12
  description: "Tip tokens via emoji, replies or command.",
13
13
  skills: [
14
14
  {
@@ -111,28 +111,6 @@ export const skills: SkillGroup[] = [
111
111
  },
112
112
  ],
113
113
  },
114
- {
115
- name: "Loyalty",
116
- description: "Manage group members and metadata.",
117
- skills: [
118
- {
119
- command: "/points",
120
- triggers: ["/points"],
121
- examples: ["/points"],
122
- handler: loyalty,
123
- description: "Check your points.",
124
- params: {},
125
- },
126
- {
127
- command: "/leaderboard",
128
- triggers: ["/leaderboard"],
129
- adminOnly: true,
130
- handler: loyalty,
131
- description: "Check the points of a user.",
132
- params: {},
133
- },
134
- ],
135
- },
136
114
  {
137
115
  name: "Agent",
138
116
  description: "Manage agent commands.",
@@ -1,16 +0,0 @@
1
- {
2
- "name": "agent",
3
- "private": true,
4
- "type": "module",
5
- "scripts": {
6
- "build": "tsc",
7
- "dev": "tsc -w & sleep 1 && nodemon --quiet dist/index.js",
8
- "start": "node dist/index.js"
9
- },
10
- "dependencies": {
11
- "@xmtp/message-kit": "workspace:*"
12
- },
13
- "engines": {
14
- "node": ">=20"
15
- }
16
- }
@@ -1,16 +0,0 @@
1
- {
2
- "name": "gm",
3
- "private": true,
4
- "type": "module",
5
- "scripts": {
6
- "build": "tsc",
7
- "dev": "tsc -w & sleep 1 && nodemon --quiet dist/index.js",
8
- "start": "node dist/index.js"
9
- },
10
- "dependencies": {
11
- "@xmtp/message-kit": "workspace:*"
12
- },
13
- "engines": {
14
- "node": ">=20"
15
- }
16
- }
@@ -1,20 +0,0 @@
1
- {
2
- "name": "group",
3
- "private": true,
4
- "type": "module",
5
- "scripts": {
6
- "build": "tsc",
7
- "dev": "tsc -w & sleep 1 && nodemon --quiet dist/index.js",
8
- "start": "node dist/index.js"
9
- },
10
- "dependencies": {
11
- "@stackso/js-core": "^0.3.1",
12
- "@xmtp/message-kit": "workspace:*"
13
- },
14
- "devDependencies": {
15
- "nodemon": "^3.1.3"
16
- },
17
- "engines": {
18
- "node": ">=20"
19
- }
20
- }
@@ -1,49 +0,0 @@
1
- import { HandlerContext, AbstractedMember } from "@xmtp/message-kit";
2
- import { getStackClient } from "../lib/stack.js";
3
-
4
- export async function handler(context: HandlerContext, fake?: boolean) {
5
- const stack = getStackClient();
6
- const {
7
- members,
8
- group,
9
- message: {
10
- sender,
11
- typeId,
12
- content: { command, params, text },
13
- },
14
- } = context;
15
- if (typeId === "text" && group) {
16
- if (command === "points") {
17
- const points = await stack?.getPoints(sender.address);
18
- context.reply(`You have ${points} points`);
19
- return;
20
- } else if (command === "leaderboard") {
21
- const leaderboard = await stack?.getLeaderboard();
22
- const formattedLeaderboard = leaderboard?.leaderboard
23
- .map(
24
- (entry, index) =>
25
- `${index + 1}. Address: ${`${entry.address.slice(
26
- 0,
27
- 6,
28
- )}...${entry.address.slice(-4)}`}, Points: ${entry.points}`,
29
- )
30
- .join("\n");
31
- context.reply(
32
- `Leaderboard:\n\n${formattedLeaderboard}\n\nCheck out the public leaderboard\nhttps://www.stack.so/leaderboard/degen-group`,
33
- );
34
- return;
35
- }
36
- } else if (typeId === "group_updated" && group) {
37
- const { initiatedByInboxId, addedInboxes } = params;
38
- const adminAddress = members?.find(
39
- (member: AbstractedMember) => member.inboxId === initiatedByInboxId,
40
- );
41
- if (addedInboxes && addedInboxes.length > 0) {
42
- //if add someone to the group
43
- await stack?.track("referral", {
44
- points: 10,
45
- account: adminAddress?.address ?? "",
46
- });
47
- }
48
- }
49
- }
@@ -1,18 +0,0 @@
1
- import { StackClient } from "@stackso/js-core";
2
-
3
- let stack: StackClient | null = null;
4
-
5
- export function getStackClient(): StackClient | null {
6
- if (!process?.env?.STACK_API_KEY) {
7
- console.log("No STACK_API_KEY found in .env");
8
- return null;
9
- }
10
- if (!stack) {
11
- stack = new StackClient({
12
- apiKey: process.env.STACK_API_KEY as string,
13
- pointSystemId: 2893,
14
- });
15
- }
16
- return stack;
17
- }
18
- export type { StackClient };