@sriram-rach/clavis 1.0.0
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 +109 -0
- package/bin/cli.js +53 -0
- package/hook/statusline.js +67 -0
- package/package.json +36 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Sriram Rachamadugu
|
|
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,109 @@
|
|
|
1
|
+
```
|
|
2
|
+
___ ___ ___ ___ ___
|
|
3
|
+
/\ \ /\__\ /\ \ /\__\ ___ /\ \
|
|
4
|
+
/::\ \ /:/ / /::\ \ /:/ / /\ \ /::\ \
|
|
5
|
+
/:/\:\ \ /:/ / /:/\:\ \ /:/ / \:\ \ /:/\ \ \
|
|
6
|
+
/:/ \:\ \ /:/ / /::\~\:\ \ /:/__/ ___ /::\__\ _\:\~\ \ \
|
|
7
|
+
/:/__/ \:\__\ /:/__/ /:/\:\ \:\__\ |:| | /\__\ __/:/\/__/ /\ \:\ \ \__\
|
|
8
|
+
\:\ \ \/__/ \:\ \ \/__\:\/:/ / |:| |/:/ / /\/:/ / \:\ \:\ \/__/
|
|
9
|
+
\:\ \ \:\ \ \::/ / |:|__/:/ / \::/__/ \:\ \:\__\
|
|
10
|
+
\:\ \ \:\ \ /:/ / \::::/__/ \:\__\ \:\/:/ /
|
|
11
|
+
\:\__\ \:\__\ /:/ / ~~~~ \/__/ \::/ /
|
|
12
|
+
\/__/ \/__/ \/__/ \/__/
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
# clavis
|
|
16
|
+
|
|
17
|
+
> Powerful enhancements for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) — unlock the full potential of your AI coding assistant.
|
|
18
|
+
|
|
19
|
+
[](https://www.npmjs.com/package/clavis)
|
|
20
|
+
[](https://github.com/sriram-rachamadugu/clavis/blob/main/LICENSE)
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
### One-time use (no install needed)
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx clavis
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Global install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install -g clavis
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Then run `clavis` in any repo.
|
|
37
|
+
|
|
38
|
+
### Local install (per-project)
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install --save-dev clavis
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Then run via npx or add it to your npm scripts:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"scripts": {
|
|
49
|
+
"setup-claude": "clavis"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Features
|
|
55
|
+
|
|
56
|
+
### Context Usage Statusline
|
|
57
|
+
|
|
58
|
+
A real-time statusline that keeps you informed while Claude works:
|
|
59
|
+
|
|
60
|
+
- **Model** — which Claude model is active
|
|
61
|
+
- **Current task** — the in-progress task from your todo list
|
|
62
|
+
- **Directory** — current working directory
|
|
63
|
+
- **Context usage** — a 10-segment progress bar with color coding
|
|
64
|
+
|
|
65
|
+
#### Context bar colors
|
|
66
|
+
|
|
67
|
+
| Usage | Color |
|
|
68
|
+
|---------|------------------|
|
|
69
|
+
| < 50% | Green |
|
|
70
|
+
| 50–65% | Yellow |
|
|
71
|
+
| 65–80% | Orange |
|
|
72
|
+
| > 80% | Red (blinking) |
|
|
73
|
+
|
|
74
|
+
*More features coming soon.*
|
|
75
|
+
|
|
76
|
+
## How It Works
|
|
77
|
+
|
|
78
|
+
Running `npx clavis` in your repo root will:
|
|
79
|
+
|
|
80
|
+
1. Create `.claude/hooks/statusline.js` — the statusline hook
|
|
81
|
+
2. Add a `statusLine` entry to `.claude/settings.json` — tells Claude Code to use it
|
|
82
|
+
|
|
83
|
+
It's idempotent — running it again skips the settings update if already configured.
|
|
84
|
+
|
|
85
|
+
## Uninstall
|
|
86
|
+
|
|
87
|
+
Delete the hook and remove the settings entry:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
rm .claude/hooks/statusline.js
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Then remove the `"statusLine"` key from `.claude/settings.json`.
|
|
94
|
+
|
|
95
|
+
## Versioning
|
|
96
|
+
|
|
97
|
+
This project follows [Semantic Versioning](https://semver.org/):
|
|
98
|
+
|
|
99
|
+
- **MAJOR** — breaking changes to CLI behavior or hook API
|
|
100
|
+
- **MINOR** — new features (backwards-compatible)
|
|
101
|
+
- **PATCH** — bug fixes and minor improvements
|
|
102
|
+
|
|
103
|
+
## Contributing
|
|
104
|
+
|
|
105
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
[MIT](LICENSE) — see the [LICENSE](LICENSE) file for details.
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Clavis installer — sets up Claude Code context statusline in the current repo
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
const claudeDir = path.join(cwd, '.claude');
|
|
9
|
+
const hooksDir = path.join(claudeDir, 'hooks');
|
|
10
|
+
const hookDest = path.join(hooksDir, 'statusline.js');
|
|
11
|
+
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
12
|
+
|
|
13
|
+
const hookSrc = path.join(__dirname, '..', 'hook', 'statusline.js');
|
|
14
|
+
|
|
15
|
+
const statusLineConfig = {
|
|
16
|
+
type: 'command',
|
|
17
|
+
command: 'node .claude/hooks/statusline.js'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// 1. Ensure .claude/hooks/ exists
|
|
21
|
+
fs.mkdirSync(hooksDir, { recursive: true });
|
|
22
|
+
|
|
23
|
+
// 2. Copy statusline hook
|
|
24
|
+
fs.copyFileSync(hookSrc, hookDest);
|
|
25
|
+
console.log(' Copied statusline hook to .claude/hooks/statusline.js');
|
|
26
|
+
|
|
27
|
+
// 3. Merge statusLine into settings.json
|
|
28
|
+
let settings = {};
|
|
29
|
+
if (fs.existsSync(settingsPath)) {
|
|
30
|
+
try {
|
|
31
|
+
settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
console.log(' Warning: could not parse existing settings.json, creating fresh');
|
|
34
|
+
settings = {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (settings.statusLine) {
|
|
39
|
+
console.log(' statusLine already configured in settings.json — skipped');
|
|
40
|
+
} else {
|
|
41
|
+
settings.statusLine = statusLineConfig;
|
|
42
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
43
|
+
console.log(' Added statusLine config to .claude/settings.json');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 4. Success message
|
|
47
|
+
console.log();
|
|
48
|
+
console.log(' \x1b[32m✓\x1b[0m Clavis installed!');
|
|
49
|
+
console.log();
|
|
50
|
+
console.log(' Preview:');
|
|
51
|
+
console.log(` \x1b[2mClaude Opus 4.6\x1b[0m │ \x1b[2myour-repo\x1b[0m \x1b[32m██░░░░░░░░ 20%\x1b[0m`);
|
|
52
|
+
console.log();
|
|
53
|
+
console.log(' The statusline will appear at the bottom of Claude Code.');
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Clavis — Claude Code context usage statusline
|
|
3
|
+
// Shows: model | current task | directory | context usage bar
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
|
|
9
|
+
let input = '';
|
|
10
|
+
process.stdin.setEncoding('utf8');
|
|
11
|
+
process.stdin.on('data', chunk => input += chunk);
|
|
12
|
+
process.stdin.on('end', () => {
|
|
13
|
+
try {
|
|
14
|
+
const data = JSON.parse(input);
|
|
15
|
+
const model = data.model?.display_name || 'Claude';
|
|
16
|
+
const dir = data.workspace?.current_dir || process.cwd();
|
|
17
|
+
const session = data.session_id || '';
|
|
18
|
+
const remaining = data.context_window?.remaining_percentage;
|
|
19
|
+
|
|
20
|
+
// Context window bar (shows USED percentage)
|
|
21
|
+
let ctx = '';
|
|
22
|
+
if (remaining != null) {
|
|
23
|
+
const used = Math.max(0, Math.min(100, 100 - Math.round(remaining)));
|
|
24
|
+
const filled = Math.floor(used / 10);
|
|
25
|
+
const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(10 - filled);
|
|
26
|
+
|
|
27
|
+
if (used < 50) {
|
|
28
|
+
ctx = ` \x1b[32m${bar} ${used}%\x1b[0m`;
|
|
29
|
+
} else if (used < 65) {
|
|
30
|
+
ctx = ` \x1b[33m${bar} ${used}%\x1b[0m`;
|
|
31
|
+
} else if (used < 80) {
|
|
32
|
+
ctx = ` \x1b[38;5;208m${bar} ${used}%\x1b[0m`;
|
|
33
|
+
} else {
|
|
34
|
+
ctx = ` \x1b[5;31m\uD83D\uDC80 ${bar} ${used}%\x1b[0m`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Current task from todos
|
|
39
|
+
let task = '';
|
|
40
|
+
const homeDir = os.homedir();
|
|
41
|
+
const todosDir = path.join(homeDir, '.claude', 'todos');
|
|
42
|
+
if (session && fs.existsSync(todosDir)) {
|
|
43
|
+
const files = fs.readdirSync(todosDir)
|
|
44
|
+
.filter(f => f.startsWith(session) && f.includes('-agent-') && f.endsWith('.json'))
|
|
45
|
+
.map(f => ({ name: f, mtime: fs.statSync(path.join(todosDir, f)).mtime }))
|
|
46
|
+
.sort((a, b) => b.mtime - a.mtime);
|
|
47
|
+
|
|
48
|
+
if (files.length > 0) {
|
|
49
|
+
try {
|
|
50
|
+
const todos = JSON.parse(fs.readFileSync(path.join(todosDir, files[0].name), 'utf8'));
|
|
51
|
+
const inProgress = todos.find(t => t.status === 'in_progress');
|
|
52
|
+
if (inProgress) task = inProgress.activeForm || '';
|
|
53
|
+
} catch (e) {}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Output
|
|
58
|
+
const dirname = path.basename(dir);
|
|
59
|
+
if (task) {
|
|
60
|
+
process.stdout.write(`\x1b[2m${model}\x1b[0m \u2502 \x1b[1m${task}\x1b[0m \u2502 \x1b[2m${dirname}\x1b[0m${ctx}`);
|
|
61
|
+
} else {
|
|
62
|
+
process.stdout.write(`\x1b[2m${model}\x1b[0m \u2502 \x1b[2m${dirname}\x1b[0m${ctx}`);
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
// Silent fail — don't break statusline on parse errors
|
|
66
|
+
}
|
|
67
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sriram-rach/clavis",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Powerful enhancements for Claude Code — unlock the full potential of your AI coding assistant",
|
|
5
|
+
"bin": {
|
|
6
|
+
"clavis": "./bin/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/",
|
|
10
|
+
"hook/",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"claude",
|
|
15
|
+
"claude-code",
|
|
16
|
+
"statusline",
|
|
17
|
+
"context-window",
|
|
18
|
+
"cli",
|
|
19
|
+
"developer-tools",
|
|
20
|
+
"ai",
|
|
21
|
+
"productivity"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": "Sriram Rachamadugu",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/sriram-rachamadugu/clavis"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/sriram-rachamadugu/clavis/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/sriram-rachamadugu/clavis#readme",
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=16.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|