oh-my-claude-sisyphus 3.5.6 → 3.5.8

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.
Files changed (79) hide show
  1. package/README.md +58 -343
  2. package/commands/omc-setup.md +51 -0
  3. package/dist/__tests__/analytics/tokscale-adapter.test.d.ts +2 -0
  4. package/dist/__tests__/analytics/tokscale-adapter.test.d.ts.map +1 -0
  5. package/dist/__tests__/analytics/tokscale-adapter.test.js +79 -0
  6. package/dist/__tests__/analytics/tokscale-adapter.test.js.map +1 -0
  7. package/dist/__tests__/hooks/auto-slash-command/executor.test.d.ts +7 -0
  8. package/dist/__tests__/hooks/auto-slash-command/executor.test.d.ts.map +1 -0
  9. package/dist/__tests__/hooks/auto-slash-command/executor.test.js +374 -0
  10. package/dist/__tests__/hooks/auto-slash-command/executor.test.js.map +1 -0
  11. package/dist/__tests__/hooks/learner/bridge.test.d.ts +11 -0
  12. package/dist/__tests__/hooks/learner/bridge.test.d.ts.map +1 -0
  13. package/dist/__tests__/hooks/learner/bridge.test.js +199 -0
  14. package/dist/__tests__/hooks/learner/bridge.test.js.map +1 -0
  15. package/dist/__tests__/installer.test.js +1 -1
  16. package/dist/analytics/cost-estimator.d.ts +14 -0
  17. package/dist/analytics/cost-estimator.d.ts.map +1 -1
  18. package/dist/analytics/cost-estimator.js +65 -0
  19. package/dist/analytics/cost-estimator.js.map +1 -1
  20. package/dist/analytics/index.d.ts +1 -0
  21. package/dist/analytics/index.d.ts.map +1 -1
  22. package/dist/analytics/index.js +4 -0
  23. package/dist/analytics/index.js.map +1 -1
  24. package/dist/analytics/query-engine.d.ts +3 -0
  25. package/dist/analytics/query-engine.d.ts.map +1 -1
  26. package/dist/analytics/query-engine.js +87 -0
  27. package/dist/analytics/query-engine.js.map +1 -1
  28. package/dist/analytics/token-tracker.d.ts +3 -0
  29. package/dist/analytics/token-tracker.d.ts.map +1 -1
  30. package/dist/analytics/token-tracker.js +89 -0
  31. package/dist/analytics/token-tracker.js.map +1 -1
  32. package/dist/analytics/tokscale-adapter.d.ts +71 -0
  33. package/dist/analytics/tokscale-adapter.d.ts.map +1 -0
  34. package/dist/analytics/tokscale-adapter.js +223 -0
  35. package/dist/analytics/tokscale-adapter.js.map +1 -0
  36. package/dist/analytics/types.d.ts +17 -0
  37. package/dist/analytics/types.d.ts.map +1 -1
  38. package/dist/analytics/types.js +5 -0
  39. package/dist/analytics/types.js.map +1 -1
  40. package/dist/cli/analytics.js +35 -0
  41. package/dist/cli/analytics.js.map +1 -1
  42. package/dist/cli/commands/agents.d.ts.map +1 -1
  43. package/dist/cli/commands/agents.js +4 -2
  44. package/dist/cli/commands/agents.js.map +1 -1
  45. package/dist/cli/commands/stats.d.ts.map +1 -1
  46. package/dist/cli/commands/stats.js +6 -1
  47. package/dist/cli/commands/stats.js.map +1 -1
  48. package/dist/cli/index.js +95 -35
  49. package/dist/cli/index.js.map +1 -1
  50. package/dist/cli/utils/tokscale-launcher.d.ts +18 -0
  51. package/dist/cli/utils/tokscale-launcher.d.ts.map +1 -0
  52. package/dist/cli/utils/tokscale-launcher.js +64 -0
  53. package/dist/cli/utils/tokscale-launcher.js.map +1 -0
  54. package/dist/features/auto-update.js +5 -5
  55. package/dist/features/auto-update.js.map +1 -1
  56. package/dist/hooks/learner/bridge.d.ts +71 -0
  57. package/dist/hooks/learner/bridge.d.ts.map +1 -0
  58. package/dist/hooks/learner/bridge.js +426 -0
  59. package/dist/hooks/learner/bridge.js.map +1 -0
  60. package/dist/hooks/skill-bridge.cjs +349 -0
  61. package/dist/hud/types.d.ts +6 -2
  62. package/dist/hud/types.d.ts.map +1 -1
  63. package/dist/hud/types.js.map +1 -1
  64. package/dist/hud/usage-api.d.ts.map +1 -1
  65. package/dist/hud/usage-api.js +13 -1
  66. package/dist/hud/usage-api.js.map +1 -1
  67. package/dist/installer/index.d.ts +1 -1
  68. package/dist/installer/index.js +1 -1
  69. package/docs/ARCHITECTURE.md +80 -397
  70. package/docs/FEATURES.md +396 -1981
  71. package/docs/MIGRATION.md +4 -4
  72. package/docs/REFERENCE.md +545 -0
  73. package/docs/SYNC-SYSTEM.md +6 -6
  74. package/package.json +5 -2
  75. package/scripts/build-skill-bridge.mjs +32 -0
  76. package/scripts/skill-injector.mjs +77 -26
  77. package/scripts/sync-metadata.ts +2 -2
  78. package/skills/omc-setup/SKILL.md +51 -0
  79. package/docs/FULL-README.md +0 -1001
