rex-claude 2.2.0 → 3.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.
Files changed (33) hide show
  1. package/dist/chunk-7AGI43F5.js +42 -0
  2. package/dist/context-FN5O5YBI.js +114 -0
  3. package/dist/gateway-EOVQXRON.js +198 -0
  4. package/dist/guards/completion-guard.sh +15 -2
  5. package/dist/guards/dangerous-cmd-guard.sh +2 -2
  6. package/dist/guards/error-pattern-guard.sh +45 -0
  7. package/dist/guards/notify-telegram.sh +34 -0
  8. package/dist/guards/test-protect-guard.sh +2 -2
  9. package/dist/guards/ui-checklist-guard.sh +1 -1
  10. package/dist/index.js +52 -13
  11. package/dist/{init-NXU37FCV.js → init-W3XGDQ6D.js} +159 -1
  12. package/dist/llm-YRORUH7E.js +9 -0
  13. package/dist/optimize-UKMAGQQE.js +148 -0
  14. package/dist/setup-AO3MW46W.js +252 -0
  15. package/dist/skills/build-validate/SKILL.md +23 -0
  16. package/dist/skills/code-review/SKILL.md +25 -0
  17. package/dist/skills/context-loader/SKILL.md +25 -0
  18. package/dist/skills/debug-assist/SKILL.md +26 -0
  19. package/dist/skills/deploy-checklist/SKILL.md +61 -0
  20. package/dist/skills/dstudio-design-system/SKILL.md +120 -0
  21. package/dist/skills/figma-workflow/SKILL.md +23 -0
  22. package/dist/skills/fix-issue/SKILL.md +43 -0
  23. package/dist/skills/new-rule/SKILL.md +19 -0
  24. package/dist/skills/notify/SKILL.md +26 -0
  25. package/dist/skills/one-shot/SKILL.md +18 -0
  26. package/dist/skills/pr-review-loop/SKILL.md +48 -0
  27. package/dist/skills/project-init/SKILL.md +45 -0
  28. package/dist/skills/research/SKILL.md +17 -0
  29. package/dist/skills/rex-boot/SKILL.md +64 -0
  30. package/dist/skills/spec-interview/SKILL.md +20 -0
  31. package/dist/skills/token-guard/SKILL.md +26 -0
  32. package/package.json +4 -4
  33. package/dist/optimize-NE47FMOP.js +0 -111
@@ -1,111 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/optimize.ts
4
- import { readFileSync, existsSync } from "fs";
5
- import { join } from "path";
6
- import { homedir } from "os";
7
- var COLORS = {
8
- reset: "\x1B[0m",
9
- green: "\x1B[32m",
10
- yellow: "\x1B[33m",
11
- red: "\x1B[31m",
12
- bold: "\x1B[1m",
13
- dim: "\x1B[2m",
14
- cyan: "\x1B[36m"
15
- };
16
- var OLLAMA_URL = process.env.OLLAMA_URL || "http://localhost:11434";
17
- var PREFERRED_MODELS = ["deepseek-r1:8b", "qwen2.5:1.5b", "llama3.2", "mistral"];
18
- async function detectModel() {
19
- if (process.env.REX_OPTIMIZE_MODEL) return process.env.REX_OPTIMIZE_MODEL;
20
- try {
21
- const res = await fetch(`${OLLAMA_URL}/api/tags`);
22
- const data = await res.json();
23
- const available = data.models.map((m) => m.name);
24
- for (const pref of PREFERRED_MODELS) {
25
- if (available.some((a) => a.includes(pref.split(":")[0]))) {
26
- return available.find((a) => a.includes(pref.split(":")[0]));
27
- }
28
- }
29
- return available.find((a) => !a.includes("embed")) || available[0];
30
- } catch {
31
- return "llama3.2";
32
- }
33
- }
34
- async function llm(prompt, system, model) {
35
- const res = await fetch(`${OLLAMA_URL}/api/generate`, {
36
- method: "POST",
37
- headers: { "Content-Type": "application/json" },
38
- body: JSON.stringify({
39
- model: model || "qwen2.5:1.5b",
40
- prompt,
41
- system,
42
- stream: false
43
- })
44
- });
45
- if (!res.ok) throw new Error(`Ollama generate failed: ${res.status}`);
46
- const data = await res.json();
47
- return data.response;
48
- }
49
- async function optimize() {
50
- const line = "\u2550".repeat(45);
51
- console.log(`
52
- ${line}`);
53
- console.log(`${COLORS.bold} REX OPTIMIZE${COLORS.reset}`);
54
- console.log(`${line}
55
- `);
56
- try {
57
- const res = await fetch(`${OLLAMA_URL}/api/tags`);
58
- if (!res.ok) throw new Error();
59
- } catch {
60
- console.error(`${COLORS.red}Ollama not running.${COLORS.reset} Start it: ollama serve`);
61
- process.exit(1);
62
- }
63
- const cwd = process.cwd();
64
- const projectClaudeMd = join(cwd, "CLAUDE.md");
65
- const globalClaudeMd = join(homedir(), ".claude", "CLAUDE.md");
66
- const target = existsSync(projectClaudeMd) ? projectClaudeMd : globalClaudeMd;
67
- if (!existsSync(target)) {
68
- console.error(`${COLORS.red}No CLAUDE.md found.${COLORS.reset}`);
69
- process.exit(1);
70
- }
71
- const content = readFileSync(target, "utf-8");
72
- const lines = content.split("\n").length;
73
- const chars = content.length;
74
- const tokens = Math.ceil(chars / 4);
75
- console.log(` ${COLORS.cyan}Target:${COLORS.reset} ${target}`);
76
- console.log(` ${COLORS.cyan}Size:${COLORS.reset} ${lines} lines, ~${tokens} tokens`);
77
- console.log();
78
- const model = await detectModel();
79
- console.log(` ${COLORS.dim}Analyzing with ${model}...${COLORS.reset}`);
80
- const analysis = await llm(
81
- `Analyze this CLAUDE.md file and provide specific suggestions to reduce its token count while keeping all important instructions. Focus on:
82
- 1. Redundant or duplicate instructions
83
- 2. Overly verbose sections that could be shortened
84
- 3. Content that could be moved to separate files and @imported
85
- 4. Dead or outdated references
86
-
87
- CLAUDE.md content:
88
- ---
89
- ${content.slice(0, 6e3)}
90
- ---
91
-
92
- Provide a concise analysis with specific, actionable suggestions. Format each suggestion as:
93
- - [SECTION] What to change and why (estimated savings: N tokens)`,
94
- "You are a technical editor that optimizes AI instruction files. Be direct and specific. Output only the analysis, no preamble.",
95
- model
96
- );
97
- console.log(`
98
- ${COLORS.bold} Analysis:${COLORS.reset}
99
- `);
100
- for (const line2 of analysis.split("\n")) {
101
- console.log(` ${line2}`);
102
- }
103
- console.log(`
104
- ${COLORS.dim}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${COLORS.reset}`);
105
- console.log(`
106
- ${COLORS.dim}Tip: Run ${COLORS.cyan}rex optimize --apply${COLORS.reset}${COLORS.dim} to auto-apply suggestions${COLORS.reset}`);
107
- console.log();
108
- }
109
- export {
110
- optimize
111
- };