codeslop 0.1.2 → 0.1.5
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/bin/wasted.js +74 -3
- package/lib/config.js +1 -1
- package/package.json +1 -1
package/bin/wasted.js
CHANGED
|
@@ -6,7 +6,7 @@ import { addEvent, todayStats, allTimeStats, getSessions, startSession, getDaily
|
|
|
6
6
|
import { syncDaily, syncEvent } from '../lib/sync.js';
|
|
7
7
|
import { wasteCost } from '../lib/cost.js';
|
|
8
8
|
import { randomUUID } from 'crypto';
|
|
9
|
-
import { existsSync, statSync, readdirSync } from 'fs';
|
|
9
|
+
import { existsSync, statSync, readdirSync, mkdirSync, writeFileSync } from 'fs';
|
|
10
10
|
import { join } from 'path';
|
|
11
11
|
import { homedir } from 'os';
|
|
12
12
|
|
|
@@ -17,7 +17,7 @@ const fmt = n => n.toLocaleString('en-US');
|
|
|
17
17
|
const bar = (v, max, w=20) => { const f=Math.round((v/Math.max(max,1))*w); return `${R}${'█'.repeat(f)}${D}${'░'.repeat(w-f)}${X}`; };
|
|
18
18
|
|
|
19
19
|
const CMDS = {
|
|
20
|
-
init, log: quickLog, report, today, me, stats, sessions,
|
|
20
|
+
init, setup, log: quickLog, report, today, me, stats, sessions,
|
|
21
21
|
sync, stream, watch, scan, lb: leaderboard, leaderboard,
|
|
22
22
|
cats: showCats, categories: showCats,
|
|
23
23
|
};
|
|
@@ -30,6 +30,7 @@ ${R}${B} codeslop ${X}${D}— tracking every dollar your AI agent lights on fire
|
|
|
30
30
|
|
|
31
31
|
${B}setup${X}
|
|
32
32
|
${G}codeslop init${X} [name] create your profile
|
|
33
|
+
${G}codeslop setup${X} install /slop into your AI client
|
|
33
34
|
${G}codeslop stream${X} off|daily|live set sync mode (default: daily)
|
|
34
35
|
|
|
35
36
|
${B}record${X}
|
|
@@ -97,12 +98,82 @@ async function init() {
|
|
|
97
98
|
${D}config:${X} ~/.wasted/config.json
|
|
98
99
|
|
|
99
100
|
${B}next steps:${X}
|
|
101
|
+
${G}codeslop setup${X} → install /slop into Claude Code & Cursor
|
|
100
102
|
${G}codeslop scan${X} → detect your AI clients
|
|
101
103
|
${G}codeslop log${X} → record waste manually
|
|
102
|
-
${D}or type ${G}/slop${D} in Claude Code to auto-detect waste${X}
|
|
103
104
|
`);
|
|
104
105
|
}
|
|
105
106
|
|
|
107
|
+
async function setup() {
|
|
108
|
+
const home = homedir();
|
|
109
|
+
let installed = [];
|
|
110
|
+
const mode = args[1] || 'all';
|
|
111
|
+
|
|
112
|
+
const SLOP_PROMPT = `Scan this conversation for AI token waste. Look for these patterns:
|
|
113
|
+
|
|
114
|
+
- Yapping: excessive output nobody asked for (output/input ratio > 20:1)
|
|
115
|
+
- Groundhog Day: same tool called 3+ times with similar args
|
|
116
|
+
- Ghost Agent: sub-agent spawned that produced nothing useful
|
|
117
|
+
- Prompt Salad: vague prompt caused the model to guess
|
|
118
|
+
- Tool Spam: tool calls that errored or went unused
|
|
119
|
+
- Context Stuffing: large file reads where under 10% was used
|
|
120
|
+
- Hallucination: model produced incorrect output that needed correction
|
|
121
|
+
- Ping Pong: 3+ turns with no file changes or progress
|
|
122
|
+
- Skill Issue: skill/tool invocation errored or was discarded
|
|
123
|
+
- Overthink: solution far more complex than needed
|
|
124
|
+
|
|
125
|
+
For each pattern found, estimate the wasted tokens and report using:
|
|
126
|
+
codeslop report <category> <tokens> <model> <client>
|
|
127
|
+
|
|
128
|
+
Example: codeslop report yapping 1200 claude-opus-4-6 claude-code
|
|
129
|
+
|
|
130
|
+
Show a brief waste report with total tokens wasted, estimated cost, and a funny verdict.
|
|
131
|
+
Be funny but not mean. Roast the waste, not the person.`;
|
|
132
|
+
|
|
133
|
+
console.log(`\n ${B}codeslop setup${X} ${D}— installing waste detector into your AI clients${X}\n`);
|
|
134
|
+
|
|
135
|
+
// Claude Code: global commands at ~/.claude/commands/slop.md
|
|
136
|
+
if (mode === 'all' || mode === 'claude') {
|
|
137
|
+
const claudeDir = join(home, '.claude', 'commands');
|
|
138
|
+
try {
|
|
139
|
+
mkdirSync(claudeDir, { recursive: true });
|
|
140
|
+
writeFileSync(join(claudeDir, 'slop.md'), SLOP_PROMPT);
|
|
141
|
+
installed.push('Claude Code');
|
|
142
|
+
console.log(` ${G}✓${X} Claude Code → ~/.claude/commands/slop.md`);
|
|
143
|
+
console.log(` ${D}type ${G}/slop${D} in any session to scan for waste${X}`);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
console.log(` ${R}✗${X} Claude Code: ${e.message}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Cursor: global rules at ~/.cursor/rules/codeslop.mdc
|
|
150
|
+
if (mode === 'all' || mode === 'cursor') {
|
|
151
|
+
const cursorDir = join(home, '.cursor', 'rules');
|
|
152
|
+
try {
|
|
153
|
+
mkdirSync(cursorDir, { recursive: true });
|
|
154
|
+
writeFileSync(join(cursorDir, 'codeslop.mdc'), `---
|
|
155
|
+
description: Token waste detector — type "check for slop" or "waste report" to scan for wasted tokens
|
|
156
|
+
globs: **/*
|
|
157
|
+
alwaysApply: false
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
${SLOP_PROMPT}`);
|
|
161
|
+
installed.push('Cursor');
|
|
162
|
+
console.log(` ${G}✓${X} Cursor → ~/.cursor/rules/codeslop.mdc`);
|
|
163
|
+
console.log(` ${D}type "${G}check for slop${D}" in chat to scan for waste${X}`);
|
|
164
|
+
} catch (e) {
|
|
165
|
+
console.log(` ${R}✗${X} Cursor: ${e.message}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (installed.length) {
|
|
170
|
+
console.log(`\n ${G}${B}done!${X} waste detection active in ${installed.join(' & ')}`);
|
|
171
|
+
console.log(` ${D}works globally across all your projects${X}\n`);
|
|
172
|
+
} else {
|
|
173
|
+
console.log(`\n ${R}nothing installed${X} — try ${G}codeslop setup claude${X} or ${G}codeslop setup cursor${X}\n`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
106
177
|
function requireUser() {
|
|
107
178
|
const c = loadConfig();
|
|
108
179
|
if (!c.user_id) { console.log(`\n ${R}run ${G}codeslop init${R} first${X}\n`); return null; }
|
package/lib/config.js
CHANGED
|
@@ -8,7 +8,7 @@ const FILE = join(DIR, 'config.json');
|
|
|
8
8
|
const DEFAULTS = {
|
|
9
9
|
user_id: null,
|
|
10
10
|
nickname: null,
|
|
11
|
-
api_url: process.env.
|
|
11
|
+
api_url: process.env.CODESLOP_API_URL || 'https://codeslop.org',
|
|
12
12
|
stream: 'daily', // off | daily | live
|
|
13
13
|
country: null, // opt-in, e.g. "US" or "IN"
|
|
14
14
|
};
|
package/package.json
CHANGED