Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from ubiquibot/development
Browse files Browse the repository at this point in the history
Merge development into main
  • Loading branch information
gentlementlegen authored May 3, 2024
2 parents 709dd26 + 4382ea4 commit 7edb430
Show file tree
Hide file tree
Showing 27 changed files with 1,411 additions and 542 deletions.
4 changes: 2 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log"],
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "**/tests/*"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir"],
"words": ["dataurl", "devpool", "outdir", "servedir", "typebox", "supabase", "ubiquibot"],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
Expand Down
84 changes: 84 additions & 0 deletions .github/.ubiquibot-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
price-multiplier: 1.5
command-settings:
- name: start
enabled: false
# newContributorGreeting:
# enabled: true
# header: "Thank you for contributing to UbiquiBot! Please be sure to set your wallet address before completing your first bounty so that the automatic payout upon task completion will work for you."
# helpMenu: true
# footer: "###### Also please star this repository and [@ubiquity/devpool-directory](https://github.com/ubiquity/devpool-directory/) to show your support. It helps a lot!"

incentives:
enabled: true
contentEvaluator:
enabled: true
userExtractor:
enabled: true
redeemTask: true
dataPurge:
enabled: true
formattingEvaluator:
enabled: true
scores:
br: 0
code: 1
p: 1
em: 0
img: 0
strong: 0
blockquote: 0
h1: 1
h2: 1
h3: 1
h4: 1
h5: 1
h6: 1
a: 1
li: 1
td: 1
hr: 0
multipliers:
- type: [ ISSUE, ISSUER, SPECIFICATION ]
formattingMultiplier: 1
wordValue: 0.1
- type: [ ISSUE, ISSUER, COMMENTED ]
formattingMultiplier: 1
wordValue: 0.2
- type: [ ISSUE, ASSIGNEE, COMMENTED ]
formattingMultiplier: 0
wordValue: 0
- type: [ ISSUE, COLLABORATOR, COMMENTED ]
formattingMultiplier: 1
wordValue: 0.1
- type: [ ISSUE, CONTRIBUTOR, COMMENTED ]
formattingMultiplier: 0.25
wordValue: 0.1
- type: [ REVIEW, ISSUER, TASK ]
formattingMultiplier: 0
wordValue: 0
- type: [ REVIEW, ISSUER, COMMENTED ]
formattingMultiplier: 2
wordValue: 0.2
- type: [ REVIEW, ASSIGNEE, COMMENTED ]
formattingMultiplier: 1
wordValue: 0.1
- type: [ REVIEW, COLLABORATOR, COMMENTED ]
formattingMultiplier: 1
wordValue: 0.1
- type: [ REVIEW, CONTRIBUTOR, COMMENTED ]
formattingMultiplier: 0.25
wordValue: 0.1
permitGeneration:
enabled: true
githubComment:
enabled: true
post: true
debug: false

plugins:
'issues.closed':
- uses:
- plugin: ubiquity/conversation-rewards@testing/ubiquibot-v2-testing
type: github
with:
evmNetworkId: 100
9 changes: 0 additions & 9 deletions .github/ubiquibot-config.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/cspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Spell Check

on:
push:
pull_request:

jobs:
spellcheck:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
- uses: google-github-actions/release-please-action@v4
with:
release-type: node
package-name: @ubiquibot/configuration
default-branch: main
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.10.0'
registry-url: https://registry.npmjs.org/
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ coverage
coverage.txt

