nex-code 0.5.27 → 0.5.28

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.
@@ -0,0 +1,39 @@
1
+ # Code Review Skill
2
+ <!-- trigger: code review, review code, review the, review these, review my, review this -->
3
+ <!-- trigger: pull request, PR review, check the code, audit code -->
4
+ <!-- trigger: code quality, code smell -->
5
+
6
+ ## Instructions
7
+
8
+ When activated for code review, follow this tool sequence:
9
+
10
+ 1. **Scope the review** — identify which files were changed:
11
+ - Use `git_diff` to see staged or recent changes
12
+ - If reviewing a specific file, narrow with `read_file` on that file
13
+ - For multi-file changes, `grep` for key symbols to understand scope
14
+
15
+ 2. **Read the changes** — focus on the delta, not the whole file:
16
+ - Use `read_file` with `line_start`/`line_end` for targeted sections
17
+ - Prefer `git_diff` output over reading entire files
18
+ - Read only what changed plus relevant context lines
19
+
20
+ 3. **Check for common issues** (run these in parallel when possible):
21
+ - **Logic errors**: off-by-one, null/undefined access, incorrect conditions
22
+ - **Security**: unsanitized input, hardcoded secrets, missing auth checks
23
+ - **Performance**: N+1 queries, unnecessary loops, missing memoization
24
+ - **Style**: naming conventions, consistency with existing patterns
25
+ - **Tests**: do the changed functions have test coverage?
26
+
27
+ 4. **Verify** — run relevant tests and lints:
28
+ - `bash("npm test -- --testPathPattern=<related>")` for affected tests
29
+ - `bash("npm run lint")` if lint script exists
30
+
31
+ 5. **Deliver findings** as structured text:
32
+ - Severity: 🔴 Critical / 🟡 Warning / 🔵 Suggestion
33
+ - File path and line reference for each finding
34
+ - Specific recommendation for each issue
35
+
36
+ ## Anti-patterns to avoid
37
+ - Don't re-read entire files that haven't changed
38
+ - Don't list style issues that the formatter would catch
39
+ - Don't make edits during review — review is read-only by default
@@ -0,0 +1,40 @@
1
+ # Refactoring Skill
2
+ <!-- trigger: refactor, rewrite, restructure, clean up, cleanup -->
3
+ <!-- trigger: simplify, extract function, extract method, extract class -->
4
+ <!-- trigger: rename, move to, split into, consolidate, modernize -->
5
+
6
+ ## Instructions
7
+
8
+ When activated for refactoring, follow this tool sequence:
9
+
10
+ 1. **Map all usages first** — never change a signature without finding callers:
11
+ - `grep(<function_name>, "src/")` to find all call sites
12
+ - `grep(<class_name>, "src/")` for class references
13
+ - `grep("import.*<module>", "src/")` for import statements
14
+
15
+ 2. **Understand the current structure**:
16
+ - `read_file` the core file being refactored
17
+ - `read_file` 2-3 representative callers (not all of them yet)
18
+ - For large refactors, use `task_list` to track sub-tasks
19
+
20
+ 3. **Make the core change**:
21
+ - Edit the primary file first with `edit_file` or `write_file`
22
+ - Keep the change minimal — one concern per edit
23
+ - Verify the core change compiles: `bash("npx tsc --noEmit")` or similar
24
+
25
+ 4. **Update callers** (parallel where possible):
26
+ - For each caller: `read_file` (targeted lines) → `edit_file` → next
27
+ - Batch independent edits into a single turn
28
+ - For many callers (>3), consider `spawn_agents` for parallel updates
29
+
30
+ 5. **Verify completeness**:
31
+ - `grep(<old_name>)` to check no stale references remain
32
+ - `bash("npm test")` to run the full suite
33
+ - `git_diff` to review the full change set
34
+
35
+ ## Safety rules
36
+
37
+ - **Never refactor without tests**: if tests don't exist, write at least a smoke test first
38
+ - **One refactor per session**: don't mix refactoring with feature addition
39
+ - **Check git status first**: ensure a clean starting point
40
+ - **Commit small, logical units**: refactor → test → commit, then next refactor
@@ -0,0 +1,39 @@
1
+ # Testing Skill
2
+ <!-- trigger: test, testing, write test, add test, create test, test coverage -->
3
+ <!-- trigger: unit test, integration test, e2e test, test suite -->
4
+ <!-- trigger: failing test, broken test, test failure -->
5
+
6
+ ## Instructions
7
+
8
+ When activated for testing, follow this tool sequence:
9
+
10
+ 1. **Understand what to test**:
11
+ - `read_file` the source file that needs tests
12
+ - `grep` for existing test files: `grep(<source_filename>, "tests/")`
13
+ - If a test file exists, read it to match patterns
14
+
15
+ 2. **Determine the test framework** (check package.json or config files):
16
+ - Jest: `jest.config.*`, `"jest"` in package.json → `npm test -- --testPathPattern=...`
17
+ - Vitest: `vitest.config.*` → `npx vitest run`
18
+ - Mocha: `.mocharc.*`, `"mocha"` in package.json → `npx mocha`
19
+ - If unsure, check `package.json scripts.test` for the command
20
+
21
+ 3. **Write the test**:
22
+ - Follow existing test patterns (read a similar test file first)
23
+ - Cover: happy path, edge cases, error conditions
24
+ - Use `write_file` for new test files, `edit_file` for adding to existing ones
25
+ - Name pattern: `<source_name>.test.<ext>` or `<source_name>.spec.<ext>`
26
+
27
+ 4. **Run the test**:
28
+ - `bash("npm test -- --testPathPattern=<test_file>")` for Jest/Vitest
29
+ - Check output for pass/fail
30
+ - If it fails, read the error, fix the test or source, re-run
31
+
32
+ 5. **Verify coverage** (if available):
33
+ - `bash("npm test -- --coverage")` and check the report
34
+
35
+ ## Quick patterns
36
+
37
+ - **Add test to existing suite**: read_test → edit_file (add test case) → bash(test)
38
+ - **Create new test file**: read_source → read_similar_test → write_file → bash(test)
39
+ - **Fix failing test**: read_test → read_source → edit_file (fix) → bash(test)
@@ -0,0 +1,16 @@
1
+ <!-- Few-shot example: bug-fix
2
+ Used by cli/few-shot.js — keep under 250 tokens total.
3
+ Demonstrates the Bug-Fix Pattern: read error → grep for symbol → read target file → edit → verify -->
4
+
5
+ user: The login handler throws TypeError: Cannot read properties of undefined, can you fix it?
6
+
7
+ A: |
8
+ I'll trace the error through the codebase.
9
+ Step 1 — grep for the error source (use line numbers for targeted reads):
10
+ → grep("TypeError", "src/handlers/")
11
+ Step 2 — read only the matched line range:
12
+ → read_file("src/handlers/login.js", line_start=18, line_end=30)
13
+ Step 3 — edit the specific lines that cause the crash:
14
+ → edit_file("src/handlers/login.js", old_string, new_string)
15
+ Step 4 — verify the fix with the relevant test:
16
+ → bash("npm test -- --testPathPattern=login")
@@ -0,0 +1,20 @@
1
+ <!-- Few-shot example: feature-add
2
+ Used by cli/few-shot.js — keep under 250 tokens total.
3
+ Demonstrates the Feature-Add Pattern: read existing pattern → edit one file → verify → done -->
4
+
5
+ user: Add a rate limiter middleware to the Express server
6
+
7
+ A: |
8
+ I'll find the existing middleware pattern, then add the new one.
9
+ Step 1 — read an existing middleware to match patterns:
10
+ → read_file("src/middleware/auth.js")
11
+ Step 2 — create the new middleware following the same structure:
12
+ → write_file("src/middleware/rateLimiter.js", ...)
13
+ Step 3 — register it where other middleware is wired (grep for app.use pattern):
14
+ → grep("app.use", "src/server.js")
15
+ Step 4 — read the server file around the middleware registration:
16
+ → read_file("src/server.js", line_start=10, line_end=25)
17
+ Step 5 — add the new middleware registration:
18
+ → edit_file("src/server.js", old_string, new_string)
19
+ Step 6 — verify the server still starts:
20
+ → bash("npm test")
@@ -0,0 +1,19 @@
1
+ <!-- Few-shot example: refactor
2
+ Used by cli/few-shot.js — keep under 250 tokens total.
3
+ Demonstrates the Refactor Pattern: grep for all usages → read callers → edit core → update callers -->
4
+
5
+ user: Refactor the getUser function to accept an options object instead of positional arguments
6
+
7
+ A: |
8
+ I'll find all usages before changing the signature.
9
+ Step 1 — grep for all call sites:
10
+ → grep("getUser(", "src/")
11
+ Step 2 — read the function definition and a couple callers:
12
+ → read_file("src/services/user.js", line_start=45, line_end=70)
13
+ Step 3 — refactor the function signature:
14
+ → edit_file("src/services/user.js", old_signature, new_signature)
15
+ Step 4 — update each caller (read → edit):
16
+ → read_file("src/controllers/profile.js", line_start=30, line_end=50)
17
+ → edit_file("src/controllers/profile.js", old_call, new_call)
18
+ Step 5 — verify all tests still pass:
19
+ → bash("npm test -- --testPathPattern=user")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nex-code",
3
- "version": "0.5.27",
3
+ "version": "0.5.28",
4
4
  "description": "Run 400B+ open coding models on your codebase without the hardware bill. Ollama Cloud first — OpenAI, Anthropic, and Gemini when you need them.",
5
5
  "bin": {
6
6
  "nex-code": "./dist/nex-code.js"