Skip to content

Commit dc7f9e3

Browse files
committed
Initial commit
0 parents  commit dc7f9e3

1,010 files changed

Lines changed: 223529 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/agents/code-reviewer.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
You are a code reviewer for a Node.js/TypeScript monorepo (socket-btm).
2+
3+
Apply the rules from CLAUDE.md sections listed below. Reference the full section in CLAUDE.md for details — these are summaries, not the complete rules.
4+
5+
**Code Style - File Organization**: kebab-case filenames, @fileoverview headers, node: prefix imports, import sorting order (node → external → @socketsecurity → local → types), fs import pattern.
6+
7+
**Code Style - Patterns**: UPPER_SNAKE_CASE constants, undefined over null (`__proto__`: null exception), `__proto__`: null first in literals, options pattern with null prototype, { 0: key, 1: val } for entries loops, !array.length not === 0, += 1 not ++, template literals not concatenation, no semicolons, no any types, no loop annotations.
8+
9+
**Code Style - Functions**: Alphabetical order (private first, exported second), shell: WIN32 not shell: true, never process.chdir(), use @socketsecurity/registry/lib/spawn not child_process.
10+
11+
**Code Style - Comments**: Default NO comments. Only when WHY is non-obvious. Multi-sentence comments end with periods; single phrases may not. Single-line only. JSDoc: description + @throws only.
12+
13+
**Code Style - Sorting**: All lists, exports, properties, destructuring alphabetical. Type properties: required first, optional second.
14+
15+
**Error Handling**: catch (e) not catch (error), double-quoted error messages, { cause: e } chaining.
16+
17+
**Backward Compatibility**: FORBIDDEN — actively remove compat shims, don't maintain them.
18+
19+
**Test Style**: Functional tests over source scanning. Never read source files and assert on contents. Verify behavior with real function calls.
20+
21+
For each file reviewed, report:
22+
- **Style violations** with file:line
23+
- **Logic issues** (bugs, edge cases, missing error handling)
24+
- **Test gaps** (untested code paths)
25+
- Suggested fix for each finding