dist
junit.xml
23 changes: 16 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ubiquibot/configuration",
"version": "1.1.0",
"version": "2.0.3",
"private": false,
"description": "Configuration helpers for Ubiquibot.",
"author": "Ubiquity DAO",
Expand All @@ -25,34 +25,40 @@
"ubiquibot",
"open-source"
],
"dependencies": {
"@sinclair/typebox": "0.32.14",
"ajv": "8.12.0",
"ajv-formats": "2.1.1",
"dotenv": "16.4.4",
"dependencies": {},
"peerDependencies": {
"@octokit/webhooks": "12.2.0",
"@sinclair/typebox": "0.32.23",
"ajv": "8.13.0",
"ajv-formats": "3.0.1",
"dotenv": "16.4.5",
"lodash": "4.17.21",
"ms": "2.1.3"
},
"peerDependencies": {},
"devDependencies": {
"@commitlint/cli": "18.6.1",
"@commitlint/config-conventional": "18.6.2",
"@cspell/dict-node": "4.0.3",
"@cspell/dict-software-terms": "3.3.18",
"@cspell/dict-typescript": "3.1.2",
"@octokit/webhooks": "12.2.0",
"@rollup/plugin-commonjs": "25.0.7",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-terser": "0.4.4",
"@rollup/plugin-typescript": "11.1.6",
"@rollup/plugin-yaml": "4.1.2",
"@sinclair/typebox": "0.32.23",
"@types/jest": "29.5.12",
"@types/lodash": "4.14.202",
"@types/ms": "0.7.34",
"@types/node": "20.11.19",
"@typescript-eslint/eslint-plugin": "7.0.1",
"@typescript-eslint/parser": "7.0.1",
"ajv": "8.12.0",
"ajv-formats": "3.0.1",
"cspell": "8.3.2",
"dotenv": "16.4.5",
"esbuild": "0.20.0",
"esbuild-plugin-yaml": "0.0.1",
"eslint": "8.56.0",
Expand All @@ -65,10 +71,13 @@
"jest-transform-yaml": "1.1.2",
"knip": "5.0.1",
"lint-staged": "15.2.2",
"lodash": "4.17.21",
"ms": "2.1.3",
"npm-run-all": "4.1.5",
"prettier": "3.2.5",
"rollup": "4.12.0",
"rollup-plugin-dts-bundle-generator": "1.4.0",
"rollup-plugin-peer-deps-external": "2.2.4",
"rollup-plugin-typescript2": "0.36.0",
"ts-jest": "29.1.2",
"tslib": "2.6.2",
Expand Down
7 changes: 6 additions & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import nodeResolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import terser from "@rollup/plugin-terser";
import peerDepsExternal from "rollup-plugin-peer-deps-external";

export default {
input: "src/index.ts",
output: {
dir: "dist",
format: "cjs",
},
plugins: [nodeResolve(), commonjs(), typescript(), yaml(), json(), generateDtsBundle(), terser()],
plugins: [peerDepsExternal(), nodeResolve(), commonjs(), typescript({
tsconfigOverride: {
exclude: ["**/tests", "**/*.test.ts"],
},
}), yaml(), json(), generateDtsBundle(), terser()],
};
47 changes: 22 additions & 25 deletions src/types/configuration-types.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import { ObjectOptions, Static, StaticDecode, StringOptions, TProperties, Type as T } from "@sinclair/typebox";
import ms from "ms";

import { ajv } from "../utils";
import { validHTMLElements } from "./valid-html-elements";
import { contentEvaluatorConfigurationType } from "./configuration/content-evaluator-config";
import { dataPurgeConfigurationType } from "./configuration/data-purge-config";
import { formattingEvaluatorConfigurationType } from "./configuration/formatting-evaluator-config";
import { githubCommentConfigurationType } from "./configuration/github-comment-config";
import { permitGenerationConfigurationType } from "./configuration/permit-generation-configuration";
import { pluginConfigurationSchema } from "./configuration/plugin-configuration";
import { userExtractorConfigurationType } from "./configuration/user-extractor-config";

const promotionComment =
"###### If you enjoy the DevPool experience, please follow [Ubiquity on GitHub](https://github.com/ubiquity) and star [this repo](https://github.com/ubiquity/devpool-directory) to show your support. It helps a lot!";
const defaultGreetingHeader =
"Thank you for contributing! Please be sure to set your wallet address before completing your first task so that you can collect your reward.";

const htmlEntities = validHTMLElements.map((value) => T.Literal(value));

const allHtmlElementsSetToZero = validHTMLElements.reduce(
(accumulator, current) => {
accumulator[current] = 0;
return accumulator;
},
{} as Record<keyof HTMLElementTagNameMap, number>
);

export enum LogLevel {
FATAL = "fatal",
ERROR = "error",
Expand Down Expand Up @@ -49,18 +44,23 @@ export function stringDuration(options?: StringOptions) {
.Encode((value) => ms(value));
}

const envConfigSchema = T.Object({
export const envConfigSchema = T.Object({
WEBHOOK_PROXY_URL: T.Optional(T.String({ format: "uri" })), // optional for production
LOG_LEVEL: T.Enum(LogLevel, { default: LogLevel.DEBUG }),
LOG_RETRY_LIMIT: T.Number({ default: 8 }),
SUPABASE_URL: T.String({ format: "uri" }),
SUPABASE_KEY: T.String(),
GITHUB_TOKEN: T.String(),
X25519_PRIVATE_KEY: T.String(),
OPENAI_API_KEY: T.String(),
NFT_MINTER_PRIVATE_KEY: T.String(),
NFT_CONTRACT_ADDRESS: T.String(),
PRIVATE_KEY: T.String(),
APP_ID: T.Number(),
});

export const validateEnvConfig = ajv.compile(envConfigSchema);
export type EnvConfig = Static<typeof envConfigSchema>;
export type EnvConfigType = Static<typeof envConfigSchema>;

const botConfigSchema = strictObject(
{
Expand All @@ -83,7 +83,6 @@ const botConfigSchema = strictObject(
}),
isNftRewardEnabled: T.Boolean({ default: false }),
}),

timers: strictObject({
reviewDelayTolerance: stringDuration({ default: "1 day" }),
taskStaleTimeoutDuration: stringDuration({ default: "4 weeks" }),
Expand All @@ -98,16 +97,13 @@ const botConfigSchema = strictObject(
}),
disabledCommands: T.Array(T.String(), { default: allCommands }),
incentives: strictObject({
comment: strictObject({
elements: T.Record(T.Union(htmlEntities), T.Number({ default: 0 }), { default: allHtmlElementsSetToZero }),
totals: strictObject({
character: T.Number({ default: 0, minimum: 0 }),
word: T.Number({ default: 0, minimum: 0 }),
sentence: T.Number({ default: 0, minimum: 0 }),
paragraph: T.Number({ default: 0, minimum: 0 }),
comment: T.Number({ default: 0, minimum: 0 }),
}),
}),
enabled: T.Boolean({ default: true }),
contentEvaluator: contentEvaluatorConfigurationType,
userExtractor: userExtractorConfigurationType,
dataPurge: dataPurgeConfigurationType,
formattingEvaluator: formattingEvaluatorConfigurationType,
permitGeneration: permitGenerationConfigurationType,
githubComment: githubCommentConfigurationType,
}),
labels: strictObject({
time: T.Array(T.String(), { default: defaultTimeLabels }),
Expand All @@ -119,6 +115,7 @@ const botConfigSchema = strictObject(
registerWalletWithVerification: T.Boolean({ default: false }),
openAiTokenLimit: T.Number({ default: 100000 }),
}),
plugins: pluginConfigurationSchema,
},
{ default: undefined } // top level object can't have default!
);
Expand Down
38 changes: 38 additions & 0 deletions src/types/configuration/comment-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export enum CommentType {
/**
* Review related item
*/
REVIEW = 0b1,
/**
* Issue related item
*/
ISSUE = 0b10,
/**
* User assigned to the {@link CommentType.ISSUE} or {@link CommentType.REVIEW}
*/
ASSIGNEE = 0b100,
/**
* The author of the {@link CommentType.ISSUE} or {@link CommentType.REVIEW}
*/
ISSUER = 0b1000,
/**
* A user that is part of the organization or owner of the repo
*/
COLLABORATOR = 0b10000,
/**
* A user that is NOT part of the organization nor owner of the repo
*/
CONTRIBUTOR = 0b100000,
/**
* A user comment action on a {@link CommentType.ISSUE} or {@link CommentType.REVIEW}
*/
COMMENTED = 0b1000000,
/**
* Pull request opening item
*/
TASK = 0b10000000,
/**
* Issue opening item
*/
SPECIFICATION = 0b100000000,
}
10 changes: 10 additions & 0 deletions src/types/configuration/common-incentive-config-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Type, Static } from "@sinclair/typebox";

export const baseIncentiveConfiguration = Type.Object({
/**
* Enables or disabled this module
*/
enabled: Type.Boolean({ default: true }),
});

export type BaseConfiguration = Static<typeof baseIncentiveConfiguration>;
10 changes: 10 additions & 0 deletions src/types/configuration/content-evaluator-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Static, Type } from "@sinclair/typebox";

export const contentEvaluatorConfigurationType = Type.Object({
/**
* Enables or disabled this module
*/
enabled: Type.Boolean(),
});

export type ContentEvaluatorConfiguration = Static<typeof contentEvaluatorConfigurationType>;
10 changes: 10 additions & 0 deletions src/types/configuration/data-purge-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Type, Static } from "@sinclair/typebox";

export const dataPurgeConfigurationType = Type.Object({
/**
* Enables or disabled this module
*/
enabled: Type.Boolean({ default: true }),
});

export type DataPurgeConfiguration = Static<typeof dataPurgeConfigurationType>;
Loading

0 comments on commit 7edb430

Please sign in to comment.