Skip to content

Commit e4c4594

Browse files
committed
feat: add Biome for lint and format checks
- Install @biomejs/biome as devDependency - Add biome.json with project-appropriate rules - Add lint, lint:fix, and format scripts to package.json - Add lint step to CI workflow - Auto-fix existing code to pass biome checks Closes NianJiuZst#25
1 parent 42a8661 commit e4c4594

97 files changed

Lines changed: 19133 additions & 16801 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
- name: Install dependencies
2222
run: bun install --frozen-lockfile
2323

24+
- name: Lint and format check
25+
run: bunx biome check
26+
2427
- name: Typecheck
2528
run: bunx tsc --noEmit
2629

biome.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": true,
10+
"includes": ["src/**/*.ts", "test/**/*.ts"]
11+
},
12+
"formatter": {
13+
"enabled": true,
14+
"indentStyle": "tab",
15+
"lineWidth": 100
16+
},
17+
"linter": {
18+
"enabled": true,
19+
"rules": {
20+
"recommended": true,
21+
"suspicious": {
22+
"noExplicitAny": "warn",
23+
"noControlCharactersInRegex": "off"
24+
},
25+
"style": {
26+
"noNonNullAssertion": "warn",
27+
"useNodejsImportProtocol": "off"
28+
},
29+
"complexity": {
30+
"useLiteralKeys": "off",
31+
"noStaticOnlyClass": "off"
32+
}
33+
}
34+
},
35+
"javascript": {
36+
"formatter": {
37+
"quoteStyle": "single",
38+
"semicolons": "always"
39+
}
40+
},
41+
"assist": {
42+
"enabled": true,
43+
"actions": {
44+
"source": {
45+
"organizeImports": "on"
46+
}
47+
}
48+
}
49+
}

bun.lock