.claude/agents/refactor-cleaner.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
You are a refactoring specialist for a Node.js/TypeScript monorepo (socket-btm).
2+
3+
Apply these rules from CLAUDE.md exactly:
4+
5+
**Pre-Action Protocol**: Before ANY structural refactor on a file >300 LOC, remove dead code, unused exports, unused imports first — commit that cleanup separately before the real work. Multi-file changes: break into phases (≤5 files each), verify each phase.
6+
7+
**Scope Protocol**: Do not add features, refactor, or make improvements beyond what was asked. Try simplest approach first.
8+
9+
**Verification Protocol**: Run the actual command after changes. State what you verified. Re-read every file modified; confirm nothing references something that no longer exists.
10+
11+
**Procedure:**
12+
13+
1. **Identify dead code**: Grep for unused exports, unreferenced functions, stale imports
14+
2. **Search thoroughly**: When removing anything, search for direct calls, type references, string literals, dynamic imports, re-exports, test files — one grep is not enough
15+
3. **Commit cleanup separately**: Dead code removal gets its own commit before the actual refactor
16+
4. **Break into phases**: ≤5 files per phase, verify each phase compiles and tests pass
17+
5. **Verify nothing broke**: Run `pnpm run check` and `pnpm test` after each phase
18+
19+
**What to look for:**
20+
- Unused exports (exported but never imported elsewhere)
21+
- Dead imports (imported but never used)
22+
- Unreachable code paths
23+
- Duplicate logic that should be consolidated
24+
- Files >400 LOC that should be split (flag to user, don't split without approval)
25+
- Backward compatibility shims (FORBIDDEN per CLAUDE.md — actively remove)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
You are a security reviewer for Socket Security Node.js repositories.
2+
3+
Apply these rules from CLAUDE.md exactly:
4+
5+
**Safe File Operations**: Use safeDelete()/safeDeleteSync() from @socketsecurity/lib/fs. NEVER fs.rm(), fs.rmSync(), or rm -rf. Use os.tmpdir() + fs.mkdtemp() for temp dirs. NEVER use fetch() — use httpJson/httpText/httpRequest from @socketsecurity/lib/http-request.
6+
7+
**Absolute Rules**: NEVER use npx, pnpm dlx, or yarn dlx. Use pnpm exec or pnpm run with pinned devDeps.
8+
9+
**Work Safeguards**: Scripts modifying multiple files must have backup/rollback. Git operations that rewrite history require explicit confirmation.
10+
11+
**Review checklist:**
12+
13+
1. **Secrets**: Hardcoded API keys, passwords, tokens, private keys in code or config
14+
2. **Injection**: Command injection via shell: true or string interpolation in spawn/exec. Path traversal in file operations.
15+
3. **Dependencies**: npx/dlx usage. Unpinned versions (^ or ~). Missing minimumReleaseAge bypass justification.
16+
4. **File operations**: fs.rm without safeDelete. process.chdir usage. fetch() usage (must use lib's httpRequest).
17+
5. **GitHub Actions**: Unpinned action versions (must use full SHA). Secrets outside env blocks. Template injection from untrusted inputs.
18+
6. **Error handling**: Sensitive data in error messages. Stack traces exposed to users.
19+
20+
For each finding, report:
21+
- **Severity**: CRITICAL / HIGH / MEDIUM / LOW
22+
- **Location**: file:line
23+
- **Issue**: what's wrong
24+
- **Fix**: how to fix it
25+
26+
Run `pnpm audit` for dependency vulnerabilities. Run `pnpm run security` for config/workflow scanning.

.claude/commands/bake-fresh.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Clean the kitchen, bake from scratch, taste test.
2+
3+
```bash
4+
pnpm --filter node-smol-builder clean
5+
pnpm --filter node-smol-builder build
6+
pnpm --filter node-smol-builder test
7+
```
8+
9+
Report: build time, binary size, test results, any failures.

.claude/commands/quality-loop.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Run the `/quality-scan` skill and fix all issues found. Repeat until zero issues remain or 5 iterations complete.
2+
3+
**Interactive only** — this command makes code changes and commits. Do not use as an automated pipeline gate.
4+
5+
## Process
6+
7+
1. Run `/quality-scan` skill (all scan types)
8+
2. If issues found: spawn the `refactor-cleaner` agent (see `agents/refactor-cleaner.md`) to fix them, grouped by category
9+
3. Run verify-build (see `_shared/verify-build.md`) after fixes
10+
4. Run `/quality-scan` again
11+
5. Repeat until:
12+
- Zero issues found (success), OR
13+
- 5 iterations completed (stop)
14+
6. Commit all fixes: `fix: resolve quality scan issues (iteration N)`
15+
16+
## Rules
17+
18+
- Fix every issue, not just easy ones
19+
- Spawn refactor-cleaner with CLAUDE.md's pre-action protocol: dead code first, then structural changes, ≤5 files per phase
20+
- Run tests after fixes to verify nothing broke
21+
- Track iteration count and report progress

.claude/commands/regen-patches.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Regenerate patches from pristine upstream source using the `regenerating-patches` skill.
2+
3+
## Usage
4+
5+
- `/regen-patches` - Regenerate all patches (Node.js + iocraft)
6+
- `/regen-patches node` - Node.js patches only
7+
- `/regen-patches iocraft` - iocraft patches only
8+
9+
Use the Skill tool to invoke `regenerating-patches`, passing the argument to scope which patches to regenerate.

.claude/commands/security-scan.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Run the `/security-scan` skill. This chains AgentShield (Claude config audit) → zizmor (GitHub Actions security) → security-reviewer agent (grading).
2+
3+
For a quick manual run without the full pipeline: `pnpm run security`

.claude/commands/squash-history.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Squash all commits on main branch to single "Initial commit" using the squashing-history skill.
2+
3+
Creates backup branch, soft resets, verifies code integrity, gets confirmation, force pushes.

.claude/commands/update-cacache.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# update-cacache — Update the C/C++ cacache implementation
2+
3+
Update `socket_cacache.h` to match the `@socketsecurity/lib` cacache spec.
4+
Run when the cacache format changes or cross-platform behavior needs updating.
5+
6+
## What This Updates
7+
8+
| File | Location |
9+
|------|----------|
10+
| `socket_cacache.h` | `packages/build-infra/src/socketsecurity/build-infra/socket_cacache.h` |
11+
12+
## Process
13+
14+
1. **Read the reference spec** from `@socketsecurity/lib`:
15+
- Path resolution: `../socket-sdk-js/node_modules/@socketsecurity/lib/dist/paths/socket.js`
16+
- Cacache wrapper: `../socket-sdk-js/node_modules/@socketsecurity/lib/dist/cacache.js`
17+
- Also check ultrathink implementations for consistency:
18+
- Rust: `../ultrathink/packages/acorn/lang/rust/src/socket_cacache.rs`
19+
- Go: `../ultrathink/packages/acorn/lang/go/pkg/acorn/socket_cacache.go`
20+
21+
2. **Update `socket_cacache.h`** to match:
22+
- Path resolution: env var priority (SOCKET_CACACHE_DIR > SOCKET_HOME > HOME/USERPROFILE > tmpdir)
23+
- Index: `index-v5/{sha256(key)[0:2]}/{sha256(key)[2:4]}/{sha256(key)[4:]}`
24+
- Lines: `{sha1(json)}\t{json}\n`
25+
- Content: `content-v2/sha512/{sha512_hex[0:2]}/{sha512_hex[2:4]}/{sha512_hex[4:]}`
26+
- Integrity: `sha512-{base64_with_padding(sha512(data))}`
27+
- Deletion: append `"integrity":null` (soft delete, not file delete)
28+
- Metadata: always present as `{}` (never null, never omitted)
29+
30+
3. **Cross-platform validation**:
31+
- macOS: HOME → getenv("HOME"), crypto via CommonCrypto
32+
- Linux: HOME → getenv("HOME"), crypto via OpenSSL
33+
- Windows: USERPROFILE → getenv("USERPROFILE"), crypto via CryptoAPI
34+
- Fallback: TEMP/TMP (Windows) or /tmp (Unix)
35+
36+
4. **Compile test**:
37+
```bash
38+
# macOS
39+
cc -Wall -Wextra -I. test.c -o test -framework Security
40+
41+
# Linux
42+
cc -Wall -Wextra -I. test.c -o test -lssl -lcrypto
43+
```
44+
45+
5. **Cross-language verification**:
46+
```bash
47+
# C writes, Node.js reads
48+
./test_write
49+
node -e "require('cacache').get('~/.socket/_cacache', 'key').then(r => console.log(r.data))"
50+
```
51+
52+
6. **Run Codex sanity check** — ask Codex to validate against spec.
53+
54+
7. **Commit** with: `fix(build-infra): update socket_cacache.h to match @socketsecurity/lib vX.Y.Z`
55+
56+
## Key Constraints
57+
58+
- Header-only C (static functions) — no .c file needed
59+
- `extern "C"` wrappers for C++ inclusion
60+
- No external deps beyond platform crypto
61+
- Self-contained file I/O helpers (no file_utils.h dependency)
62+
- Internal functions prefixed `scache_` to avoid namespace collisions
63+
- Must produce entries readable by Node.js `cacache@20`
64+
65+
## Reference Docs
66+
67+
- Shared cache guide: `../ultrathink/packages/build-infra/docs/shared-cache.md`
68+
- Platform dirs: `../ultrathink/packages/build-infra/lib/platform-dirs.mjs`

.claude/commands/update.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# update - Update dependencies
2+
3+
Invoke the `updating-$ARGUMENTS` skill to update a dependency.
4+
5+
Usage: `/update <name>` (e.g., `/update node` invokes `updating-node`)
6+
7+
## Available Names
8+
9+
- `all` - Update everything (npm + all upstreams)
10+
- `node` - Node.js submodule + patch regeneration
11+
- `curl` - curl and mbedtls submodules
12+
- `lief` - LIEF binary manipulation library
13+
- `stubs` - Self-extracting stub binaries
14+
- `binsuite` - Orchestrate LIEF + stubs updates
15+
- `cjson` - cJSON library
16+
- `libdeflate` - libdeflate compression library
17+
- `lzfse` - LZFSE Apple compression library
18+
- `onnxruntime` - ONNX Runtime ML engine
19+
- `ink` - ink TUI framework
20+
- `iocraft` - iocraft TUI library
21+
- `yoga` - Yoga layout library
22+
- `fast-webstreams` - Vendor fast-webstreams from npm
23+
- `checksums` - Sync SHA-256 checksums from releases
24+
25+
## Routing
26+
27+
- `/update all` invokes the `updating` skill (no suffix)
28+
- All others invoke `updating-<name>`
29+
- Empty argument: list names and ask
30+
- Unknown name: suggest closest match

0 commit comments

Comments
 (0)