@@ -4,34 +4,41 @@
4
4
  * Skill Injector Hook (UserPromptSubmit)
5
5
  * Injects relevant learned skills into context based on prompt triggers.
6
6
  *
7
- * STANDALONE SCRIPT - does not import from dist/
8
- * Follows pattern of keyword-detector.mjs and session-start.mjs
7
+ * STANDALONE SCRIPT - uses compiled bridge bundle from dist/hooks/skill-bridge.cjs
8
+ * Falls back to inline implementation if bundle not available (first run before build)
9
+ *
10
+ * Enhancement in v3.5: Now uses RECURSIVE discovery (skills in subdirectories included)
9
11
  */
10
12
 
11
13
  import { existsSync, readdirSync, readFileSync, realpathSync } from 'fs';
12
- import { join } from 'path';
14
+ import { join, basename } from 'path';
13
15
  import { homedir } from 'os';
16
+ import { createRequire } from 'module';
17
+
18
+ // Try to load the compiled bridge bundle
19
+ const require = createRequire(import.meta.url);
20
+ let bridge = null;
21
+ try {
22
+ bridge = require('../dist/hooks/skill-bridge.cjs');
23
+ } catch {
24
+ // Bridge not available - use fallback (first run before build, or dist/ missing)
25
+ }
14
26
 
15
- // Constants
27
+ // Constants (used by fallback)
16
28
  const USER_SKILLS_DIR = join(homedir(), '.claude', 'skills', 'omc-learned');
17
29
  const PROJECT_SKILLS_SUBDIR = '.omc/skills';
18
30
  const SKILL_EXTENSION = '.md';
19
31
  const MAX_SKILLS_PER_SESSION = 5;
20
32
 
21
- // Session cache to avoid re-injecting same skills
22
- const injectedCache = new Map();
33
+ // =============================================================================
34
+ // Fallback Implementation (used when bridge bundle not available)
35
+ // =============================================================================
23
36
 
24
- // Read all stdin
25
- async function readStdin() {
26
- const chunks = [];
27
- for await (const chunk of process.stdin) {
28
- chunks.push(chunk);
29
- }
30
- return Buffer.concat(chunks).toString('utf-8');
31
- }
37
+ // In-memory cache (resets each process - known limitation, fixed by bridge)
38
+ const injectedCacheFallback = new Map();
32
39
 
