tsra-code 0.0.0-stage → 1.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.
package/LICENSE ADDED
@@ -0,0 +1,6 @@
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2026 Вышегуров Мусса Адамович <mussa.gurov06@gmail.com>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
package/README.md CHANGED
@@ -1,3 +1,58 @@
1
- # Temporary Holding Version
1
+ # TSRA_code (tsra-code)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > High-Speed Terminal Code Synthesis, Cyber-Security Audit & Senior Staff Engineering Suite.
4
+ > **Author:** Вышегуров Мусса Адамович (<mussa.gurov06@gmail.com>)
5
+ > **License:** AGPL-3.0-or-later
6
+ > **SLO:** Sub-Millisecond Architecture Splicing (< 1 ms local I/O)
7
+
8
+ ## Quick Installation
9
+
10
+ Add directly to your system `$PATH` via npm:
11
+
12
+ ```bash
13
+ npm install -g tsra-code
14
+ ```
15
+
16
+ Or run directly without installation:
17
+
18
+ ```bash
19
+ npx tsra-code synth "SPSC RingBuffer на Rust" -o ./ringbuffer
20
+ ```
21
+
22
+ ---
23
+
24
+ ## Commands
25
+
26
+ ### 1. Architecture Synthesis (`synth`)
27
+ Queries the remote knowledge engine for a compact architectural blueprint and locally materializes multi-file projects on your SSD in under 1 millisecond:
28
+ ```bash
29
+ tsra-code synth "SPSC RingBuffer на Rust" -o ./ringbuffer
30
+ cd ./ringbuffer && cargo test --release
31
+ ```
32
+
33
+ ### 2. Cyber Security & AppSec Auditor (`audit`)
34
+ Recursively scans files for CWE-89 (SQL Injection), CWE-78 (Command Execution), CWE-798 (Hardcoded Secrets), and automatically applies security patches:
35
+ ```bash
36
+ # Scan directory
37
+ tsra-code audit ./src
38
+
39
+ # Auto-fix vulnerabilities and save .bak backup
40
+ tsra-code audit /path/to/vulnerable_code.py --fix
41
+ ```
42
+
43
+ ### 3. Senior Staff Code Review (`review`)
44
+ Deep complexity and memory allocation review (Big-O Time/Space, Heap in loops, Lock-Free concurrency):
45
+ ```bash
46
+ tsra-code review src/main.rs
47
+ ```
48
+
49
+ ### 4. System Diagnostics (`doctor`)
50
+ Verifies server connectivity, WAN RTT latency, local compiler toolchains, and hardware NEON acceleration:
51
+ ```bash
52
+ tsra-code doctor
53
+ ```
54
+
55
+ ### 5. Interactive Shell (`repl`)
56
+ ```bash
57
+ tsra-code
58
+ ```
package/bin/tsra-code ADDED
Binary file
Binary file
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * TSRA_code: Professional Terminal Tool for Developers & AppSec Engineers
5
+ * Zero-Token Code Generation • Cyber Security Hardening • Architectural Synthesis
6
+ * Author: Вышегуров Мусса Адамович <mussa.gurov06@gmail.com>
7
+ * License: AGPL-3.0-or-later
8
+ */
9
+
10
+ const { spawnSync } = require('child_process');
11
+ const path = require('path');
12
+ const fs = require('fs');
13
+ const os = require('os');
14
+ const https = require('https');
15
+ const http = require('http');
16
+
17
+ const platform = os.platform();
18
+ const arch = os.arch();
19
+
20
+ // 1. First priority: Run bare-metal native binary if available
21
+ const nativeName = `tsra-code-${platform}-${arch}`;
22
+ const nativeBinPath = path.join(__dirname, nativeName);
23
+ const localBinPath = path.join(__dirname, 'tsra-code');
24
+
25
+ let targetBin = null;
26
+ if (fs.existsSync(nativeBinPath)) {
27
+ targetBin = nativeBinPath;
28
+ } else if (fs.existsSync(localBinPath) && platform === 'darwin' && arch === 'arm64') {
29
+ targetBin = localBinPath;
30
+ }
31
+
32
+ if (targetBin) {
33
+ try {
34
+ fs.chmodSync(targetBin, 0o755);
35
+ const result = spawnSync(targetBin, process.argv.slice(2), {
36
+ stdio: 'inherit',
37
+ env: process.env
38
+ });
39
+ if (result.status !== null) {
40
+ process.exit(result.status);
41
+ }
42
+ } catch (err) {
43
+ // If native execution fails, fallback to cross-platform node driver
44
+ }
45
+ }
46
+
47
+ // 2. Cross-Platform Node.js Driver for Linux x64 / Windows / Other environments
48
+ const SERVER_URL = process.env.TSRA_SERVER || 'https://synapseecosystem.qzz.io';
49
+ const args = process.argv.slice(2);
50
+
51
+ function printBanner() {
52
+ console.log('\x1b[38;2;64;224;208m');
53
+ console.log(' ┌────────────────────────────────────────────────────────────────────────┐');
54
+ console.log(' │ ████████╗███████╗██████╗ █████╗ ██████╗ ██████╗ ██████╗ ███████╗ │');
55
+ console.log(' │ ╚══██╔══╝██╔════╝██╔══██╗██╔══██╗ ██╔════╝██╔═══██╗██╔══██╗██╔════╝ │');
56
+ console.log(' │ ██║ ███████╗██████╔╝███████║█████╗██║ ██║ ██║██║ ██║█████╗ │');
57
+ console.log(' │ ██║ ╚════██║██╔══██╗██╔══██║╚════╝██║ ██║ ██║██║ ██║██╔══╝ │');
58
+ console.log(' │ ██║ ███████║██║ ██║██║ ██║ ╚██████╗╚██████╔╝██████╔╝███████╗ │');
59
+ console.log(' │ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ │');
60
+ console.log(' │ HIGH-SPEED CODE SYNTHESIS & CYBER SECURITY ENGINE │');
61
+ console.log(' └────────────────────────────────────────────────────────────────────────┘\x1b[0m');
62
+ console.log(' \x1b[38;2;80;227;145m[CORE]\x1b[0m Sub-Millisecond SLO \x1b[38;2;186;104;200m[SEC]\x1b[0m Zero-Vulnerability Guarantee \x1b[38;2;79;140;255m[NPM]\x1b[0m Universal CLI\n');
63
+ }
64
+
65
+ function postJson(urlStr, data) {
66
+ return new Promise((resolve, reject) => {
67
+ const url = new URL(urlStr);
68
+ const postData = JSON.stringify(data);
69
+ const client = url.protocol === 'https:' ? https : http;
70
+
71
+ const req = client.request(url, {
72
+ method: 'POST',
73
+ headers: {
74
+ 'Content-Type': 'application/json',
75
+ 'Content-Length': Buffer.byteLength(postData)
76
+ },
77
+ timeout: 10000
78
+ }, (res) => {
79
+ let body = '';
80
+ res.on('data', chunk => body += chunk);
81
+ res.on('end', () => {
82
+ try {
83
+ resolve(JSON.parse(body));
84
+ } catch (e) {
85
+ resolve({ error: body });
86
+ }
87
+ });
88
+ });
89
+
90
+ req.on('error', reject);
91
+ req.on('timeout', () => {
92
+ req.destroy();
93
+ reject(new Error('Request timed out'));
94
+ });
95
+ req.write(postData);
96
+ req.end();
97
+ });
98
+ }
99
+
100
+ function getJson(urlStr) {
101
+ return new Promise((resolve, reject) => {
102
+ const url = new URL(urlStr);
103
+ const client = url.protocol === 'https:' ? https : http;
104
+ client.get(url, { timeout: 5000 }, (res) => {
105
+ let body = '';
106
+ res.on('data', chunk => body += chunk);
107
+ res.on('end', () => {
108
+ try {
109
+ resolve(JSON.parse(body));
110
+ } catch (e) {
111
+ resolve({ error: body });
112
+ }
113
+ });
114
+ }).on('error', reject);
115
+ });
116
+ }
117
+
118
+ async function run() {
119
+ if (args.length === 0 || args[0] === 'help' || args[0] === '--help' || args[0] === '-h') {
120
+ printBanner();
121
+ console.log('\x1b[1mИспользование:\x1b[0m tsra-code <КОМАНДА> [ОПЦИИ]\n');
122
+ console.log('\x1b[38;2;64;224;208mКОМАНДЫ ДЛЯ РАЗРАБОТЧИКА И APPSEC:\x1b[0m\n');
123
+ console.log(' \x1b[1msynth\x1b[0m "<описание>" [-o <папка>] [--lang <rust|go|ts|py>]');
124
+ console.log(' Синтезирует архитектурный блюпринт на сервере и локально развертывает файлы (< 1 мс)\n');
125
+ console.log(' \x1b[1maudit\x1b[0m [файл/папка] [--fix]');
126
+ console.log(' Аудит безопасности кода (CWE-89 SQLi, CWE-78 RCE, CWE-798 Secrets, переполнения)\n');
127
+ console.log(' \x1b[1mreview\x1b[0m <файл>');
128
+ console.log(' Senior Staff архитектурное ревью: сложность Big-O, аллокации в куче, гонки данных\n');
129
+ console.log(' \x1b[1mdoctor\x1b[0m Диагностика связи с сервером (synapseecosystem.qzz.io), задержка RTT\n');
130
+ return;
131
+ }
132
+
133
+ const cmd = args[0];
134
+
135
+ if (cmd === 'doctor') {
136
+ printBanner();
137
+ console.log('\x1b[38;2;64;224;208m━━━ TSRA_code System Diagnostics & Network Probe ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m');
138
+ console.log(` \x1b[38;2;79;140;255m▸\x1b[0m Удаленный сервер: ${SERVER_URL}`);
139
+ const t0 = Date.now();
140
+ try {
141
+ const health = await getJson(`${SERVER_URL}/api/v1/health`);
142
+ const rtt = Date.now() - t0;
143
+ console.log(` \x1b[38;2;80;227;145m✔\x1b[0m Связь с сервером: Статус: ${health.status} | RTT: \x1b[38;2;80;227;145m[⏱ ${rtt} ms]\x1b[0m | Движок: ${health.engine}`);
144
+ } catch (e) {
145
+ console.log(` \x1b[38;2;255;204;0m▲\x1b[0m Сервер недоступен: ${e.message}`);
146
+ }
147
+ console.log(` \x1b[38;2;80;227;145m✔\x1b[0m Платформа: ${platform}-${arch} (Node.js ${process.version})\n`);
148
+ return;
149
+ }
150
+
151
+ if (cmd === 'synth') {
152
+ const prompt = args[1] || 'SPSC RingBuffer на Rust';
153
+ let outDir = './tsra_project';
154
+ const oIdx = args.indexOf('-o');
155
+ if (oIdx !== -1 && args[oIdx + 1]) {
156
+ outDir = args[oIdx + 1];
157
+ }
158
+
159
+ console.log('\x1b[38;2;64;224;208m━━━ TSRA_code Architecture Synthesizer ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1b[0m');
160
+ console.log(` \x1b[38;2;79;140;255m▸\x1b[0m Запрос: "${prompt}"`);
161
+ console.log(` \x1b[38;2;79;140;255m▸\x1b[0m Сервер: ${SERVER_URL}`);
162
+
163
+ const t0 = Date.now();
164
+ const bp = await postJson(`${SERVER_URL}/api/v1/code/blueprint`, { prompt });
165
+ const rtt = Date.now() - t0;
166
+
167
+ if (bp.error) {
168
+ console.log(` \x1b[38;2;255;92;92m✖\x1b[0m Сбой: ${bp.error}`);
169
+ return;
170
+ }
171
+
172
+ console.log(` \x1b[38;2;80;227;145m✔\x1b[0m Блюпринт получен: Проект: ${bp.project_name} | Файлов: ${bp.files.length} | \x1b[38;2;80;227;145m[⏱ ${rtt} ms]\x1b[0m`);
173
+
174
+ // Materialize locally
175
+ const absOut = path.resolve(outDir);
176
+ fs.mkdirSync(absOut, { recursive: true });
177
+
178
+ let totalBytes = 0;
179
+ const tWrite = Date.now();
180
+ for (const f of bp.files) {
181
+ const fullPath = path.join(absOut, f.path);
182
+ fs.mkdirSync(path.dirname(fullPath), { recursive: true });
183
+ fs.writeFileSync(fullPath, f.content, 'utf8');
184
+ if (f.executable && platform !== 'win32') {
185
+ fs.chmodSync(fullPath, 0o755);
186
+ }
187
+ totalBytes += Buffer.byteLength(f.content, 'utf8');
188
+ }
189
+ const writeMs = Date.now() - tWrite;
190
+
191
+ console.log(` \x1b[38;2;80;227;145m✔\x1b[0m Файлы созданы: ${bp.files.length} файлов, ${totalBytes} байт записано за \x1b[38;2;80;227;145m[⏱ ${writeMs} ms]\x1b[0m! [✓ PASS: Local Zero-Copy I/O]\n`);
192
+ console.log(' \x1b[38;2;64;224;208mСозданные файлы:\x1b[0m');
193
+ for (const f of bp.files) {
194
+ console.log(` \x1b[38;2;79;140;255m•\x1b[0m ${f.path} \x1b[38;2;120;120;140m— ${f.description}\x1b[0m`);
195
+ }
196
+ if (bp.verify_command) {
197
+ console.log(`\n \x1b[1mКоманда проверки:\x1b[0m \`cd ${outDir} && ${bp.verify_command}\`\n`);
198
+ }
199
+ return;
200
+ }
201
+
202
+ // Fallback: general query
203
+ const query = args.join(' ');
204
+ const res = await postJson(`${SERVER_URL}/api/v1/code/query`, { query });
205
+ if (res.answer) {
206
+ console.log(`\n${res.answer}\n`);
207
+ } else {
208
+ console.log(res);
209
+ }
210
+ }
211
+
212
+ run().catch(err => {
213
+ console.error('\x1b[38;2;255;92;92m✖ Ошибка:\x1b[0m', err.message);
214
+ process.exit(1);
215
+ });
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "tsra-code",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "description": "TSRA_code: High-Speed Terminal Code Synthesis, Cyber-Security Audit & Senior Staff Engineering Suite",
5
+ "main": "bin/tsra-code.js",
6
+ "bin": {
7
+ "tsra-code": "bin/tsra-code.js"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "scripts": {
15
+ "test": "node bin/tsra-code.js doctor"
16
+ },
17
+ "keywords": [
18
+ "tsra",
19
+ "tsra-code",
20
+ "appsec",
21
+ "cybersecurity",
22
+ "code-synthesis",
23
+ "rust",
24
+ "high-performance",
25
+ "terminal-tool",
26
+ "cli"
27
+ ],
28
+ "author": "Вышегуров Мусса Адамович <mussa.gurov06@gmail.com>",
29
+ "license": "AGPL-3.0-or-later",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/Fastop06/HImadaOS"
33
+ },
34
+ "engines": {
35
+ "node": ">=16.0.0"
36
+ }
37
+ }