Skip to content

Commit d3123a3

Browse files
authored
feat: vg utility init (#5672)
* feat: vg utility init * Cleanup
1 parent 66ab8fd commit d3123a3

File tree

12 files changed

+593
-9
lines changed

12 files changed

+593
-9
lines changed

package-lock.json

Lines changed: 183 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"packages/bundle",
5353
"packages/test/page-object",
5454
"packages/debug-theme",
55-
"packages/fluent-theme"
55+
"packages/fluent-theme",
56+
"packages/vibe-grep"
5657
],
5758
"scripts": {
5859
"audit-all": "find -name package-lock.json | xargs dirname | xargs -I {} sh -c 'cd {} && npm audit'",
@@ -172,7 +173,8 @@
172173
"start:test-dev-server": "cd packages && cd test && cd dev-server && npm start",
173174
"start:test-harness": "cd packages && cd test && cd harness && npm start",
174175
"start:test-page-object": "cd packages && cd test && cd page-object && npm start",
175-
"test": "jest"
176+
"test": "jest",
177+
"vg": "vg"
176178
},
177179
"pinDependencies": {
178180
"@testing-library/react": [
@@ -228,6 +230,7 @@
228230
"@babel/runtime": "^7.28.4",
229231
"@biomejs/biome": "^2.3.10",
230232
"@happy-dom/jest-environment": "^20.0.11",
233+
"@msinternal/vibe-grep": "^0.0.0-0",
231234
"@testing-library/react": "^12.1.5",
232235
"@types/jest": "^29.5.14",
233236
"@types/react": "^16.14.68",

packages/component/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
"build": "npm run --if-present build:pre && npm run build:run && npm run --if-present build:post",
7979
"build:post": "npm run build:post:dtsroll && npm run build:post:validate:css && npm run build:post:validate:dts",
8080
"build:post:dtsroll": "dtsroll ./dist/*.d.*",
81-
"build:post:validate:css": "grep -q -P '\\.webchat \\.w([a-zA-Z-]){6}_' dist/*.css 2>/dev/null || { echo \"Error: dist/*.css is not compiled by Lightning CSS\" >&2; exit 1; }",
82-
"build:post:validate:dts": "if grep -q -P '@msinternal\\/' dist/*.d.* 2>/dev/null; then echo \"Error: dist/*.d.* is not compiled by dtsroll\" >&2; exit 1; fi",
81+
"build:post:validate:css": "vg ast-check lightning-css ./dist/*.css",
82+
"build:post:validate:dts": "vg ast-check dist-types ./dist/*.d.*",
8383
"build:pre": "npm run build:pre:local-dependencies && npm run build:pre:watch",
8484
"build:pre:local-dependencies": "../../scripts/npm/build-local-dependencies.sh",
8585
"build:pre:watch": "../../scripts/npm/build-watch.sh",

packages/component/src/Attachment/Text/private/ActivityCopyButton.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030
}
3131

32-
.activity-copy-button__copy-announcement {
32+
:global(.webchat) .activity-copy-button__copy-announcement {
3333
pointer-events: none;
3434
}
3535

packages/fluent-theme/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
"build:post": "npm run build:post:dtsroll && npm run build:post:validate",
4545
"build:post:dtsroll": "dtsroll ./dist/*.d.*",
4646
"build:post:validate": "npm run build:post:validate:css && npm run build:post:validate:dts",
47-
"build:post:validate:css": "grep -q -P '\\.webchat-fluent \\.w([a-zA-Z-]){6}_' dist/*.css 2>/dev/null || { echo \"Error: dist/*.css is not compiled by Lightning CSS\" >&2; exit 1; }",
48-
"build:post:validate:dts": "if grep -q -P '@msinternal\\/' dist/*.d.* 2>/dev/null; then echo \"Error: dist/*.d.* is not compiled by dtsroll\" >&2; exit 1; fi",
47+
"build:post:validate:css": "vg ast-check lightning-css ./dist/*.css",
48+
"build:post:validate:dts": "vg ast-check dist-types ./dist/*.d.*",
4949
"build:pre": "npm run build:pre:local-dependencies && npm run build:pre:watch",
5050
"build:pre:local-dependencies": "../../scripts/npm/build-local-dependencies.sh",
5151
"build:pre:watch": "../../scripts/npm/build-watch.sh",

packages/vibe-grep/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Vibe-Grep (vg)
2+
3+
An internal tool for repository housekeeping using AST-based code search and analysis.
4+
5+
## Usage
6+
7+
The tool is available across the repo via the `vg` command:
8+
9+
```bash
10+
vg help
11+
```
12+
13+
## Architecture
14+
15+
Built on top of [`ast-grep`](https://ast-grep.github.io/), vibe-grep provides extensible code analysis through:
16+
17+
- **Commands** – Custom operations in the `commands/` folder
18+
- **Presets** – Reusable rule sets in the `rules/` folder
19+
- **Rules** – Individual AST patterns within presets
20+
21+
## Development
22+
23+
### Adding Commands
24+
25+
Create a `.js` file in the `commands/` directory:
26+
27+
```js
28+
export const description = 'Short command description.';
29+
30+
export function help(...args) {
31+
// Print command help (optional)
32+
}
33+
34+
export default function run(...args) {
35+
// Run the command
36+
}
37+
```
38+
39+
### Adding Presets
40+
41+
Debug rules using the [AST-Grep playground](https://ast-grep.github.io/playground.html).
42+
43+
Create a `.yaml` file in the `rules/` directory:
44+
45+
```yaml
46+
---
47+
# Context for developers
48+
49+
id: rule-name
50+
language: TypeScript # or JavaScript, etc.
51+
rule:
52+
# AST pattern goes here
53+
description: 'Rule description for help command'
54+
message: 'Message shown when matched'
55+
severity: error # or warning
56+
args: [sample, args] # For help examples
57+
```
58+
59+
### Adding Rules
60+
61+
Adding new rules to existing presets is as simple as adding another block starting from `---` into the desired `.yaml` file.
62+
63+
## License
64+
65+
MIT

packages/vibe-grep/package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@msinternal/vibe-grep",
3+
"description": "VibeGrep (vg) is an internal tool for the repo housekeeping.",
4+
"version": "0.0.0-0",
5+
"author": "Microsoft Corporation",
6+
"license": "MIT",
7+
"private": true,
8+
"type": "module",
9+
"bin": {
10+
"vg": "./src/vg.js"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/microsoft/BotFramework-WebChat.git"
15+
},
16+
"bugs": {
17+
"url": "https://github.com/microsoft/BotFramework-WebChat/issues"
18+
},
19+
"files": [
20+
"src/**/*"
21+
],
22+
"homepage": "https://github.com/microsoft/BotFramework-WebChat/tree/main/packages/vibe-grep#readme",
23+
"scripts": {
24+
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
25+
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
26+
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
27+
"eslint": "npm run precommit",
28+
"postversion": "../../scripts/npm/postversion.sh",
29+
"precommit": "../../node_modules/.bin/eslint --report-unused-disable-directives --max-warnings 0",
30+
"preversion": "../../scripts/npm/preversion.sh"
31+
},
32+
"pinDependencies": {},
33+
"localDependencies": {},
34+
"dependencies": {
35+
"@ast-grep/napi": "^0.40.5",
36+
"yaml": "^2.8.2"
37+
}
38+
}

0 commit comments

Comments
 (0)