Lines changed: 19 additions & 0 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@
1515
"dev": "bun run ./src/cli.ts",
1616
"start": "bun run ./src/cli.ts",
1717
"typecheck": "tsgo --noEmit",
18-
"test": "bun test"
18+
"test": "bun test",
19+
"lint": "bunx biome check",
20+
"lint:fix": "bunx biome check --write",
21+
"format": "bunx biome format --write"
1922
},
2023
"devDependencies": {
24+
"@biomejs/biome": "^2.4.16",
2125
"@types/bun": "latest",
2226
"@types/crypto-js": "^4.2.2",
2327
"@typescript/native-preview": "^7.0.0-dev"

src/cli.ts

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,63 @@
11
#!/usr/bin/env bun
22
import { Command } from 'commander';
33
import {
4-
registerAgentCommand,
5-
registerAnalyzeCommand,
6-
registerAutomationCommand,
7-
registerConfigCommand,
8-
registerDailyCommand,
9-
registerDoctorCommand,
10-
registerInboxCommand,
11-
registerInitCommand,
12-
registerPowCommand,
13-
registerProviderCommand,
14-
registerRunsCommand,
15-
registerScoutCommand,
4+
registerAgentCommand,
5+
registerAnalyzeCommand,
6+
registerAutomationCommand,
7+
registerConfigCommand,
8+
registerDailyCommand,
9+
registerDoctorCommand,
10+
registerInboxCommand,
11+
registerInitCommand,
12+
registerPowCommand,
13+
registerProviderCommand,
14+
registerRunsCommand,
15+
registerScoutCommand,
1616
} from './commands/index.js';
1717
import { getErrorMessage, ui } from './infra/index.js';
1818

1919
const VERSION = '1.0.0';
2020

2121
async function main(): Promise<void> {
22-
const program = new Command();
23-
24-
program
25-
.name('openmeta')
26-
.description("OpenMeta CLI - Developer's daily open source growth companion")
27-
.version(VERSION, '-v, --version', 'Show version')
28-
.helpOption('-h, --help', 'Show help')
29-
.showSuggestionAfterError()
30-
.showHelpAfterError();
31-
32-
registerInitCommand(program);
33-
registerAgentCommand(program);
34-
registerAnalyzeCommand(program);
35-
registerDailyCommand(program);
36-
registerScoutCommand(program);
37-
registerInboxCommand(program);
38-
registerPowCommand(program);
39-
registerConfigCommand(program);
40-
registerProviderCommand(program);
41-
registerAutomationCommand(program);
42-
registerDoctorCommand(program);
43-
registerRunsCommand(program);
44-
45-
program.on('command:*', () => {
46-
ui.commandFailed('openmeta', `Unknown command "${program.args.join(' ')}". Run "openmeta --help" to see available commands.`);
47-
process.exit(1);
48-
});
49-
50-
if (process.argv.length === 2) {
51-
program.help();
52-
}
53-
54-
await program.parseAsync(process.argv);
22+
const program = new Command();
23+
24+
program
25+
.name('openmeta')
26+
.description("OpenMeta CLI - Developer's daily open source growth companion")
27+
.version(VERSION, '-v, --version', 'Show version')
28+
.helpOption('-h, --help', 'Show help')
29+
.showSuggestionAfterError()
30+
.showHelpAfterError();
31+
32+
registerInitCommand(program);
33+
registerAgentCommand(program);
34+
registerAnalyzeCommand(program);
35+
registerDailyCommand(program);
36+
registerScoutCommand(program);
37+
registerInboxCommand(program);
38+
registerPowCommand(program);
39+
registerConfigCommand(program);
40+
registerProviderCommand(program);
41+
registerAutomationCommand(program);
42+
registerDoctorCommand(program);
43+
registerRunsCommand(program);
44+
45+
program.on('command:*', () => {
46+
ui.commandFailed(
47+
'openmeta',
48+
`Unknown command "${program.args.join(' ')}". Run "openmeta --help" to see available commands.`,
49+
);
50+
process.exit(1);
51+
});
52+
53+
if (process.argv.length === 2) {
54+
program.help();
55+
}
56+
57+
await program.parseAsync(process.argv);
5558
}
5659

5760
main().catch((error) => {
58-
ui.commandFailed('openmeta', getErrorMessage(error));
59-
process.exit(1);
61+
ui.commandFailed('openmeta', getErrorMessage(error));
62+
process.exit(1);
6063
});

src/commands/agent.ts

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,50 @@
1-
import { Command, Option } from 'commander';
1+
import { type Command, Option } from 'commander';
22
import { agentOrchestrator } from '../orchestration/index.js';
33
import { runCommand } from './run-command.js';
44

55
export function registerAgentCommand(program: Command): void {
6-
program
7-
.command('agent')
8-
.description('Run the autonomous contribution agent workflow')
9-
.option('--headless', 'Run unattended using saved automation defaults')
10-
.option('--force', 'Reserved for compatibility with scheduled runs')
11-
.option('--run-checks', 'Execute detected baseline validation commands')
12-
.option('--draft-only', 'Generate dossier and PR draft artifacts without applying file edits or opening a PR')
13-
.option('--refresh', 'Ignore cached GitHub issue discovery results')
14-
.option('--repo <repository>', 'Limit issue discovery to one GitHub repository URL or owner/name')
15-
.option('--issue <issue>', 'Solve one GitHub issue number or issue URL')
16-
.option('--dry-run', 'Preview artifacts without writing to git')
17-
.addOption(new Option('--scheduler-run', 'Internal flag for scheduled automation').hideHelp())
18-
.action((options: { headless?: boolean; force?: boolean; runChecks?: boolean; draftOnly?: boolean; refresh?: boolean; repo?: string; issue?: string; dryRun?: boolean; schedulerRun?: boolean }) => runCommand(
19-
'OpenMeta Agent',
20-
() => agentOrchestrator.run({
21-
headless: options.headless,
22-
force: options.force,
23-
runChecks: options.runChecks,
24-
draftOnly: options.draftOnly,
25-
refresh: options.refresh,
26-
repo: options.repo,
27-
issue: options.issue,
28-
dryRun: options.dryRun,
29-
schedulerRun: options.schedulerRun,
30-
}),
31-
));
6+
program
7+
.command('agent')
8+
.description('Run the autonomous contribution agent workflow')
9+
.option('--headless', 'Run unattended using saved automation defaults')
10+
.option('--force', 'Reserved for compatibility with scheduled runs')
11+
.option('--run-checks', 'Execute detected baseline validation commands')
12+
.option(
13+
'--draft-only',
14+
'Generate dossier and PR draft artifacts without applying file edits or opening a PR',
15+
)
16+
.option('--refresh', 'Ignore cached GitHub issue discovery results')
17+
.option(
18+
'--repo <repository>',
19+
'Limit issue discovery to one GitHub repository URL or owner/name',
20+
)
21+
.option('--issue <issue>', 'Solve one GitHub issue number or issue URL')
22+
.option('--dry-run', 'Preview artifacts without writing to git')
23+
.addOption(new Option('--scheduler-run', 'Internal flag for scheduled automation').hideHelp())
24+
.action(
25+
(options: {
26+
headless?: boolean;
27+
force?: boolean;
28+
runChecks?: boolean;
29+
draftOnly?: boolean;
30+
refresh?: boolean;
31+
repo?: string;
32+
issue?: string;
33+
dryRun?: boolean;
34+
schedulerRun?: boolean;
35+
}) =>
36+
runCommand('OpenMeta Agent', () =>
37+
agentOrchestrator.run({
38+
headless: options.headless,
39+
force: options.force,
40+
runChecks: options.runChecks,
41+
draftOnly: options.draftOnly,
42+
refresh: options.refresh,
43+
repo: options.repo,
44+
issue: options.issue,
45+
dryRun: options.dryRun,
46+
schedulerRun: options.schedulerRun,
47+
}),
48+
),
49+
);
3250
}

src/commands/analyze.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
1-
import { Command } from 'commander';
1+
import type { Command } from 'commander';
22
import { analyzeOrchestrator } from '../orchestration/index.js';
33
import { runCommand } from './run-command.js';
44

55
export function registerAnalyzeCommand(program: Command): void {
6-
program
7-
.command('analyze')
8-
.description('Analyze a repository and draft contribution suggestions without relying on existing issues')
9-
.requiredOption('--repo <repository>', 'GitHub repository URL or owner/name to analyze')
10-
.option('--headless', 'Select the highest-scoring suggestion without prompting')
11-
.option('--run-checks', 'Execute detected baseline validation commands during workspace preparation')
12-
.option('--dry-run', 'Preview artifact paths without writing local analysis files')
13-
.action((options: { repo?: string; headless?: boolean; runChecks?: boolean; dryRun?: boolean }) => runCommand(
14-
'OpenMeta Analyze',
15-
() => analyzeOrchestrator.run({
16-
repo: options.repo,
17-
headless: options.headless,
18-
runChecks: options.runChecks,
19-
dryRun: options.dryRun,
20-
}),
21-
));
6+
program
7+
.command('analyze')
8+
.description(
9+
'Analyze a repository and draft contribution suggestions without relying on existing issues',
10+
)
11+
.requiredOption('--repo <repository>', 'GitHub repository URL or owner/name to analyze')
12+
.option('--headless', 'Select the highest-scoring suggestion without prompting')
13+
.option(
14+
'--run-checks',
15+
'Execute detected baseline validation commands during workspace preparation',
16+
)
17+
.option('--dry-run', 'Preview artifact paths without writing local analysis files')
18+
.action(
19+
(options: { repo?: string; headless?: boolean; runChecks?: boolean; dryRun?: boolean }) =>
20+
runCommand('OpenMeta Analyze', () =>
21+
analyzeOrchestrator.run({
22+
repo: options.repo,
23+
headless: options.headless,
24+
runChecks: options.runChecks,
25+
dryRun: options.dryRun,
26+
}),
27+
),
28+
);
2229
}

src/commands/automation.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import { Command } from 'commander';
1+
import type { Command } from 'commander';
22
import { automationOrchestrator } from '../orchestration/index.js';
33
import { runCommand } from './run-command.js';
44

55
export function registerAutomationCommand(program: Command): void {
6-
const automation = program
7-
.command('automation')
8-
.description('Manage unattended daily automation');
6+
const automation = program
7+
.command('automation')
8+
.description('Manage unattended daily automation');
99

10-
automation
11-
.command('status')
12-
.description('Show automation status')
13-
.action(() => runCommand('OpenMeta Automation', () => automationOrchestrator.status()));
10+
automation
11+
.command('status')
12+
.description('Show automation status')
13+
.action(() => runCommand('OpenMeta Automation', () => automationOrchestrator.status()));
1414

15-
automation
16-
.command('enable')
17-
.description('Enable unattended daily automation using saved settings')
18-
.action(() => runCommand('OpenMeta Automation', () => automationOrchestrator.enable()));
15+
automation
16+
.command('enable')
17+
.description('Enable unattended daily automation using saved settings')
18+
.action(() => runCommand('OpenMeta Automation', () => automationOrchestrator.enable()));
1919

20-
automation
21-
.command('disable')
22-
.description('Disable unattended daily automation and remove the system scheduler')
23-
.action(() => runCommand('OpenMeta Automation', () => automationOrchestrator.disable()));
20+
automation
21+
.command('disable')
22+
.description('Disable unattended daily automation and remove the system scheduler')
23+
.action(() => runCommand('OpenMeta Automation', () => automationOrchestrator.disable()));
2424
}

0 commit comments

Comments
 (0)