Skip to content

Commit

Permalink
🔧 chore(workflow): Add agent/plugin readme list sync workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Nov 3, 2023
1 parent 438b7d0 commit 81b3b2a
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 27 deletions.
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ By establishing a versatile plugin system, ChatGPT becomes capable of delivering

In our agent market. We have accumulated a large number of practical, prompt agents that have been used in daily work and study. You can also share your agents here and iterate and optimize your prompt agents with more people. You can submit your agents through [🤖/🏪 Submit Agents][submit-agents-link], and our automated i18n workflow will automatically translate your agents into multiple languages, allowing users worldwide to enjoy your wisdom.

<!-- AGENT LIST -->

| Recent Submits | Description |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| [Sketch Feature Summary Expert](https://chat-preview.lobehub.com/market?agent=sketch-changelog-highlighter)<br/><sup>By **[arvinxx](https://github.com/arvinxx)** on **2023-11-02**</sup> | Skilled at extracting key changes from Sketch release notes<br/>`Experience Design` `sketch` `update` `feature` `text summary` |
| [Master of Debating](https://chat-preview.lobehub.com/market?agent=tqg-20231026)<br/><sup>By **[cake79](https://github.com/cake79)** on **2023-10-26**</sup> | Simulates people who enjoy debating and can express counterarguments to any user input<br/>`Writing` `Dialogue` |
| [Graph Generator](https://chat-preview.lobehub.com/market?agent=graph-generator)<br/><sup>By **[choldrim](https://github.com/choldrim)** on **2023-10-23**</sup> | Automatic Graph Generator<br/>`graph` |
| [Master of Naming](https://chat-preview.lobehub.com/market?agent=meaningful-name)<br/><sup>By **[yingxirz](https://github.com/yingxirz)** on **2023-10-18**</sup> | Provides concise and meaningful names for your artistic creations.<br/>`naming` `creative` |

> 📊 Total agents: [<kbd>**37**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
<!-- AGENT LIST -->

<br/>

![](https://gw.alipayobjects.com/zos/kitchen/69x6bllkX3/pwa.webp)
Expand Down Expand Up @@ -282,11 +295,18 @@ Plugins provide a means to extend the [Function Calling][fc-link] capabilities o
> - [x] [**Plugin Phase 2**](https://github.com/lobehub/lobe-chat/issues/97): The security and stability of the plugin's use, more accurately presenting abnormal states, the maintainability of the plugin architecture, and developer-friendly.
> - [ ] [**Plugin Phase 3**](https://github.com/lobehub/lobe-chat/issues/149): Higher-level and more comprehensive customization capabilities, support for plugin authentication, and examples.
| Official Plugin | Description |
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| [SearchEngine][chat-plugin-search-engine] | This plugin allows for the use of the SerpApi search engine. |
| [RealtimeWeather][chat-plugin-realtime-weather] | This plugin provides practical weather information by obtaining real-time weather data and can automatically update based on the user's location. |
| [WebsiteCrawler][chat-plugin-web-crawler] | This plugin automatically crawls the main content of a specified URL webpage and uses it as context input. |
<!-- PLUGIN LIST -->

| Official Plugin | Description |
| --------------------------------------------------------------------------- | -------------------------------------- |
| [Clock Time](https://github.com/lobehub/chat-plugin-clock-time) | display a clock to show current time |
| [Website Crawler](https://github.com/lobehub/chat-plugin-web-crawler) | Extract content from web links |
| [Search Engine](https://github.com/lobehub/chat-plugin-search-engine) | Query search engine to get information |
| [Realtime Weather](https://github.com/lobehub/chat-plugin-realtime-weather) | Get realtime weather information |

> 📊 Total plugins: [<kbd>**4**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
<!-- PLUGIN LIST -->

<div align="right">

Expand Down Expand Up @@ -365,11 +385,8 @@ This project is [MIT](./LICENSE) licensed.
[chat-desktop-report]: https://lobehub.github.io/lobe-chat/lighthouse/chat/desktop/chat_preview_lobehub_com_chat.html
[chat-mobile]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/mobile/pagespeed.svg
[chat-mobile-report]: https://lobehub.github.io/lobe-chat/lighthouse/chat/mobile/chat_preview_lobehub_com_chat.html
[chat-plugin-realtime-weather]: https://github.com/lobehub/chat-plugin-realtime-weather
[chat-plugin-sdk]: https://github.com/lobehub/chat-plugin-sdk
[chat-plugin-search-engine]: https://github.com/lobehub/chat-plugin-search-engine
[chat-plugin-template]: https://github.com/lobehub/chat-plugin-template
[chat-plugin-web-crawler]: https://github.com/lobehub/chat-plugin-web-crawler
[chat-plugins-gateway]: https://github.com/lobehub/chat-plugins-gateway
[codespaces-link]: https://codespaces.new/lobehub/lobe-chat
[codespaces-shield]: https://github.com/codespaces/badge.svg
Expand Down
33 changes: 25 additions & 8 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ LobeChat 是一个开源的、可扩展的([Function Calling][fc-link])高

在我们的助手市场中,我们积累了大量实用的助手 Prompt,这些都是在日常工作和学习中得到实际应用的。你也可以在这里分享你的助手,与更多的人一起迭代和优化你的助手提示词。你可以通过 [🤖/🏪 提交助手][submit-agents-link] 来提交你的助手,我们构建的自动化 i18n 工作流将会自动将你的助手翻译成多语言版本,让多语种用户都能享受到你的智慧成果。

<!-- AGENT LIST -->

| 最近新增 | 助手说明 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| [Sketch 特性总结专家](https://chat-preview.lobehub.com/market?agent=sketch-changelog-highlighter)<br/><sup>By **[arvinxx](https://github.com/arvinxx)** on **2023-11-02**</sup> | 擅长从 Sketch 的更新日志中提取关键变更要点<br/>`体验设计` `sketch` `更新` `特性` `文本总结` |
| [抬杠高手](https://chat-preview.lobehub.com/market?agent=tqg-20231026)<br/><sup>By **[cake79](https://github.com/cake79)** on **2023-10-26**</sup> | 模拟那些喜欢抬杠的人,能对用户输入的任何观点进行抬杠表达的角色<br/>`写作` `对话` |
| [图表生成器](https://chat-preview.lobehub.com/market?agent=graph-generator)<br/><sup>By **[choldrim](https://github.com/choldrim)** on **2023-10-23**</sup> | 自动图表生成器<br/>`图表` |
| [作品命名大师](https://chat-preview.lobehub.com/market?agent=meaningful-name)<br/><sup>By **[yingxirz](https://github.com/yingxirz)** on **2023-10-18**</sup> | 为您的艺术创作提供简洁而富有内涵的名称。<br/>`起名` `创意` |

> 📊 Total agents: [<kbd>**37**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
<!-- AGENT LIST -->

<br/>

![](https://gw.alipayobjects.com/zos/kitchen/69x6bllkX3/pwa.webp)
Expand Down Expand Up @@ -286,11 +299,18 @@ $ docker run -d -p 3210:3210 \
> - [x] [**插件二期**](https://github.com/lobehub/lobe-chat/issues/97): 插件的安全性与使用的稳定性,更加精准地呈现异常状态,插件架构的可维护性与开发者友好
> - [ ] [**插件三期**](https://github.com/lobehub/lobe-chat/issues/149):更高阶与完善的自定义能力,支持插件鉴权与示例
| 官方插件 | 描述 |
| ---------------------------------------- | ---------------------------------------------------------------------------- |
| [搜索引擎][chat-plugin-search-engine] | 此插件允许使用 SerpApi 搜索引擎。 |
| [实时天气][chat-plugin-realtime-weather] | 此插件通过获取实时天气数据提供实用的天气信息,并可以根据用户的位置自动更新。 |
| [网站爬虫][chat-plugin-web-crawler] | 此插件自动爬取指定 URL 网页的主要内容,并将其用作上下文输入。 |
<!-- PLUGIN LIST -->

| 官方插件 | 插件说明 |
| ------------------------------------------------------------------- | -------------------------- |
| [时钟时间](https://github.com/lobehub/chat-plugin-clock-time) | 显示一个时钟来展示当前时间 |
| [网站爬虫](https://github.com/lobehub/chat-plugin-web-crawler) | 从网页链接中提取内容 |
| [搜索引擎](https://github.com/lobehub/chat-plugin-search-engine) | 查询搜索引擎以获取信息 |
| [实时天气](https://github.com/lobehub/chat-plugin-realtime-weather) | 获取实时天气信息 |

> 📊 Total plugins: [<kbd>**4**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
<!-- PLUGIN LIST -->

<div align="right">

Expand Down Expand Up @@ -369,11 +389,8 @@ This project is [MIT](./LICENSE) licensed.
[chat-desktop-report]: https://lobehub.github.io/lobe-chat/lighthouse/chat/desktop/chat_preview_lobehub_com_chat.html
[chat-mobile]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/mobile/pagespeed.svg
[chat-mobile-report]: https://lobehub.github.io/lobe-chat/lighthouse/chat/mobile/chat_preview_lobehub_com_chat.html
[chat-plugin-realtime-weather]: https://github.com/lobehub/chat-plugin-realtime-weather
[chat-plugin-sdk]: https://github.com/lobehub/chat-plugin-sdk
[chat-plugin-search-engine]: https://github.com/lobehub/chat-plugin-search-engine
[chat-plugin-template]: https://github.com/lobehub/chat-plugin-template
[chat-plugin-web-crawler]: https://github.com/lobehub/chat-plugin-web-crawler
[chat-plugins-gateway]: https://github.com/lobehub/chat-plugins-gateway
[codespaces-link]: https://codespaces.new/lobehub/lobe-chat
[codespaces-shield]: https://github.com/codespaces/badge.svg
Expand Down
10 changes: 9 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ const nextConfig = {
experimental: {
webVitalsAttribution: ['CLS', 'LCP'],
forceSwcTransforms: true,
optimizePackageImports: ['modern-screenshot','emoji-mart','@emoji-mart/react','@emoji-mart/data','@icons-pack/react-simple-icons','gpt-tokenizer','chroma-js'],
optimizePackageImports: [
'modern-screenshot',
'emoji-mart',
'@emoji-mart/react',
'@emoji-mart/data',
'@icons-pack/react-simple-icons',
'gpt-tokenizer',
'chroma-js',
],
},
transpilePackages: ['@lobehub/ui', 'antd-style', 'lodash-es'],

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"build:docker": "DOCKER=true next build",
"dev": "next dev -p 3010",
"i18n": "npm run i18n:workflow && lobe-i18n",
"i18n:workflow": "ts-node --project ./tsconfig.json scripts/i18nWorkflow/index.ts",
"lint": "npm run lint:ts && npm run lint:style && npm run type-check && npm run lint:circular",
"lint:circular": "dpdm src/**/*.ts --warning false --tree false --exit-code circular:1 -T true",
"lint:md": "remark . --quiet --frail --output",
Expand All @@ -43,7 +42,9 @@
"test": "vitest --passWithNoTests",
"test:coverage": "vitest run --coverage --passWithNoTests",
"test:update": "vitest -u",
"type-check": "tsc --noEmit"
"type-check": "tsc --noEmit",
"workflow:i18n": "ts-node --project ./tsconfig.json scripts/i18nWorkflow/index.ts",
"workflow:readme": "bun scripts/readmeWorkflow/index.ts"
},
"lint-staged": {
"*.md": [
Expand Down Expand Up @@ -149,6 +150,7 @@
"jsdom": "^22",
"lint-staged": "^15",
"lodash": "^4",
"markdown-table": "^3",
"next-pwa": "^5",
"node-fetch": "^3",
"prettier": "^3",
Expand Down
18 changes: 18 additions & 0 deletions scripts/readmeWorkflow/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export interface DataItem {
author: string;
createAt: string;
homepage: string;
identifier: string;
meta: { avatar: string; description: string; tags: string[]; title: string };
}

export const MARKET_URL = 'https://chat-preview.lobehub.com/market';
export const AGENT_EN_URL = 'https://chat-agents.lobehub.com/index.json';
export const AGENT_CN_URL = 'https://chat-agents.lobehub.com/index.zh-CN.json';
export const AGENT_REPO = 'https://github.com/lobehub/lobe-chat-agents';
export const PLUGIN_EN_URL = 'https://chat-plugins.lobehub.com/index.json';
export const PLUGIN_CN_URL = 'https://chat-plugins.lobehub.com/index.zh-CN.json';
export const PLUGIN_REPO = 'https://github.com/lobehub/lobe-chat-plugins';

export const AGENT_SPLIT = '<!-- AGENT LIST -->';
export const PLUGIN_SPLIT = '<!-- PLUGIN LIST -->';
12 changes: 12 additions & 0 deletions scripts/readmeWorkflow/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { consola } from 'consola';

import syncAgentIndex from './syncAgentIndex';
import syncPluginIndex from './syncPluginIndex';

const runSync = async () => {
consola.start('Start sync readme workflow...');
await syncAgentIndex();
await syncPluginIndex();
};

runSync();
53 changes: 53 additions & 0 deletions scripts/readmeWorkflow/syncAgentIndex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { consola } from 'consola';
import { markdownTable } from 'markdown-table';
import qs from 'query-string';

import { AGENT_REPO, AGENT_SPLIT, DataItem, MARKET_URL } from './const';
import { fetchAgentIndex, genLink, readReadme, updateReadme, writeReadme } from './utlis';

const genAgentTable = (data: DataItem[], lang: string) => {
const isCN = lang === 'zh-CN';
const content = data.slice(0, 4).map((item) => [
[
genLink(
item.meta.title,
qs.stringifyUrl({
query: { agent: item.identifier },
url: MARKET_URL,
}),
),
`<sup>By **${genLink(item.author, item.homepage)}** on **${item.createAt}**</sup>`,
].join('<br/>'),
[
item.meta.description,
item.meta.tags
.filter(Boolean)
.map((tag) => `\`${tag}\``)
.join(' '),
].join('<br/>'),
]);
return markdownTable([
[isCN ? '最近新增' : 'Recent Submits', isCN ? '助手说明' : 'Description'],
...content,
]);
};

const runAgentTable = async (lang: string) => {
const data = await fetchAgentIndex(lang);
const md = readReadme(lang);
const mdTable = genAgentTable(data, lang);
const newMd = updateReadme(
AGENT_SPLIT,
md,
[mdTable, `> 📊 Total agents: ${genLink(`<kbd>**${data.length}**</kbd> `, AGENT_REPO)}`].join(
'\n\n',
),
);
writeReadme(newMd, lang);
consola.success('Sync agent index success!');
};

export default async () => {
await runAgentTable('en-US');
await runAgentTable('zh-CN');
};
36 changes: 36 additions & 0 deletions scripts/readmeWorkflow/syncPluginIndex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { consola } from 'consola';
import { markdownTable } from 'markdown-table';

import { DataItem, PLUGIN_REPO, PLUGIN_SPLIT } from './const';
import { fetchPluginIndex, genLink, readReadme, updateReadme, writeReadme } from './utlis';

const genPluginTable = (data: DataItem[], lang: string) => {
const isCN = lang === 'zh-CN';
const content = data
.filter((item) => item.author === 'LobeHub')
.map((item) => [genLink(item.meta.title, item.homepage), item.meta.description]);
return markdownTable([
[isCN ? '官方插件' : 'Official Plugin', isCN ? '插件说明' : 'Description'],
...content,
]);
};

const runPluginTable = async (lang: string) => {
const data = await fetchPluginIndex(lang);
const md = readReadme(lang);
const mdTable = genPluginTable(data, lang);
const newMd = updateReadme(
PLUGIN_SPLIT,
md,
[mdTable, `> 📊 Total plugins: ${genLink(`<kbd>**${data.length}**</kbd>`, PLUGIN_REPO)}`].join(
'\n\n',
),
);
writeReadme(newMd, lang);
consola.success('Sync plugin index success!');
};

export default async () => {
await runPluginTable('en-US');
await runPluginTable('zh-CN');
};
45 changes: 45 additions & 0 deletions scripts/readmeWorkflow/utlis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { readFileSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';

import { AGENT_CN_URL, AGENT_EN_URL, PLUGIN_CN_URL, PLUGIN_EN_URL } from './const';

const fetchIndex = async (url: string) => {
const res = await fetch(url);
return await res.json();
};

export const fetchAgentIndex = async (lang: string) => {
const isCN = lang === 'zh-CN';
const url = isCN ? AGENT_CN_URL : AGENT_EN_URL;
const data = await fetchIndex(url);
return data.agents;
};

export const fetchPluginIndex = async (lang: string) => {
const isCN = lang === 'zh-CN';
const url = isCN ? PLUGIN_CN_URL : PLUGIN_EN_URL;
const data = await fetchIndex(url);
return data.plugins;
};

export const genLink = (title: string, url: string) => `[${title}](${url})`;

const getReadmePath = (lang: string) => {
const isCN = lang === 'zh-CN';
return resolve(__dirname, '../../', isCN ? `./README.zh-CN.md` : `./README.md`);
};

export const readReadme = (lang: string): string => {
return readFileSync(getReadmePath(lang), 'utf8');
};

export const writeReadme = (content: string, lang: string) => {
writeFileSync(getReadmePath(lang), content, 'utf8');
};

export const updateReadme = (split: string, md: string, content: string): string => {
const mds = md.split(split);
mds[1] = [' ', content, ' '].join('\n\n');

return mds.join(split);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,5 @@ import { memo } from 'react';
export const ErrorActionsBar = memo<ActionsBarProps>(({ text, onActionClick }) => {
const { regenerate, del } = useChatListActionsBar(text);

return (
<ActionIconGroup
items={[regenerate, del]}
onActionClick={onActionClick}
type="ghost"
/>
);
return <ActionIconGroup items={[regenerate, del]} onActionClick={onActionClick} type="ghost" />;
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const UserActionsBar: RenderAction = memo(({ text, onActionClick }) => {
const { regenerate, edit, copy, divider, del } = useChatListActionsBar(text);
const { translate } = useCustomActions();


return (
<ActionIconGroup
dropdownMenu={[edit, copy, regenerate, divider, translate, divider, del]}
Expand Down

0 comments on commit 81b3b2a

Please sign in to comment.