@kosuke-ai/cli 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +132 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +105 -0
- package/dist/index.js.map +1 -0
- package/dist/kosuke/commands/analyse.d.ts +15 -0
- package/dist/kosuke/commands/analyse.d.ts.map +1 -0
- package/dist/kosuke/commands/analyse.js +308 -0
- package/dist/kosuke/commands/analyse.js.map +1 -0
- package/dist/kosuke/commands/sync-rules.d.ts +8 -0
- package/dist/kosuke/commands/sync-rules.d.ts.map +1 -0
- package/dist/kosuke/commands/sync-rules.js +364 -0
- package/dist/kosuke/commands/sync-rules.js.map +1 -0
- package/dist/kosuke/types.d.ts +31 -0
- package/dist/kosuke/types.d.ts.map +1 -0
- package/dist/kosuke/types.js +5 -0
- package/dist/kosuke/types.js.map +1 -0
- package/dist/kosuke/utils/batch-creator.d.ts +14 -0
- package/dist/kosuke/utils/batch-creator.d.ts.map +1 -0
- package/dist/kosuke/utils/batch-creator.js +76 -0
- package/dist/kosuke/utils/batch-creator.js.map +1 -0
- package/dist/kosuke/utils/file-discovery.d.ts +15 -0
- package/dist/kosuke/utils/file-discovery.d.ts.map +1 -0
- package/dist/kosuke/utils/file-discovery.js +81 -0
- package/dist/kosuke/utils/file-discovery.js.map +1 -0
- package/dist/kosuke/utils/git.d.ts +29 -0
- package/dist/kosuke/utils/git.d.ts.map +1 -0
- package/dist/kosuke/utils/git.js +72 -0
- package/dist/kosuke/utils/git.js.map +1 -0
- package/dist/kosuke/utils/github.d.ts +17 -0
- package/dist/kosuke/utils/github.d.ts.map +1 -0
- package/dist/kosuke/utils/github.js +22 -0
- package/dist/kosuke/utils/github.js.map +1 -0
- package/dist/kosuke/utils/validator.d.ts +22 -0
- package/dist/kosuke/utils/validator.d.ts.map +1 -0
- package/dist/kosuke/utils/validator.js +65 -0
- package/dist/kosuke/utils/validator.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kosuke Org
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Kosuke CLI
|
|
2
|
+
|
|
3
|
+
Development automation tool for syncing rules and analyzing code quality with Claude AI.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install globally via npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @kosuke-ai/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or use with npx (no installation required):
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx @kosuke-ai/cli <command>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
Before using Kosuke CLI, set up the required environment variables:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Required for Claude API access
|
|
25
|
+
export ANTHROPIC_API_KEY="your-api-key-here"
|
|
26
|
+
|
|
27
|
+
# Required for creating pull requests
|
|
28
|
+
export GITHUB_TOKEN="your-github-token-here"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
You can also create a `.env` file in your project root:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
ANTHROPIC_API_KEY=your-api-key-here
|
|
35
|
+
GITHUB_TOKEN=your-github-token-here
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Commands
|
|
39
|
+
|
|
40
|
+
### `kosuke sync-rules`
|
|
41
|
+
|
|
42
|
+
Sync rules and documentation from kosuke-template repository.
|
|
43
|
+
|
|
44
|
+
**Options:**
|
|
45
|
+
- `--force` - Compare files regardless of recent commit history
|
|
46
|
+
|
|
47
|
+
**Examples:**
|
|
48
|
+
```bash
|
|
49
|
+
kosuke sync-rules
|
|
50
|
+
kosuke sync-rules --force
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### `kosuke analyse`
|
|
54
|
+
|
|
55
|
+
Analyze and fix code quality issues against CLAUDE.md rules. Creates a single PR with all fixes from multiple isolated Claude runs.
|
|
56
|
+
|
|
57
|
+
**Options:**
|
|
58
|
+
- `--dry-run` - Report violations only, don't create PR
|
|
59
|
+
- `--scope=<dirs>` - Analyze specific directories (comma-separated)
|
|
60
|
+
- `--types=<exts>` - Analyze specific file types (comma-separated)
|
|
61
|
+
|
|
62
|
+
**Examples:**
|
|
63
|
+
```bash
|
|
64
|
+
# Analyze entire project
|
|
65
|
+
kosuke analyse
|
|
66
|
+
|
|
67
|
+
# Analyze specific directories
|
|
68
|
+
kosuke analyse --scope=hooks,lib/trpc
|
|
69
|
+
|
|
70
|
+
# Analyze specific file types
|
|
71
|
+
kosuke analyse --types=ts,tsx
|
|
72
|
+
|
|
73
|
+
# Dry run (report only)
|
|
74
|
+
kosuke analyse --dry-run
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Configuration
|
|
78
|
+
|
|
79
|
+
### `.kosukeignore`
|
|
80
|
+
|
|
81
|
+
Create a `.kosukeignore` file in your project root to exclude files and directories from analysis. Uses the same syntax as `.gitignore`.
|
|
82
|
+
|
|
83
|
+
Example:
|
|
84
|
+
```
|
|
85
|
+
# Ignore build outputs
|
|
86
|
+
dist/
|
|
87
|
+
build/
|
|
88
|
+
|
|
89
|
+
# Ignore specific files
|
|
90
|
+
*.test.ts
|
|
91
|
+
**/*.spec.ts
|
|
92
|
+
|
|
93
|
+
# Ignore directories
|
|
94
|
+
node_modules/
|
|
95
|
+
.git/
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Development
|
|
99
|
+
|
|
100
|
+
If you want to contribute or run from source:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Clone the repository
|
|
104
|
+
git clone https://github.com/Kosuke-Org/kosuke-cli.git
|
|
105
|
+
cd kosuke-cli
|
|
106
|
+
|
|
107
|
+
# Install dependencies
|
|
108
|
+
npm install
|
|
109
|
+
|
|
110
|
+
# Build the project
|
|
111
|
+
npm run build
|
|
112
|
+
|
|
113
|
+
# Run in development mode
|
|
114
|
+
npm run dev <command>
|
|
115
|
+
|
|
116
|
+
# Link for local testing
|
|
117
|
+
npm link
|
|
118
|
+
kosuke <command>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
ISC
|
|
124
|
+
|
|
125
|
+
## Support
|
|
126
|
+
|
|
127
|
+
- Issues: https://github.com/Kosuke-Org/kosuke-cli/issues
|
|
128
|
+
- Homepage: https://github.com/Kosuke-Org/kosuke-cli
|
|
129
|
+
|
|
130
|
+
## Author
|
|
131
|
+
|
|
132
|
+
filippo.pedrazzini@kosuke.ai
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Kosuke CLI - Development Automation Tool
|
|
4
|
+
*
|
|
5
|
+
* Commands:
|
|
6
|
+
* sync-rules [--force] Sync rules from kosuke-template
|
|
7
|
+
* analyse Analyze and fix code quality issues
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* bun run kosuke sync-rules
|
|
11
|
+
* bun run kosuke analyse
|
|
12
|
+
*
|
|
13
|
+
* Environment Variables:
|
|
14
|
+
* ANTHROPIC_API_KEY - Required for Claude API
|
|
15
|
+
* GITHUB_TOKEN - Required for creating PRs
|
|
16
|
+
*/
|
|
17
|
+
import 'dotenv/config';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Kosuke CLI - Development Automation Tool
|
|
4
|
+
*
|
|
5
|
+
* Commands:
|
|
6
|
+
* sync-rules [--force] Sync rules from kosuke-template
|
|
7
|
+
* analyse Analyze and fix code quality issues
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* bun run kosuke sync-rules
|
|
11
|
+
* bun run kosuke analyse
|
|
12
|
+
*
|
|
13
|
+
* Environment Variables:
|
|
14
|
+
* ANTHROPIC_API_KEY - Required for Claude API
|
|
15
|
+
* GITHUB_TOKEN - Required for creating PRs
|
|
16
|
+
*/
|
|
17
|
+
import 'dotenv/config';
|
|
18
|
+
import { syncRulesCommand } from './kosuke/commands/sync-rules.js';
|
|
19
|
+
import { analyseCommand } from './kosuke/commands/analyse.js';
|
|
20
|
+
async function main() {
|
|
21
|
+
const args = process.argv.slice(2);
|
|
22
|
+
const command = args[0];
|
|
23
|
+
if (!command) {
|
|
24
|
+
showHelp();
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
switch (command) {
|
|
29
|
+
case 'sync-rules': {
|
|
30
|
+
const hasForceFlag = args.includes('--force');
|
|
31
|
+
await syncRulesCommand(hasForceFlag);
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
case 'analyse': {
|
|
35
|
+
const options = {
|
|
36
|
+
dryRun: args.includes('--dry-run'),
|
|
37
|
+
scope: args.find((arg) => arg.startsWith('--scope='))?.split('=')[1],
|
|
38
|
+
types: args
|
|
39
|
+
.find((arg) => arg.startsWith('--types='))
|
|
40
|
+
?.split('=')[1]
|
|
41
|
+
?.split(','),
|
|
42
|
+
};
|
|
43
|
+
await analyseCommand(options);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
default:
|
|
47
|
+
console.error(`ā Unknown command: ${command}\n`);
|
|
48
|
+
showHelp();
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error('\nā Fatal error:', error);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function showHelp() {
|
|
58
|
+
console.log(`
|
|
59
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
60
|
+
ā Kosuke CLI - Development Tools ā
|
|
61
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
62
|
+
|
|
63
|
+
COMMANDS:
|
|
64
|
+
|
|
65
|
+
sync-rules [--force]
|
|
66
|
+
Sync rules and documentation from kosuke-template
|
|
67
|
+
|
|
68
|
+
Options:
|
|
69
|
+
--force Compare files regardless of recent commit history
|
|
70
|
+
|
|
71
|
+
Examples:
|
|
72
|
+
kosuke sync-rules
|
|
73
|
+
kosuke sync-rules --force
|
|
74
|
+
|
|
75
|
+
analyse
|
|
76
|
+
Analyze and fix code quality issues against CLAUDE.md rules
|
|
77
|
+
Creates a single PR with all fixes from multiple isolated Claude runs
|
|
78
|
+
|
|
79
|
+
Options:
|
|
80
|
+
--dry-run Report violations only, don't create PR
|
|
81
|
+
--scope=<dirs> Analyze specific directories (comma-separated)
|
|
82
|
+
--types=<exts> Analyze specific file types (comma-separated)
|
|
83
|
+
|
|
84
|
+
Examples:
|
|
85
|
+
kosuke analyse
|
|
86
|
+
kosuke analyse --scope=hooks,lib/trpc
|
|
87
|
+
kosuke analyse --types=ts,tsx
|
|
88
|
+
kosuke analyse --dry-run
|
|
89
|
+
|
|
90
|
+
ENVIRONMENT VARIABLES:
|
|
91
|
+
|
|
92
|
+
ANTHROPIC_API_KEY Required for Claude API access
|
|
93
|
+
GITHUB_TOKEN Required for creating pull requests
|
|
94
|
+
|
|
95
|
+
CONFIGURATION:
|
|
96
|
+
|
|
97
|
+
.kosukeignore Exclude files/directories from analysis
|
|
98
|
+
(same syntax as .gitignore)
|
|
99
|
+
`);
|
|
100
|
+
}
|
|
101
|
+
main().catch((error) => {
|
|
102
|
+
console.error('Fatal error:', error);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
});
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,KAAK,UAAU,IAAI;IACjB,MAA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AO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;QACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,QAAQ;IACf,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCb,CAAC,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analyse command - Analyze and fix code quality issues
|
|
3
|
+
*
|
|
4
|
+
* Strategy: Single PR with multiple isolated Claude runs
|
|
5
|
+
* - Each batch of 10-12 files gets its own Claude run
|
|
6
|
+
* - Claude only sees those specific files (no repository-wide context)
|
|
7
|
+
* - Validate after each batch, commit locally
|
|
8
|
+
* - Push all commits at once and create single PR
|
|
9
|
+
*/
|
|
10
|
+
import type { AnalyseOptions } from '../types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Main analyse command
|
|
13
|
+
*/
|
|
14
|
+
export declare function analyseCommand(options?: AnalyseOptions): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=analyse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyse.d.ts","sourceRoot":"","sources":["../../../kosuke/commands/analyse.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,aAAa,CAAC;AA4O9D;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoHhF"}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analyse command - Analyze and fix code quality issues
|
|
3
|
+
*
|
|
4
|
+
* Strategy: Single PR with multiple isolated Claude runs
|
|
5
|
+
* - Each batch of 10-12 files gets its own Claude run
|
|
6
|
+
* - Claude only sees those specific files (no repository-wide context)
|
|
7
|
+
* - Validate after each batch, commit locally
|
|
8
|
+
* - Push all commits at once and create single PR
|
|
9
|
+
*/
|
|
10
|
+
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
11
|
+
import simpleGit from 'simple-git';
|
|
12
|
+
import { readFileSync } from 'fs';
|
|
13
|
+
import { join } from 'path';
|
|
14
|
+
import { discoverFiles } from '../utils/file-discovery.js';
|
|
15
|
+
import { createBatches } from '../utils/batch-creator.js';
|
|
16
|
+
import { runLint, runTypecheck } from '../utils/validator.js';
|
|
17
|
+
import { createBranch, commit, push, reset, getCurrentRepo } from '../utils/git.js';
|
|
18
|
+
import { createPullRequest } from '../utils/github.js';
|
|
19
|
+
/**
|
|
20
|
+
* Calculate cost based on Claude Sonnet 4.5 pricing
|
|
21
|
+
* $3 per million input tokens, $15 per million output tokens
|
|
22
|
+
*/
|
|
23
|
+
function calculateCost(inputTokens, outputTokens) {
|
|
24
|
+
const INPUT_COST_PER_MILLION = 3.0;
|
|
25
|
+
const OUTPUT_COST_PER_MILLION = 15.0;
|
|
26
|
+
const inputCost = (inputTokens / 1000000) * INPUT_COST_PER_MILLION;
|
|
27
|
+
const outputCost = (outputTokens / 1000000) * OUTPUT_COST_PER_MILLION;
|
|
28
|
+
return inputCost + outputCost;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Run Claude analysis on a single batch
|
|
32
|
+
*/
|
|
33
|
+
async function analyzeBatch(batch, _claudeMdRules) {
|
|
34
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
35
|
+
console.log(`š Analyzing: ${batch.name}`);
|
|
36
|
+
console.log(` Files: ${batch.files.join(', ')}`);
|
|
37
|
+
console.log(`${'='.repeat(60)}\n`);
|
|
38
|
+
const workspaceRoot = process.cwd();
|
|
39
|
+
// System prompt: Just point to CLAUDE.md
|
|
40
|
+
const systemPrompt = `You are a code quality analyzer for this repository.
|
|
41
|
+
|
|
42
|
+
Your task is to analyze specific files for code quality issues and fix them according to the rules in CLAUDE.md.
|
|
43
|
+
|
|
44
|
+
IMPORTANT: You will ONLY be given access to a specific batch of files. Do NOT explore the entire repository.
|
|
45
|
+
|
|
46
|
+
The rules you must follow are provided in CLAUDE.md.`;
|
|
47
|
+
// User prompt: Simple and direct
|
|
48
|
+
const promptText = `Analyze these ${batch.files.length} files for code quality issues:
|
|
49
|
+
|
|
50
|
+
${batch.files.map((f) => `- ${f}`).join('\n')}
|
|
51
|
+
|
|
52
|
+
**Your task:**
|
|
53
|
+
1. Read CLAUDE.md to understand all the rules and best practices
|
|
54
|
+
2. Read ONLY the files listed above (these are the files in this batch)
|
|
55
|
+
3. Check each file against the CLAUDE.md rules
|
|
56
|
+
4. Fix any violations you find
|
|
57
|
+
5. Do NOT explore or modify other files outside this batch
|
|
58
|
+
|
|
59
|
+
**Rules reference:** ${join(workspaceRoot, 'CLAUDE.md')}
|
|
60
|
+
|
|
61
|
+
Start by reading CLAUDE.md, then analyze the batch files.`;
|
|
62
|
+
const options = {
|
|
63
|
+
model: 'claude-sonnet-4-5',
|
|
64
|
+
systemPrompt,
|
|
65
|
+
maxTurns: 15,
|
|
66
|
+
cwd: workspaceRoot,
|
|
67
|
+
permissionMode: 'bypassPermissions',
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
const responseStream = query({ prompt: promptText, options });
|
|
71
|
+
let fixCount = 0;
|
|
72
|
+
let inputTokens = 0;
|
|
73
|
+
let outputTokens = 0;
|
|
74
|
+
// Display Claude's reasoning and actions
|
|
75
|
+
for await (const message of responseStream) {
|
|
76
|
+
if (message.type === 'assistant') {
|
|
77
|
+
const content = message.message.content;
|
|
78
|
+
for (const block of content) {
|
|
79
|
+
if (block.type === 'text' && block.text.trim()) {
|
|
80
|
+
// Only show key insights, not every detail
|
|
81
|
+
const text = block.text.trim();
|
|
82
|
+
if (text.includes('violation') ||
|
|
83
|
+
text.includes('fix') ||
|
|
84
|
+
text.includes('issue') ||
|
|
85
|
+
text.includes('ā
') ||
|
|
86
|
+
text.includes('ā')) {
|
|
87
|
+
console.log(` š ${text}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (block.type === 'tool_use') {
|
|
91
|
+
if (block.name === 'write' || block.name === 'search_replace') {
|
|
92
|
+
fixCount++;
|
|
93
|
+
console.log(` š§ Applying fix ${fixCount}...`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Track token usage from the response
|
|
99
|
+
if (message.type === 'result' && message.subtype === 'success') {
|
|
100
|
+
inputTokens += message.usage.input_tokens || 0;
|
|
101
|
+
outputTokens += message.usage.output_tokens || 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Calculate cost for this batch
|
|
105
|
+
const cost = calculateCost(inputTokens, outputTokens);
|
|
106
|
+
// Return placeholder fixes (real fix tracking would require parsing Claude's edits)
|
|
107
|
+
const fixes = batch.files.map((file) => ({
|
|
108
|
+
file,
|
|
109
|
+
type: 'other',
|
|
110
|
+
description: 'Quality improvements',
|
|
111
|
+
linesChanged: 0,
|
|
112
|
+
}));
|
|
113
|
+
console.log(`\n ⨠Batch analysis complete (${fixCount} fixes applied)`);
|
|
114
|
+
console.log(` š° Cost: $${cost.toFixed(4)} (${inputTokens.toLocaleString()} input + ${outputTokens.toLocaleString()} output tokens)`);
|
|
115
|
+
return {
|
|
116
|
+
fixes: fixCount > 0 ? fixes : [],
|
|
117
|
+
inputTokens,
|
|
118
|
+
outputTokens,
|
|
119
|
+
cost,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
console.error(`\n ā Error analyzing batch:`, error);
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Validate fixes with lint and typecheck
|
|
129
|
+
*/
|
|
130
|
+
async function validateBatch() {
|
|
131
|
+
console.log(` š§ Running validation...`);
|
|
132
|
+
const lintResult = await runLint();
|
|
133
|
+
if (!lintResult.success) {
|
|
134
|
+
console.error(` ā Linting failed:\n${lintResult.error}`);
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
console.log(` ā
Lint passed`);
|
|
138
|
+
const typecheckResult = await runTypecheck();
|
|
139
|
+
if (!typecheckResult.success) {
|
|
140
|
+
console.error(` ā Type checking failed:\n${typecheckResult.error}`);
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
console.log(` ā
Typecheck passed`);
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Create quality fixes PR
|
|
148
|
+
*/
|
|
149
|
+
async function createQualityPR(batches, totalFixes, totalCost, totalInputTokens, totalOutputTokens) {
|
|
150
|
+
const { owner, repo } = await getCurrentRepo();
|
|
151
|
+
const date = new Date().toISOString().split('T')[0];
|
|
152
|
+
// Categorize by directory for summary
|
|
153
|
+
const dirSummary = batches.reduce((acc, batch) => {
|
|
154
|
+
acc[batch.name] = (acc[batch.name] || 0) + batch.files.length;
|
|
155
|
+
return acc;
|
|
156
|
+
}, {});
|
|
157
|
+
const prBody = `## š§ Automated Quality Fixes
|
|
158
|
+
|
|
159
|
+
This PR contains automated fixes to align the codebase with **CLAUDE.md** standards.
|
|
160
|
+
|
|
161
|
+
### š Summary
|
|
162
|
+
- **Batches Processed**: ${batches.length}
|
|
163
|
+
- **Files Modified**: ${batches.reduce((sum, b) => sum + b.files.length, 0)}
|
|
164
|
+
- **Fixes Applied**: ${totalFixes}
|
|
165
|
+
- **š° Estimated Cost**: $${totalCost.toFixed(4)}
|
|
166
|
+
- Input tokens: ${totalInputTokens.toLocaleString()}
|
|
167
|
+
- Output tokens: ${totalOutputTokens.toLocaleString()}
|
|
168
|
+
- Model: Claude Sonnet 4.5 ($3/M input, $15/M output)
|
|
169
|
+
|
|
170
|
+
### š¦ Batches
|
|
171
|
+
|
|
172
|
+
${Object.entries(dirSummary)
|
|
173
|
+
.map(([dir, count]) => `- **${dir}**: ${count} files`)
|
|
174
|
+
.join('\n')}
|
|
175
|
+
|
|
176
|
+
### ā
Validation
|
|
177
|
+
- Linting: **PASSED**
|
|
178
|
+
- Type checking: **PASSED**
|
|
179
|
+
|
|
180
|
+
### šÆ Fix Categories
|
|
181
|
+
|
|
182
|
+
All fixes follow the comprehensive rules in CLAUDE.md, including:
|
|
183
|
+
- ā
Type inference from tRPC routers
|
|
184
|
+
- ā
Centralized type management
|
|
185
|
+
- ā
Navigation patterns (Link vs Button)
|
|
186
|
+
- ā
Loading states (Skeleton components)
|
|
187
|
+
- ā
Component colocation
|
|
188
|
+
- ā
Server-side filtering
|
|
189
|
+
- ā
Python code quality (if applicable)
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
š¤ *Generated by Kosuke CLI (\`bun run kosuke analyse\`)*
|
|
194
|
+
`;
|
|
195
|
+
// Get current branch name from git
|
|
196
|
+
const git = simpleGit();
|
|
197
|
+
const currentBranch = await git.revparse(['--abbrev-ref', 'HEAD']);
|
|
198
|
+
const prUrl = await createPullRequest({
|
|
199
|
+
owner,
|
|
200
|
+
repo,
|
|
201
|
+
title: `chore: Quality Fixes (${date})`,
|
|
202
|
+
head: currentBranch.trim(),
|
|
203
|
+
base: 'main',
|
|
204
|
+
body: prBody,
|
|
205
|
+
});
|
|
206
|
+
console.log(`ā
Pull request created: ${prUrl}`);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Main analyse command
|
|
210
|
+
*/
|
|
211
|
+
export async function analyseCommand(options = {}) {
|
|
212
|
+
console.log('š Starting Kosuke Quality Analysis...\n');
|
|
213
|
+
try {
|
|
214
|
+
// Validate environment
|
|
215
|
+
if (!process.env.ANTHROPIC_API_KEY) {
|
|
216
|
+
throw new Error('ANTHROPIC_API_KEY environment variable is required');
|
|
217
|
+
}
|
|
218
|
+
if (!process.env.GITHUB_TOKEN) {
|
|
219
|
+
throw new Error('GITHUB_TOKEN environment variable is required');
|
|
220
|
+
}
|
|
221
|
+
// Load CLAUDE.md rules
|
|
222
|
+
const claudeMdPath = join(process.cwd(), 'CLAUDE.md');
|
|
223
|
+
const claudeMdRules = readFileSync(claudeMdPath, 'utf-8');
|
|
224
|
+
console.log('š Loaded CLAUDE.md rules\n');
|
|
225
|
+
// Discover files
|
|
226
|
+
console.log('š Discovering files...');
|
|
227
|
+
const files = await discoverFiles({
|
|
228
|
+
scope: options.scope,
|
|
229
|
+
types: options.types,
|
|
230
|
+
});
|
|
231
|
+
console.log(`š Found ${files.length} files to analyze\n`);
|
|
232
|
+
if (files.length === 0) {
|
|
233
|
+
console.log('ā¹ļø No files found to analyze.');
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
// Create batches (10-12 files each, grouped by directory)
|
|
237
|
+
const batches = createBatches(files, { maxSize: 10, groupBy: 'directory' });
|
|
238
|
+
console.log(`š¦ Created ${batches.length} batches\n`);
|
|
239
|
+
// Dry run: just analyze and report
|
|
240
|
+
if (options.dryRun) {
|
|
241
|
+
console.log('š DRY RUN MODE: Analyzing without creating PR...\n');
|
|
242
|
+
for (const [index, batch] of batches.entries()) {
|
|
243
|
+
console.log(`\nBatch ${index + 1}/${batches.length}: ${batch.name}`);
|
|
244
|
+
console.log(`Files: ${batch.files.join(', ')}`);
|
|
245
|
+
}
|
|
246
|
+
console.log('\nā
Dry run complete. Use without --dry-run to create PR.');
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
// Create working branch with unique name
|
|
250
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').split('.')[0];
|
|
251
|
+
const branchName = `quality/kosuke-analysis-${timestamp}`;
|
|
252
|
+
console.log(`šæ Creating branch: ${branchName}\n`);
|
|
253
|
+
await createBranch(branchName);
|
|
254
|
+
// Process each batch with isolated Claude run
|
|
255
|
+
const processedBatches = [];
|
|
256
|
+
let totalFixes = 0;
|
|
257
|
+
let totalCost = 0;
|
|
258
|
+
let totalInputTokens = 0;
|
|
259
|
+
let totalOutputTokens = 0;
|
|
260
|
+
for (const [index, batch] of batches.entries()) {
|
|
261
|
+
console.log(`\nš Progress: ${index + 1}/${batches.length}`);
|
|
262
|
+
// Analyze batch (isolated Claude run)
|
|
263
|
+
const result = await analyzeBatch(batch, claudeMdRules);
|
|
264
|
+
if (result.fixes.length > 0) {
|
|
265
|
+
// Validate changes
|
|
266
|
+
const isValid = await validateBatch();
|
|
267
|
+
if (isValid) {
|
|
268
|
+
// Commit batch
|
|
269
|
+
await commit(`fix(quality): ${batch.name} - ${result.fixes.length} improvements`);
|
|
270
|
+
console.log(` ā
Batch committed\n`);
|
|
271
|
+
processedBatches.push(batch);
|
|
272
|
+
totalFixes += result.fixes.length;
|
|
273
|
+
totalCost += result.cost;
|
|
274
|
+
totalInputTokens += result.inputTokens;
|
|
275
|
+
totalOutputTokens += result.outputTokens;
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
// Validation failed, rollback
|
|
279
|
+
console.warn(` ā ļø Validation failed, rolling back batch\n`);
|
|
280
|
+
await reset();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
console.log(` ā¹ļø No fixes needed for this batch\n`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (processedBatches.length === 0) {
|
|
288
|
+
console.log('ā
No fixes needed! Codebase is already compliant.\n');
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
// Push all commits
|
|
292
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
293
|
+
console.log('š¤ Pushing all commits...\n');
|
|
294
|
+
await push(branchName);
|
|
295
|
+
// Create PR
|
|
296
|
+
console.log('š Creating pull request...\n');
|
|
297
|
+
await createQualityPR(processedBatches, totalFixes, totalCost, totalInputTokens, totalOutputTokens);
|
|
298
|
+
console.log('\nā
Quality analysis complete!');
|
|
299
|
+
console.log(`š Processed ${processedBatches.length}/${batches.length} batches`);
|
|
300
|
+
console.log(`š§ Applied ${totalFixes} fixes`);
|
|
301
|
+
console.log(`š° Total cost: $${totalCost.toFixed(4)}`);
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
console.error('\nā Analysis failed:', error);
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=analyse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyse.js","sourceRoot":"","sources":["../../../kosuke/commands/analyse.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAgB,MAAM,gCAAgC,CAAC;AACrE,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAUvD;;;GAGG;AACH,SAAS,aAAa,CAAC,WAAmB,EAAE,YAAoB;IAC9D,MAAM,sBAAsB,GAAG,GAAG,CAAC;IACnC,MAAM,uBAAuB,GAAG,IAAI,CAAC;IAErC,MAAM,SAAS,GAAG,CAAC,WAAW,GAAG,OAAS,CAAC,GAAG,sBAAsB,CAAC;IACrE,MAAM,UAAU,GAAG,CAAC,YAAY,GAAG,OAAS,CAAC,GAAG,uBAAuB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