rex-claude 2.1.0 → 3.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/dist/chunk-7AGI43F5.js +42 -0
- package/dist/context-FN5O5YBI.js +114 -0
- package/dist/gateway-EOVQXRON.js +198 -0
- package/dist/guards/completion-guard.sh +15 -2
- package/dist/guards/dangerous-cmd-guard.sh +2 -2
- package/dist/guards/error-pattern-guard.sh +45 -0
- package/dist/guards/notify-telegram.sh +34 -0
- package/dist/guards/test-protect-guard.sh +2 -2
- package/dist/guards/ui-checklist-guard.sh +1 -1
- package/dist/index.js +52 -13
- package/dist/{init-S7BKM2N2.js → init-W3XGDQ6D.js} +274 -11
- package/dist/llm-YRORUH7E.js +9 -0
- package/dist/optimize-UKMAGQQE.js +148 -0
- package/dist/setup-AO3MW46W.js +252 -0
- package/dist/skills/build-validate/SKILL.md +23 -0
- package/dist/skills/code-review/SKILL.md +25 -0
- package/dist/skills/context-loader/SKILL.md +25 -0
- package/dist/skills/debug-assist/SKILL.md +26 -0
- package/dist/skills/deploy-checklist/SKILL.md +61 -0
- package/dist/skills/dstudio-design-system/SKILL.md +120 -0
- package/dist/skills/figma-workflow/SKILL.md +23 -0
- package/dist/skills/fix-issue/SKILL.md +43 -0
- package/dist/skills/new-rule/SKILL.md +19 -0
- package/dist/skills/notify/SKILL.md +26 -0
- package/dist/skills/one-shot/SKILL.md +18 -0
- package/dist/skills/pr-review-loop/SKILL.md +48 -0
- package/dist/skills/project-init/SKILL.md +45 -0
- package/dist/skills/research/SKILL.md +17 -0
- package/dist/skills/rex-boot/SKILL.md +64 -0
- package/dist/skills/spec-interview/SKILL.md +20 -0
- package/dist/skills/token-guard/SKILL.md +26 -0
- package/package.json +4 -4
- package/dist/optimize-NE47FMOP.js +0 -111
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pr-review-loop
|
|
3
|
+
description: Automated PR review loop. Use when user says "review loop", "check PR comments", "fix PR feedback", or after creating a PR. Pulls comments from Gemini Code Assist and GitHub Copilot, fixes valid issues, and pushes updates.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PR Review Loop
|
|
7
|
+
|
|
8
|
+
After a PR is created or when asked to check PR feedback:
|
|
9
|
+
|
|
10
|
+
1. **Pull review comments** from the PR:
|
|
11
|
+
```bash
|
|
12
|
+
# Get PR number from current branch
|
|
13
|
+
PR_NUMBER=$(gh pr view --json number -q .number 2>/dev/null)
|
|
14
|
+
|
|
15
|
+
# Get all review comments (inline code comments)
|
|
16
|
+
gh api repos/{owner}/{repo}/pulls/$PR_NUMBER/comments --jq '.[] | "[\(.user.login)] \(.path):\(.line // .original_line) - \(.body)"'
|
|
17
|
+
|
|
18
|
+
# Get PR review summaries
|
|
19
|
+
gh pr view $PR_NUMBER --comments
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
2. **Categorize each comment**:
|
|
23
|
+
- **Valid fix needed**: bug, security issue, logic error, missing edge case
|
|
24
|
+
- **Good suggestion**: improvement worth making (cleaner code, better naming)
|
|
25
|
+
- **Dismiss**: style preference, false positive, or not applicable
|
|
26
|
+
|
|
27
|
+
3. **Fix valid issues**:
|
|
28
|
+
- Address each valid comment with a targeted fix
|
|
29
|
+
- Run tests/lint after each fix to ensure no regressions
|
|
30
|
+
- Do NOT introduce unrelated changes
|
|
31
|
+
|
|
32
|
+
4. **Commit and push fixes**:
|
|
33
|
+
- One commit for all review fixes: `fix: address PR review feedback`
|
|
34
|
+
- Push to the same branch (the PR updates automatically)
|
|
35
|
+
|
|
36
|
+
5. **Report to user**:
|
|
37
|
+
- List what was fixed and why
|
|
38
|
+
- List what was dismissed and why
|
|
39
|
+
- Ask user to review the diff between v1 and v2
|
|
40
|
+
|
|
41
|
+
IMPORTANT: Never force-push. Always regular push. The user reviews the incremental diff.
|
|
42
|
+
|
|
43
|
+
## Auto-Learn
|
|
44
|
+
|
|
45
|
+
After processing all comments, call `rex_learn` MCP tool for each valid fix:
|
|
46
|
+
- category: `"lesson"`
|
|
47
|
+
- fact: the reviewer feedback pattern + fix (e.g. "Copilot flagged missing null check on X — added guard clause")
|
|
48
|
+
- Skip dismissed comments — only learn from actionable feedback
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-init
|
|
3
|
+
description: Initialize a new project with CLAUDE.md, proper git setup, and documentation cache. Use when starting a new project or onboarding an existing one.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Project Init
|
|
7
|
+
|
|
8
|
+
Initialize project: $ARGUMENTS (path or name)
|
|
9
|
+
|
|
10
|
+
## For new projects
|
|
11
|
+
1. Create project directory structure
|
|
12
|
+
2. Generate `CLAUDE.md` with project-specific instructions
|
|
13
|
+
3. Detect stack from user input, create appropriate config files
|
|
14
|
+
4. Load relevant docs from `~/.claude/docs/` or fetch via Context7
|
|
15
|
+
5. Git init, create `.gitignore`, initial commit
|
|
16
|
+
6. Save project context: `rex_learn("Project X uses stack Y, structure Z", "architecture")`
|
|
17
|
+
|
|
18
|
+
## For existing projects (onboarding)
|
|
19
|
+
1. Read existing `package.json` / `composer.json` / config files to detect stack
|
|
20
|
+
2. Read existing `CLAUDE.md` if present, or create one
|
|
21
|
+
3. Scan project structure: key directories, entry points, routing
|
|
22
|
+
4. Load relevant framework docs from `~/.claude/docs/`
|
|
23
|
+
5. Call `rex_context(project_path)` for any past work history
|
|
24
|
+
6. Report: stack, structure, key files, any issues noticed
|
|
25
|
+
|
|
26
|
+
## CLAUDE.md template
|
|
27
|
+
```markdown
|
|
28
|
+
# Project Name
|
|
29
|
+
|
|
30
|
+
## Stack
|
|
31
|
+
- Framework: ...
|
|
32
|
+
- Language: ...
|
|
33
|
+
- Database: ...
|
|
34
|
+
|
|
35
|
+
## Commands
|
|
36
|
+
- Dev: `npm run dev`
|
|
37
|
+
- Build: `npm run build`
|
|
38
|
+
- Test: `npm test`
|
|
39
|
+
- Lint: `npm run lint`
|
|
40
|
+
|
|
41
|
+
## Key Files
|
|
42
|
+
- Entry: ...
|
|
43
|
+
- Config: ...
|
|
44
|
+
- Routes: ...
|
|
45
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: research
|
|
3
|
+
description: Deep research on a topic using web, docs, codebase. Returns concise actionable summary with sources. Use for architecture decisions, library comparisons, debugging.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Research
|
|
7
|
+
|
|
8
|
+
Research: $ARGUMENTS
|
|
9
|
+
|
|
10
|
+
1. Check `~/.claude/docs/` for local cached documentation first
|
|
11
|
+
2. Search web for documentation, best practices, recent changes
|
|
12
|
+
3. Query Context7 for versioned library docs if relevant
|
|
13
|
+
4. Search codebase for existing patterns and usage
|
|
14
|
+
5. Synthesize into concise summary with recommendations
|
|
15
|
+
|
|
16
|
+
Return: key findings, recommended approach, code references, links.
|
|
17
|
+
Keep it actionable — the goal is to inform a decision, not write an essay.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rex-boot
|
|
3
|
+
description: Session startup companion. Auto-detects project, loads context, checks environment, asks what to work on. Runs automatically at every session start.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# REX Boot — Session Companion
|
|
7
|
+
|
|
8
|
+
Tu es REX, senior dev companion de Kevin. A chaque début de session, tu fais ce briefing.
|
|
9
|
+
|
|
10
|
+
## 1. Detect project context
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Where are we?
|
|
14
|
+
pwd
|
|
15
|
+
# Git state
|
|
16
|
+
git branch --show-current 2>/dev/null
|
|
17
|
+
git status --short 2>/dev/null | head -20
|
|
18
|
+
# What project is this?
|
|
19
|
+
cat package.json 2>/dev/null | jq '{name, scripts: .scripts | keys}' 2>/dev/null || cat composer.json 2>/dev/null | jq '.name' 2>/dev/null || echo "No project detected"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 2. Check for in-progress work
|
|
23
|
+
|
|
24
|
+
- Open branches with uncommitted changes?
|
|
25
|
+
- Stashed work? (`git stash list`)
|
|
26
|
+
- Open PRs on this repo? (`gh pr list --state open --limit 5`)
|
|
27
|
+
- Failing CI on current branch?
|
|
28
|
+
|
|
29
|
+
## 3. Load relevant context (ON-DEMAND only)
|
|
30
|
+
|
|
31
|
+
- If a project is detected: call `rex_context(project_path)` for past session memory
|
|
32
|
+
- If CLAUDE.md exists in project: mention its key points
|
|
33
|
+
- Do NOT load `~/.claude/docs/` yet — wait until the task is clear
|
|
34
|
+
|
|
35
|
+
## 4. Briefing to Kevin
|
|
36
|
+
|
|
37
|
+
Format the output as a short briefing:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
REX Boot
|
|
41
|
+
---
|
|
42
|
+
Projet: {name} ({path})
|
|
43
|
+
Branche: {branch} | {clean/dirty}
|
|
44
|
+
Stack: {detected stack}
|
|
45
|
+
PR ouvertes: {count}
|
|
46
|
+
Travail en cours: {stash/uncommitted summary}
|
|
47
|
+
Mémoire REX: {brief context if found}
|
|
48
|
+
---
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 5. Ask what to work on
|
|
52
|
+
|
|
53
|
+
Use AskUserQuestion with smart options based on context:
|
|
54
|
+
- If dirty git state → "Continuer le travail en cours?"
|
|
55
|
+
- If open PRs → "Review la PR #{number}?"
|
|
56
|
+
- If nothing → "Quel est l'objectif aujourd'hui?"
|
|
57
|
+
|
|
58
|
+
Always offer these options contextually, not a generic menu.
|
|
59
|
+
|
|
60
|
+
## Rules
|
|
61
|
+
- Keep the boot FAST — no heavy operations, no doc loading
|
|
62
|
+
- Max 3 bash commands total
|
|
63
|
+
- If no project detected (home dir), just ask what Kevin veut faire
|
|
64
|
+
- NEVER read doc files at boot — they load when the task is clear
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spec-interview
|
|
3
|
+
description: Interview the user to write a complete feature spec before coding. Use when user says "/spec-interview" or "interview me about" a feature.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Feature Spec Interview
|
|
8
|
+
|
|
9
|
+
I want to build: $ARGUMENTS
|
|
10
|
+
|
|
11
|
+
Interview me in depth using the AskUserQuestion tool. Cover:
|
|
12
|
+
- Technical implementation and architecture choices
|
|
13
|
+
- UI/UX and user flows
|
|
14
|
+
- Edge cases and failure modes
|
|
15
|
+
- Security implications
|
|
16
|
+
- Performance at scale (10x users/requests)
|
|
17
|
+
- Tradeoffs and alternatives considered
|
|
18
|
+
|
|
19
|
+
Don't ask obvious questions. Dig into the hard parts I haven't thought through.
|
|
20
|
+
Keep interviewing until we've covered everything, then write a complete spec to `SPEC.md`.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: token-guard
|
|
3
|
+
description: Optimize context usage. Audit what's loaded, suggest cleanup, compact if needed. Use when context feels bloated or before long sessions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Token Guard
|
|
7
|
+
|
|
8
|
+
Audit and optimize the current context usage.
|
|
9
|
+
|
|
10
|
+
## Checks
|
|
11
|
+
1. **Files in context**: list all files that have been read this session
|
|
12
|
+
2. **Redundant reads**: flag files read multiple times
|
|
13
|
+
3. **Large outputs**: flag tool results > 200 lines that could have been scoped
|
|
14
|
+
4. **Stale context**: flag information from early in session that's no longer relevant
|
|
15
|
+
|
|
16
|
+
## Actions
|
|
17
|
+
- Suggest `/compact` if context > 70%
|
|
18
|
+
- Suggest `/clear` if switching to unrelated task
|
|
19
|
+
- Identify docs/files that could be read on-demand instead of upfront
|
|
20
|
+
- Flag any MCP server responses that returned excessive data
|
|
21
|
+
|
|
22
|
+
## Reminders
|
|
23
|
+
- Use subagents for heavy research (keeps main context clean)
|
|
24
|
+
- Use `limit` and `offset` when reading large files
|
|
25
|
+
- Use `head_limit` on Grep results
|
|
26
|
+
- Prefer Glob/Grep over Agent for simple lookups
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rex-claude",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Claude Code sous steroides — guards, health checks, memory RAG",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@rex/core": "workspace:*",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
39
|
+
"@types/node": "^25.3.3",
|
|
40
|
+
"tsup": "^8.5.1",
|
|
41
|
+
"typescript": "^5.9.3"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -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
|
-
};
|