33
- // Parse YAML frontmatter from skill file
34
- function parseSkillFrontmatter(content) {
40
+ // Parse YAML frontmatter from skill file (fallback)
41
+ function parseSkillFrontmatterFallback(content) {
35
42
  const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
36
43
  if (!match) return null;
37
44
 
@@ -56,8 +63,8 @@ function parseSkillFrontmatter(content) {
56
63
  return { name, triggers, content: body };
57
64
  }
58
65
 
59
- // Find all skill files
60
- function findSkillFiles(directory) {
66
+ // Find all skill files (fallback - NON-RECURSIVE for backward compat)
67
+ function findSkillFilesFallback(directory) {
61
68
  const candidates = [];
62
69
  const seenPaths = new Set();
63
70
 
@@ -111,17 +118,17 @@ function findSkillFiles(directory) {
111
118
  return candidates;
112
119
  }
113
120
 
114
- // Find matching skills by trigger keywords
115
- function findMatchingSkills(prompt, directory, sessionId) {
121
+ // Find matching skills (fallback)
122
+ function findMatchingSkillsFallback(prompt, directory, sessionId) {
116
123
  const promptLower = prompt.toLowerCase();
117
- const candidates = findSkillFiles(directory);
124
+ const candidates = findSkillFilesFallback(directory);
118
125
  const matches = [];
119
126
 
120
127
  // Get or create session cache
121
- if (!injectedCache.has(sessionId)) {
122
- injectedCache.set(sessionId, new Set());
128
+ if (!injectedCacheFallback.has(sessionId)) {
129
+ injectedCacheFallback.set(sessionId, new Set());
123
130
  }
124
- const alreadyInjected = injectedCache.get(sessionId);
131
+ const alreadyInjected = injectedCacheFallback.get(sessionId);
125
132
 
126
133
  for (const candidate of candidates) {
127
134
  // Skip if already injected this session
@@ -129,7 +136,7 @@ function findMatchingSkills(prompt, directory, sessionId) {
129
136
 
130
137
  try {
131
138
  const content = readFileSync(candidate.path, 'utf-8');
132
- const skill = parseSkillFrontmatter(content);
139
+ const skill = parseSkillFrontmatterFallback(content);
133
140
  if (!skill) continue;
134
141
 
135
142
  // Check if any trigger matches
@@ -146,7 +153,8 @@ function findMatchingSkills(prompt, directory, sessionId) {
146
153
  name: skill.name,
147
154
  content: skill.content,
148
155
  score,
149
- scope: candidate.scope
156
+ scope: candidate.scope,
157
+ triggers: skill.triggers
150
158
  });
151
159
  }
152
160
  } catch {
@@ -166,6 +174,39 @@ function findMatchingSkills(prompt, directory, sessionId) {
166
174
  return selected;
167
175
  }
168
176
 
177
+ // =============================================================================
178
+ // Main Logic (uses bridge if available, fallback otherwise)
179
+ // =============================================================================
180
+
181
+ // Read all stdin
182
+ async function readStdin() {
183
+ const chunks = [];
184
+ for await (const chunk of process.stdin) {
185
+ chunks.push(chunk);
186
+ }
187
+ return Buffer.concat(chunks).toString('utf-8');
188
+ }
189
+
190
+ // Find matching skills - delegates to bridge or fallback
191
+ function findMatchingSkills(prompt, directory, sessionId) {
192
+ if (bridge) {
193
+ // Use bridge (RECURSIVE discovery, persistent session cache)
194
+ const matches = bridge.matchSkillsForInjection(prompt, directory, sessionId, {
195
+ maxResults: MAX_SKILLS_PER_SESSION
196
+ });
197
+
198
+ // Mark as injected via bridge
199
+ if (matches.length > 0) {
200
+ bridge.markSkillsInjected(sessionId, matches.map(s => s.path), directory);
201
+ }
202
+
203
+ return matches;
204
+ }
205
+
206
+ // Fallback (NON-RECURSIVE, in-memory cache)
207
+ return findMatchingSkillsFallback(prompt, directory, sessionId);
208
+ }
209
+
169
210
  // Format skills for injection
170
211
  function formatSkillsMessage(skills) {
171
212
  const lines = [
@@ -179,7 +220,17 @@ function formatSkillsMessage(skills) {
179
220
 
180
221
  for (const skill of skills) {
181
222
  lines.push(`### ${skill.name} (${skill.scope})`);
223
+
224
+ // Add metadata block for programmatic parsing
225
+ const metadata = {
226
+ path: skill.path,
227
+ triggers: skill.triggers,
228
+ score: skill.score,
229
+ scope: skill.scope
230
+ };
231
+ lines.push(`<skill-metadata>${JSON.stringify(metadata)}</skill-metadata>`);
182
232
  lines.push('');
233
+
183
234
  lines.push(skill.content);
184
235
  lines.push('');
185
236
  lines.push('---');
@@ -123,7 +123,7 @@ function getFileSyncConfigs(): FileSync[] {
123
123
  ],
124
124
  },
125
125
  {
126
- path: 'docs/FULL-README.md',
126
+ path: 'docs/REFERENCE.md',
127
127
  replacements: [
128
128
  {
129
129
  pattern: /\[!\[Version\]\(https:\/\/img\.shields\.io\/badge\/version-[^-]+-[^)]+\)/g,
@@ -319,7 +319,7 @@ ${color('Description:', colors.cyan)}
319
319
 
320
320
  ${color('Files Synced:', colors.cyan)}
321
321
  - README.md (npm badges)
322
- - docs/FULL-README.md (version badges and headers)
322
+ - docs/REFERENCE.md (version badges and headers)
323
323
  - .github/CLAUDE.md (agent/skill counts)
324
324
  - docs/ARCHITECTURE.md (version references)
325
325
  - CHANGELOG.md (version header verification)
@@ -266,6 +266,45 @@ echo "Default execution mode set to: USER_CHOICE"
266
266
 
267
267
  **Note**: This preference ONLY affects generic keywords ("fast", "parallel"). Explicit keywords ("ulw", "eco") always override this preference.
268
268
 
269
+ ## Step 3.8: Install CLI Analytics Tools (Optional)
270
+
271
+ The OMC CLI provides standalone token analytics commands (`omc stats`, `omc agents`, `omc tui`).
272
+
273
+ Ask user: "Would you like to install the OMC CLI for standalone analytics? (Recommended for tracking token usage and costs)"
274
+
275
+ **Options:**
276
+ 1. **Yes (Recommended)** - Install CLI tools globally for `omc stats`, `omc agents`, etc.
277
+ 2. **No** - Skip CLI installation, use only plugin skills
278
+
279
+ ### If User Chooses YES:
280
+
281
+ ```bash
282
+ # Check for bun (preferred) or npm
283
+ if command -v bun &> /dev/null; then
284
+ echo "Installing OMC CLI via bun..."
285
+ bun install -g oh-my-claudecode
286
+ elif command -v npm &> /dev/null; then
287
+ echo "Installing OMC CLI via npm..."
288
+ npm install -g oh-my-claudecode
289
+ else
290
+ echo "ERROR: Neither bun nor npm found. Please install Node.js or Bun first."
291
+ exit 1
292
+ fi
293
+
294
+ # Verify installation
295
+ if command -v omc &> /dev/null; then
296
+ echo "✓ OMC CLI installed successfully!"
297
+ echo " Try: omc stats, omc agents, omc tui"
298
+ else
299
+ echo "⚠ CLI installed but 'omc' not in PATH."
300
+ echo " You may need to restart your terminal or add npm/bun global bin to PATH."
301
+ fi
302
+ ```
303
+
304
+ ### If User Chooses NO:
305
+
306
+ Skip this step. User can install later with `npm install -g oh-my-claudecode`.
307
+
269
308
  ## Step 4: Verify Plugin Installation
270
309
 
271
310
  ```bash
@@ -329,6 +368,12 @@ Run /oh-my-claudecode:mcp-setup to add tools like web search, GitHub, etc.
329
368
  HUD STATUSLINE:
330
369
  The status bar now shows OMC state. Restart Claude Code to see it.
331
370
 
371
+ CLI ANALYTICS (if installed):
372
+ - omc - Full dashboard (stats + agents + cost)
373
+ - omc stats - View token usage and costs
374
+ - omc agents - See agent breakdown by cost
375
+ - omc tui - Launch interactive TUI dashboard
376
+
332
377
  That's it! Just use Claude Code normally.
333
378
  ```
334
379
 
@@ -359,6 +404,12 @@ MAGIC KEYWORDS (power-user shortcuts):
359
404
  HUD STATUSLINE:
360
405
  The status bar now shows OMC state. Restart Claude Code to see it.
361
406
 
407
+ CLI ANALYTICS (if installed):
408
+ - omc - Full dashboard (stats + agents + cost)
409
+ - omc stats - View token usage and costs
410
+ - omc agents - See agent breakdown by cost
411
+ - omc tui - Launch interactive TUI dashboard
412
+
362
413
  Your workflow won't break - it just got easier!
363
414
  ```
364
415