Skip to content

Commit

Permalink
chore: simplify contribution process (#263)
Browse files Browse the repository at this point in the history
Ref: #259

Signed-off-by: Tomas Dvorak <[email protected]>
  • Loading branch information
Tomas2D authored Dec 23, 2024
1 parent e10b053 commit 1da6f6e
Show file tree
Hide file tree
Showing 18 changed files with 242 additions and 188 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable
- name: Check Copyright Header
uses: actions/setup-go@v3
with:
go-version: 1.23
run: yarn copyright:check
- name: Code Lint
run: yarn lint
- name: Code Format
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ dist
.idea
/experiments
.npmrc
.DS_Store
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
yarn lint-staged
CI=true yarn docs:check && yarn lint && yarn format && yarn ts:check && yarn run test:unit && yarn copyright
CI=true yarn docs:check && yarn lint && yarn format && yarn ts:check && yarn run test:unit && yarn copyright:check
13 changes: 13 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import tseslint from "typescript-eslint";
import prettierConfig from "eslint-config-prettier";
import unusedImports from "eslint-plugin-unused-imports";
import markdown from "@eslint/markdown";
import stylisticJs from "@stylistic/eslint-plugin-js";

export default tseslint.config(
{
Expand Down Expand Up @@ -40,6 +41,8 @@ export default tseslint.config(
},
plugins: {
"unused-imports": unusedImports,
// @ts-expect-error wrong types
"@stylistic/js": stylisticJs,
},
rules: {
"no-console": ["error"],
Expand Down Expand Up @@ -74,6 +77,16 @@ export default tseslint.config(
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-object-type": "off",
"quote-props": ["error", "consistent"],
// Force a new line after the copyright header; otherwise, nwa reports them as incorrectly formatted
"@stylistic/js/lines-around-comment": [
"error",
{
applyDefaultIgnorePatterns: false,
afterBlockComment: true,
beforeBlockComment: false,
ignorePattern: /^(?![\s\S]*Copyright \d+ IBM Corp.)[\s\S]+$/u.source,
},
],
},
},
{
Expand Down
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@
}
},
"lint-staged": {
"*": [
"yarn copyright",
"prettier --ignore-unknown --write"
],
"*.{ts,js}": "eslint --fix",
"*": "prettier --ignore-unknown --write"
"docs/**/*.md": "yarn docs:links"
},
"prettier": {
"printWidth": 100,
Expand Down Expand Up @@ -76,7 +80,8 @@
},
"hooks": {
"before:init": [
"[ \"$RELEASE_SKIP_DOCS\" = \"true\" ] && echo 'Skipping docs check.' || yarn docs:check",
"yarn docs:check",
"[ \"$RELEASE_SKIP_DOCS_LINKS\" = \"true\" ] && echo 'Skipping docs links check.' || yarn docs:links:check",
"yarn lint",
"yarn ts:check",
"yarn test:all"
Expand Down Expand Up @@ -140,8 +145,9 @@
"start:bee": "yarn start -- examples/agents/bee.ts",
"start:telemetry": "BEE_FRAMEWORK_INSTRUMENTATION_ENABLED=true yarn start --import ./examples/helpers/telemetry.ts",
"docs:build": "embedme --source-root=. docs/**/*.md && cp *.md docs/ && yarn lint:fix docs/ && yarn prettier --write docs/",
"docs:check": "embedme --source-root=. docs/**/*.md --verify && yarn docs:links",
"docs:links": "linkinator \"**/*.md\" --timeout=10000 --retry --markdown --directory-listing --skip node_modules --skip \"https://ai.meta.com/blog/meta-llama-3-1/\" ",
"docs:check": "embedme --source-root=. docs/**/*.md --verify",
"docs:links": "linkinator . --timeout=10000 --retry --markdown --directory-listing --skip node_modules --skip CHANGELOG.md --skip docs/CHANGELOG.md --skip \"https://ai.meta.com/blog/meta-llama-3-1/\" --include",
"docs:links:check": "yarn docs:links docs/**/*.md",
"docs:watch": "docsify serve ./docs --open",
"lint": "yarn eslint",
"lint:fix": "yarn eslint --fix",
Expand All @@ -156,6 +162,7 @@
"test:examples:watch": "vitest --config ./examples/vitest.examples.config.ts watch tests/examples",
"prepare": "husky",
"copyright": "./scripts/copyright.sh",
"copyright:check": "TYPE=check ./scripts/copyright.sh",
"release": "release-it",
"ibm-vllm:generate-types": "./scripts/ibm_vllm_generate_protos/ibm_vllm_generate_protos.sh",
"_ensure_env": "cp -n .env.template .env || true"
Expand Down Expand Up @@ -285,6 +292,7 @@
"@opentelemetry/semantic-conventions": "^1.28.0",
"@release-it/conventional-changelog": "^8.0.2",
"@rollup/plugin-commonjs": "^28.0.1",
"@stylistic/eslint-plugin-js": "^2.12.1",
"@swc/core": "^1.10.0",
"@types/eslint": "^9.6.1",
"@types/eslint-config-prettier": "^6.11.3",
Expand All @@ -300,7 +308,7 @@
"docsify-cli": "^4.4.4",
"dotenv": "^16.4.7",
"embedme": "^1.22.1",
"eslint": "^9.16.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-unused-imports": "^4.1.4",
"glob": "^11.0.0",
Expand Down Expand Up @@ -328,7 +336,7 @@
"tsup": "^8.3.5",
"tsx": "^4.19.2",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"typescript-eslint": "^8.18.1",
"vite-tsconfig-paths": "^5.1.3",
"vitest": "^2.1.8",
"yaml": "^2.6.1"
Expand Down
21 changes: 16 additions & 5 deletions scripts/copyright.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@

set -e

TARGETS=(${TARGETS:-src dist tests scripts})
if [ "$#" -eq 0 ]; then
TARGETS=('src/**/*.{js,ts,proto}' "dist/**/*.js" "tests/**/*.{js,ts}" "scripts/**/*.{sh,ts,js}")
else
TARGETS=("$@")
fi

# Path to the package.json file
PACKAGE_JSON_PATH="./package.json"
Expand Down Expand Up @@ -43,11 +47,18 @@ if ! command -v nwa &> /dev/null && command -v go &> /dev/null; then
export PATH=$PATH:$(go env GOPATH)/bin
fi

TYPE=${TYPE:-add}

if command -v nwa &> /dev/null; then
nwa add -l apache -c "$AUTHOR" "${TARGETS[@]}"
echo "Running 'nwa' version $(nwa --version)"
nwa "${TYPE}" -l apache -c "$AUTHOR" "${TARGETS[@]}"
elif command -v docker &> /dev/null; then
docker run --rm -v "${PWD}:/src" ghcr.io/b1nary-gr0up/nwa:main add -l apache -c "$AUTHOR" "${TARGETS[@]}"
docker run --rm -v "${PWD}:/src" ghcr.io/b1nary-gr0up/nwa:main "${TYPE}" -l apache -c "$AUTHOR" "${TARGETS[@]}"
else
echo "Error: 'nwa' is not available. Either install it manually or install go/docker."
exit 1
if [ "$COPYRIGHT_STRICT" = true ] ; then
echo "Error: 'nwa' is not available. Either install it manually or install go/docker."
exit 1
else
echo "Copyright script was not executed because the nwa package could not be installed."
fi
fi
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ rm -rf "${SCRIPT_DIR}"/{dist,dts,types}

yarn run lint:fix "${GRPC_TYPES_PATH}"
yarn prettier --write "${GRPC_TYPES_PATH}"
TARGETS="$GRPC_TYPES_PATH" yarn copyright
yarn copyright "${GRPC_TYPES_PATH}"
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/caikit_data_model_caikit_nlp.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2024 IBM Corp.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Source: https://github.com/IBM/vllm/blob/main/proto/caikit_data_model_caikit_nlp.proto

Expand Down
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/caikit_data_model_common.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2024 IBM Corp.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Source: https://github.com/IBM/vllm/blob/main/proto/caikit_data_model_common.proto

Expand Down
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/caikit_data_model_nlp.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2024 IBM Corp.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Source: https://github.com/IBM/vllm/blob/main/proto/caikit_data_model_nlp.proto

Expand Down
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/caikit_data_model_runtime.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2024 IBM Corp.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Source: https://github.com/IBM/vllm/blob/main/proto/caikit_data_model_runtime.proto

Expand Down
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/caikit_runtime_Nlp.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2024 IBM Corp.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Source: https://github.com/IBM/vllm/blob/main/proto/caikit_runtime_Nlp.proto

Expand Down
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/generation.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2024 IBM Corp.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Source: https://github.com/IBM/vllm/blob/main/proto/generation.proto

Expand Down
1 change: 1 addition & 0 deletions src/agents/bee/runners/default/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { BaseRunner, BeeRunnerLLMInput, BeeRunnerToolInput } from "@/agents/bee/runners/base.js";
import type {
BeeAgentRunIteration,
Expand Down
1 change: 1 addition & 0 deletions src/agents/bee/runners/granite/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { BaseMessage, Role } from "@/llms/primitives/message.js";
import type { AnyTool } from "@/tools/base.js";
import { isEmpty } from "remeda";
Expand Down
1 change: 1 addition & 0 deletions src/agents/parsers/linePrefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Emitter } from "@/emitter/emitter.js";
import { entries } from "remeda";
import { ValueError } from "@/errors.js";
Expand Down
Loading

0 comments on commit 1da6f6e

Please sign in to comment.