open-index/open-npm huggingface dataset:
npm package: @ms-sol/dice-roll
Description: Simple library to interpret, execute dice rolls and calculate odds of given dice result. It uses dice description in dnd form (e.g. 2d6+4) or range (27-34). It can be used in any game that uses dice rolls.
Author: Maciej Sielski
Latest version: 0.1.2

# @ms-sol/dice-roll

This library provides a simple way to interpret and execute dice rolls in the format commonly used in Dungeons & Dragons (D&D) and other tabletop roleplaying games (TTRPGs).

## Installation

Install the library using npm or yarn:

```bash
npm install @ms-sol/dice-roll
```

## Usage
This library offers two functions:

``` rollDice(input: string | DiceSetup): number ```
Takes a dice notation string (e.g., "2d6", "4d10", "3d8+2", allowed notations below) as input. Alternatively you can pass ```DiceSetup``` interface implementing object which is returned by ```parseDice``` function.

Returns an object containing the roll results. The object typically includes properties like the total rolled value, the individual dice rolls, and any modifiers applied.

``` parseDice(notation: string): DiceSetup | null ```
Parses the dice notation string into a more structured representation (```DiceSetup``` interface).
Returns an object with properties:
* count: number of dice
* die: depending on your input this object's descripting (A) the die's minimum, maximum and optional modifier or (B) custom sides of the die.

### CommonJS (CJS):

```JavaScript
const diceRoll = require('@ms-sol/dice-roll');

const result = diceRoll.rollDice('2d6');
console.log(result); // result from 2*1=2 till 2*6=12
```

### ES Modules (ESM):

Importing specific functions:

```JavaScript
import { rollDice, parseDice } from '@ms-sol/dice-roll';

const result = rollDice('3d8');
console.log(result); // result from 3*1=3 till 3*8=24
```

Importing the entire library:

```JavaScript
import diceRoll from '@ms-sol/dice-roll';

const result = diceRoll.rollDice('4d10');
console.log(result); // result from 4*1=4 till 4*10=40
```

## Allowed input string formats

```JavaScript
"d6" // standard 6-sided die
"3d4" // three 4-sided dice

"d4+2" // 4-sided die with +2 modifier to die roll result
"d4-2" // 4-sided die with -2 modifier to die roll result

"4-17" // range from 4-17, equivalent of d14+3

"2d[10,20,30,40,50,60]" // two dice with 6 custom sides (10,20,30,40,50,60)
"2d[10,20,30,40,50,60]+5" // as above but with additional +5 modifier to dice roll result

// HINT: any spaces you input are discarded
" d 4 - 2" // will be treated as "d4-2"

// HINT 2: both lower- and uppercase 'd' are allowed
" D 4 - 2" // will be treated as "d4-2"
```

## Calculating result probability
It might be usefull to calculate the probability of a given result in certain dice setup. 

```JavaScript
// use string dice setup
calculateProbability('d6', 1) // returns 0.1667 (16.67%)

// or parsed object
const diceSetup = parseDice('d6');
calculateProbability(diceSetup, 1) // returns 0.1667 (16.67%)
```

## License
This library is licensed under the MIT License. See the LICENSE file for details.
npm package: @ms918/eslint-config-react
Description: 通用eslint规范
Author: mengshang918
Latest version: 0.5.2

# `eslint-config-react`

> 通用 eslint 配置

## Usage

`package.json`中指定 eslintconfig 字段如下

```
{
  "eslintConfig": {
    "extends": "@ms918/eslint-config-react"
  },
}
```
npm package: @ms918/mrm-task-branchclear
Description: mrm branchclear任务
Author: mengshang918
Latest version: 0.5.2

# `@ms918/mrm-task-branchclear`

> mrm task,用来配置 branchclear

创建的默认`.branchclear.yml`，如下

```json
branchRegStr: ""
clearPosition: local
clearType: current
ignoreRegStr: ""
isIgnore: false
isReg: false
main: master
remoteName: origin
user:
```

## 默认

`.branchclear.yml`的 user 使用`user-meta`获取

## 用法

```powershell
npm install -g @ms918/mrm-task-branchclear
mrm @ms918/mrm-task-branchclear
```

当执行的时候，会走下面步骤：

1. 判断当前路径不存在`.branchclear.yml`，则创建默认
2. 初始化 husky
3. 设置`package.json`
   1. 设置 script branchclera:'branchclear'
   2. 设置 husky.hooks.pre-push 为`exec < /dev/tty && branchclear`
   3. 设置`devDependencies.branchclear-cli`为`^2.0.0`
npm package: @ms918/mrm-task-browserlist
Description: mrm task 创建browserlist
Author: mengshang918
Latest version: 0.5.2

# `@ms918/mrm-task-browserlist`

> mrm task,用来创建[browserlist](https://github.com/browserslist/browserslist)

创建的默认`browserlist`使用`react-dev-util`的`defaultBrowsers`，如下

```json
{
  "production": [">0.2%", "not dead", "not op_mini all"],
  "development": [
    "last 1 chrome version",
    "last 1 firefox version",
    "last 1 safari version"
  ]
}
```

## 用法

```powershell
npm install -g @ms918/mrm-task-browserlist
mrm @ms918/mrm-task-browserlist
```

当执行的时候，会走下面步骤：

1. 判断当前路径下是否存在`.browserslistrc`。存在则不操作，退出
2. 不存在则判断`package.json`是否含有`browserlist`字段且字段为空
   - 为空则设置默认值
   - 不为空直接退出
npm package: @ms918/mrm-task-cz
Description: mrm task创建cz配置
Author: mengshang918
Latest version: 0.5.2

# @ms918/mrm-task-cz

> mrm task,用来创建`commitlint`和`commitizen`配置

创建或更新`package.json`，如下

```json
{
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  },
  "devDependencies": {
    "@commitlint/cli": "^11.0.0",
    "@commitlint/config-conventional": "^11.0.0",
    "commitizen": "^4.2.2",
    "cz-conventional-changelog": "^3.3.0",
    "husky": "^4.3.0"
  },
  "config": {
    "commitizen": {
      "path": "cz-conventional-changelog"
    }
  },
  "scripts": {
    "cz": "cz"
  }
}
```

创建的`commitlint.config.js`如下

```js
module.exports = { extends: ['@commitlint/config-conventional'] }
```

## 用法

```powershell
npm install -g @ms918/mrm-task-cz
mrm @ms918/mrm-task-cz
```

当执行的时候，会走下面步骤：

1. 执行`@ms918/mrm-task-husky`操作
2. 配置`commilint`
   1. 使用`yarn` or `npm`安装`@commitlint/config-conventional`、`@commitlint/cli`
   2. 创建或覆盖`commitlint.config.js`文件
   3. 设置`package.json`的`husky.hooks.commit-msg`字段为`commitlint -E HUSKY_GIT_PARAMS`
3. 配置`commitizen`
   1. 使用`yarn` or `npm`安装`commitizen`、`cz-conventional-changelog`
   2. 设置`package.json`的`config.commitizen.path`为`cz-conventional-changelog`
   3. 设置`cz`script
npm package: @ms918/mrm-task-editorconfig
Description: mrm 编辑器设置
Author: mengshang918
Latest version: 0.5.2

# `@ms918/mrm-task-editorconfig`

> mrm task,用来创建.editorconfig

创建的默认`.editorconfig`如下

```ini
# editorconfig.org
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false

```

## 默认

indent 默认为 2 个空格

## 用法

```powershell
npm install -g @ms918/mrm-task-editorconfig
mrm @ms918/mrm-task-editorconfig
```
npm package: @ms918/mrm-task-eslint
Description: mrm task 配置lint-staged
Author: mengshang918
Latest version: 0.5.2

# `@ms918/mrm-task-eslint`

> mrm task,用来创建`package.json`的`eslintConfig`字段

创建的默认`eslintConfig`字段如下

```json
{
  "eslintConfig": {
    "extends": "@ms918/eslint-config-react"
  }
}
```

## 用法

```powershell
npm install -g @ms918/mrm-task-eslint
mrm @ms918/mrm-task-eslint
```

当执行的时候，会走下面步骤：

1. 获取`eslint-config-react-app`的相对依赖
2. 获取`@ms918/eslint-config-react`的最新版本
3. `yarn`o r`install`安装`eslint-config-react-app`的相对依赖和`@ms918/eslint-config-react`
4. 设置`package.json`的`eslintConfig.extends`为`@ms918/eslint-config-react`
npm package: @ms918/mrm-task-gitignore
Description: mrm task 创建.gitignore
Author: mengshang918
Latest version: 0.5.2

# `@ms918/mrm-task-gitignore

> mrm task,用来创建`.gitignore`

创建的默认`.gitignore`，如下

```
.DS_*
*.log
logs
node_modules/
.idea/
.vscode/
*.sublime*
```

会根据当前路径下是否存在`package-lock.json` 和`yarn.lock`来判断当前用的是`npm`还是`yarn`

## 用法

```powershell
npm install -g @ms918/mrm-task-gitignore
mrm @ms918/mrm-task-gitignore
```

当执行的时候，会走下面步骤：

1. 会根据当前路径下是否存在`package-lock.json` 和`yarn.lock`来判断当前用的是`npm`还是`yarn`
2. 添加`.gitignore`
npm package: @ms918/mrm-task-husky
Description: mrm task创建husky
Author: mengshang918
Latest version: 0.5.2

# @ms918/mrm-task-husky

> mrm task,用来创建`husky`配置

创建的默认`huksy`，如下

```json
{
  "husky": {
    "hooks": {}
  }
}
```

## 用法

```powershell
npm install -g @ms918/mrm-task-husky
mrm @ms918/mrm-task-husky
```

当执行的时候，会走下面步骤：

1. 判断当前文件夹是否存在`.git`文件
   - 存在，则进行下面步骤`2`-`4`初始化 husky 操作
   - 不存在，则先`git init`
2. 判断当前使用 npm 还是 yarn
3. npm or yarn install husky
4. package.json 判断是否有 husky.hooks 字段
   - 有则认为用户已经设置了 husky 环境，直接退出
   - 没有则设置
npm package: @ms918/mrm-task-license
Description: mrm task 创建license
Author: mengshang918
Latest version: 0.5.2

# `@ms918/mrm-task-license

> mrm task,用来创建`LICENSE`

创建的默认`LICENSE`，如下

```
The MIT License

Copyright ${year} ${author}, contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

## 默认

`year`默认为当前年份，`author`默认为`package.json`的`author.name`或`.gitconfig`的`user.name`

## 用法

```powershell
npm install -g @ms918/mrm-task-license
mrm @ms918/mrm-task-license
```

当执行的时候，会走下面步骤：

1. 获取默认 author
2. 生成 LICENSE
3. 设置`package.json`的`license`字段为`MIT`
npm package: @ms918/mrm-task-lint-staged
Description: mrm task 创建lint-staged
Author: mengshang918
Latest version: 0.5.2

# `@ms918/mrm-task-lint-staged`

> mrm task,用来配置`lint-staged`,可选 eslint 和 prettier（需要配合@ms918/mrm-task-eslint、@ms918/mrm-task-prettier）

创建的默认`package.json`字段如下

```json
{
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "devDependencies": {
    "husky": "^4.3.0"
  },
  "lint-staged": {
    "*.{tsx,ts,jsx,js}": ["eslint --fix", "prettier --write ."],
    "*.{md,mdx}": ["prettier --write ."]
  }
}
```

## 默认

默认选择 eslint 和 prettier，创建配置如上。

只选择 eslint，创建配置如下

```json
{
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "devDependencies": {
    "husky": "^4.3.0"
  },
  "lint-staged": {
    "*.{tsx,ts,jsx,js}": ["eslint --fix"]
  }
}
```

只选择 prettier，创建配置如下

```json
{
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "devDependencies": {
    "husky": "^4.3.0"
  },
  "lint-staged": {
    "*.{tsx,ts,jsx,js}": ["prettier --config .prettierrc.yml --write"],
    "*.{md,mdx}": ["prettier --config .prettierrc.yml --write"]
  }
}
```

## 用法

```powershell
npm install -g @ms918/mrm-task-lint-staged
mrm @ms918/mrm-task-lint-staged
```

当执行的时候，会走下面步骤：

1. 执行`@ms918/mrm-task-husky`步骤
2. 判断`husky.pre-commit`是否有脚本
   1. 有，则设置`husky.pre-commit`为`之前脚本 && lint-staged`
   2. 无，则设置`husky.pre-commit`为`lint-staged`
3. `yarn`or`npm`安装`lint-staged`
4. 设置`package.json`的`lint-staged`字段为上述所示
npm package: @ms918/mrm-task-npmrc
Description: mrm创建.npmrc的task
Author: mengshang918
Latest version: 0.5.2

# `@ms918/mrm-task-npmrc`

> mrm task,用来创建.npmrc

创建的默认`.npmrc`如下

```
registry=https://registry.yarnpkg.com/
```

## 默认

- 默认不设置 scope

- 默认 registry 为https://registry.yarnpkg.com/

## 用法

```powershell
npm install -g @ms918/mrm-task-npmrc
mrm @ms918/mrm-task-npmrc
```

当执行的时候，会走下面步骤：

1. 判断当前路径下是否存在`.npmrc`，存在则删除包含有 registry 的行
2. 判断是否有 scope
   - 没有 scope，只设置 registry
   - 有 scope，除了执行上面步骤之外，还会添加@scope:registry
npm package: @ms918/mrm-task-package
Description: mrm task创建package.json
Author: mengshang918
Latest version: 0.5.2

# `@ms918/mrm-task-package`

> mrm task,用来配置`package`

创建的默认`package.json`如下

```js
{
    name: '',
    version: '1.0.0',
    description: '',
    author: {
      name:'',
      email:'',
      url:''
    },
    homepage: '',
    license: 'MIT',
    main: 'index.js',
    files: ['index.js'],
    scripts: {},
    keywords: [],
    dependencies: {},
    devDependencies: {},
  }
```

## 默认

作者名字、邮箱、主页，使用`user-meta`获取，若之前设置则使用之前设置的值。

## 用法

```powershell
npm install -g @ms918/mrm-task-package
mrm @ms918/mrm-task-package
```

当执行的时候，会走下面步骤：

1. 判断当前路径下是否有`package.json`

   1. 有

      `package.json`没有的字段均设置成上面的默认值

   2. 无

      创建默认的`package.json`
npm package: @ms918/mrm-task-prettier
Description: mrm task 创建prettier
Author: mengshang918
Latest version: 0.5.2

# `@ms918/mrm-task-prettier`

> mrm task,用来创建`package.json`的`prettier`字段

创建的默认`prettier`字段如下

```json
{
  "prettier": {
    "useTabs": false,
    "indent": 2,
    "semi": false,
    "singleQuote": true
  }
}
```

## 默认

- 默认读取`.editorconfig`,使用`editorconfig-to-prettier`
- 没有.editorconfig，默认 indent 为 2

## 用法

```powershell
npm install -g @ms918/mrm-task-prettier
mrm @ms918/mrm-task-prettier
```

当执行的时候，会走下面步骤：

1. 判断当前路径下是否存在`.editorconfig`
   1. 存在使用`.editorconfig`中一些配置
   2. 不存在使用默认`indent`为 2
2. 设置`package.json`的`prettier`字段
3. 设置`package.json`
   1. 设置`prettier`字段
   2. 设置`prettier`script
4. `yarn`or`npm`安装`prettier`
npm package: @ms918/mrm-task-readme
Description: mrm task设置readme
Author: mengshang918
Latest version: 0.5.2

# `@ms918/mrm-task-readme`

> mrm task,用来创建`README.md`

创建的默认`README.md`，如下

```json
# `packagename`

> package description

## Usage

some api ...
```

## 默认

默认 package name 从 package.json 中获取 name 字段

## 用法

```powershell
npm install -g @ms918/mrm-task-readme
mrm @ms918/mrm-task-readme
```

当执行的时候，会走下面步骤：

1. 判断当前路径不存在`README.md`，则创建默认`README.md`
npm package: @ms_teams/agents-hosting-china
Description: Microsoft 365 Agents SDK for JavaScript - China Cloud Support (21Vianet)
Author: ms_teams
Latest version: 1.3.1-china1

# microsoft/agents-hosting

## Overview

The `@microsoft/agents-hosting` package provides the necessary tools and components to create and host Microsoft Agents. This package includes a compatible API to migrate a bot using `botbuilder` from the BotFramework SDK.

## Installation

To install the package:

```sh
npm install @microsoft/agents-hosting
```

## Example Usage based on the AgentApplication object

```ts
import { AgentApplication, MemoryStorage, TurnContext, TurnState } from '@microsoft/agents-hosting'

const echo = new AgentApplication<TurnState>({ storage: new MemoryStorage() })
echo.onConversationUpdate('membersAdded', async (context: TurnContext) => {
  await context.sendActivity('Welcome to the Echo sample, send a message to see the echo feature in action.')
})
echo.onActivity('message', async (context: TurnContext, state: TurnState) => {
  let counter: number = state.getValue('conversation.counter') || 0
  await context.sendActivity(`[${counter++}]You said: ${context.activity.text}`)
  state.setValue('conversation.counter', counter)
})
```

## Example Usage based on bot framework Activity Handler

Create an Echo bot using the ActivityHandler

```ts
// myHandler.ts
import { ActivityHandler, MessageFactory } from '@microsoft/agents-hosting'

export class MyHandler extends ActivityHandler {
  constructor () {
    super()
    this.onMessage(async (context, next) => {
      const replyText = `Agent: ${context.activity.text}`
      await context.sendActivity(MessageFactory.text(replyText))
      await next()
    })
  }
}
```

Host the bot with express

```ts
// index.ts
import express, { Response } from 'express'
import { Request, CloudAdapter, authorizeJWT, AuthConfiguration, loadAuthConfigFromEnv } from '@microsoft/agents-hosting'
import { EchoBot } from './myHandler'

const authConfig: AuthConfiguration = loadAuthConfigFromEnv()

const adapter = new CloudAdapter(authConfig)
const myHandler = new MyHandler()

const app = express()

app.use(express.json())
app.use(authorizeJWT(authConfig))

app.post('/api/messages', async (req: Request, res: Response) => {
  await adapter.process(req, res, async (context) => await myHandler.run(context))
})

```