@bigfishnpm/matrixcode 0.2.4 → 0.4.17

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/README.md CHANGED
@@ -1,59 +1,34 @@
1
- # MatrixCode npm Package
1
+ # MatrixCode CLI
2
2
 
3
- 这个 npm 包是 [MatrixCode](https://github.com/bigfish1913/matrixcode) 的安装包装器。
3
+ AI coding assistant with multi-model support, context compression, and cross-session memory.
4
4
 
5
- ## 安装
5
+ ## Installation
6
6
 
7
+ ### npm
7
8
  ```bash
8
- npm install -g matrixcode
9
+ npm install -g @bigfishnpm/matrixcode
9
10
  ```
10
11
 
11
- 安装脚本会自动:
12
- 1. 检查是否已安装 `matrixcode`
13
- 2. 如果有 Rust/Cargo,使用 `cargo install matrixcode`
14
- 3. 否则从 GitHub Releases 下载预编译二进制
15
-
16
- ## 手动安装
17
-
18
- 如果自动安装失败,你可以:
19
-
12
+ ### cargo
20
13
  ```bash
21
- # 使用 Cargo
22
14
  cargo install matrixcode
23
-
24
- # 或从 GitHub Releases 下载
25
- # https://github.com/bigfish1913/matrixcode/releases
26
15
  ```
27
16
 
28
- ## 发布说明
17
+ ## Usage
29
18
 
30
- 发布新版本时:
31
-
32
- 1. 更新版本号:
33
- - `Cargo.toml` 中的 `version`
34
- - `npm/package.json` 中的 `version`
35
-
36
- 2. 发布到 crates.io:
37
- ```bash
38
- cargo login
39
- cargo publish
40
- ```
19
+ ```bash
20
+ matrixcode # Start interactive chat
21
+ matrixcode --help # Show help
22
+ ```
41
23
 
42
- 3. 发布到 npm:
43
- ```bash
44
- cd npm
45
- npm login
46
- npm publish
47
- ```
24
+ ## Features
48
25
 
49
- 4. 创建 Git tag 并推送(触发 GitHub Release):
50
- ```bash
51
- git tag v0.1.0
52
- git push origin v0.1.0
53
- ```
26
+ - Multi-model support (Claude, GPT, etc.)
27
+ - Context compression for long conversations
28
+ - Cross-session memory
29
+ - Project overview generation
30
+ - Skill system for specialized tasks
54
31
 
55
- ## 支持的平台
32
+ ## License
56
33
 
57
- - macOS (x64, Apple Silicon)
58
- - Linux (x64, arm64)
59
- - Windows (x64)
34
+ MIT
package/bin/matrixcode CHANGED
@@ -1,42 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { spawn } = require('child_process');
4
- const path = require('path');
5
- const fs = require('fs');
6
- const os = require('os');
7
-
8
- // Find the matrixcode binary
9
- const ext = os.platform() === 'win32' ? '.exe' : '';
10
- const localBin = path.join(__dirname, 'bin', `matrixcode${ext}`);
11
-
12
- let binPath = 'matrixcode'; // Default: use system-installed
13
-
14
- // If local binary exists, use it
15
- if (fs.existsSync(localBin)) {
16
- binPath = localBin;
17
- }
18
-
19
- // Spawn the actual binary with all arguments
20
- const child = spawn(binPath, process.argv.slice(2), {
21
- stdio: 'inherit',
22
- shell: os.platform() === 'win32',
23
- });
24
-
25
- child.on('error', (err) => {
26
- if (err.code === 'ENOENT') {
27
- console.error('[matrixcode] Error: matrixcode binary not found');
28
- console.error('');
29
- console.error('Please install matrixcode:');
30
- console.error(' npm install -g matrixcode');
31
- console.error(' or');
32
- console.error(' cargo install matrixcode');
33
- process.exit(1);
34
- } else {
35
- console.error('[matrixcode] Error:', err.message);
36
- process.exit(1);
37
- }
38
- });
39
-
40
- child.on('exit', (code) => {
41
- process.exitCode = code || 0;
42
- });
3
+ console.error('MatrixCode binary not found.');
4
+ console.error('Please install via cargo: cargo install matrixcode');
5
+ console.error('Or reinstall this package to download the binary.');
6
+ process.exit(1);
package/package.json CHANGED
@@ -1,43 +1,48 @@
1
1
  {
2
2
  "name": "@bigfishnpm/matrixcode",
3
- "version": "0.2.4",
4
- "description": "A smart code agent CLI with multi-model support, context compression, and task planning",
5
- "author": "bigfish1913",
3
+ "version": "0.4.17",
4
+ "description": "AI coding assistant CLI with multi-model support, context compression, and cross-session memory",
6
5
  "license": "MIT",
6
+ "author": "bigfish1913",
7
+ "homepage": "https://github.com/bigfish1913/matrixcode#readme",
7
8
  "repository": {
8
9
  "type": "git",
9
- "url": "https://github.com/bigfish1913/matrixcode.git"
10
+ "url": "git+https://github.com/bigfish1913/matrixcode.git"
10
11
  },
11
- "homepage": "https://github.com/bigfish1913/matrixcode#readme",
12
12
  "bugs": {
13
13
  "url": "https://github.com/bigfish1913/matrixcode/issues"
14
14
  },
15
15
  "keywords": [
16
16
  "ai",
17
- "llm",
18
- "code-agent",
19
17
  "cli",
20
- "anthropic",
18
+ "code-assistant",
19
+ "llm",
21
20
  "claude",
22
- "gpt",
23
- "assistant"
21
+ "anthropic",
22
+ "openai",
23
+ "gpt"
24
24
  ],
25
25
  "bin": {
26
26
  "matrixcode": "./bin/matrixcode"
27
27
  },
28
28
  "scripts": {
29
- "postinstall": "node install.js"
29
+ "postinstall": "node scripts/download.js"
30
30
  },
31
+ "files": [
32
+ "bin",
33
+ "scripts",
34
+ "README.md"
35
+ ],
31
36
  "engines": {
32
- "node": ">=16"
37
+ "node": ">=14"
33
38
  },
34
- "files": [
35
- "bin/",
36
- "install.js",
37
- "README.md",
38
- "LICENSE"
39
+ "os": [
40
+ "win32",
41
+ "darwin",
42
+ "linux"
39
43
  ],
40
- "publishConfig": {
41
- "access": "public"
42
- }
44
+ "cpu": [
45
+ "x64",
46
+ "arm64"
47
+ ]
43
48
  }
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env node
2
+
3
+ const https = require('https');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { execSync } = require('child_process');
7
+
8
+ const VERSION = require('./package.json').version;
9
+ const BIN_DIR = path.join(__dirname, 'bin');
10
+ const BIN_PATH = path.join(BIN_DIR, 'matrixcode');
11
+
12
+ // Determine platform and arch
13
+ const platform = process.platform;
14
+ const arch = process.arch;
15
+
16
+ // Map to release binary names
17
+ const binaryName = {
18
+ win32: { x64: 'matrixcode-windows-x64.exe', arm64: 'matrixcode-windows-arm64.exe' },
19
+ darwin: { x64: 'matrixcode-macos-x64', arm64: 'matrixcode-macos-arm64' },
20
+ linux: { x64: 'matrixcode-linux-x64', arm64: 'matrixcode-linux-arm64' }
21
+ };
22
+
23
+ const binary = binaryName[platform]?.[arch];
24
+ if (!binary) {
25
+ console.error(`Unsupported platform: ${platform}-${arch}`);
26
+ process.exit(1);
27
+ }
28
+
29
+ // GitHub release URL
30
+ const downloadUrl = `https://github.com/bigfish1913/matrixcode/releases/download/v${VERSION}/${binary}`;
31
+
32
+ console.log(`Downloading matrixcode v${VERSION} for ${platform}-${arch}...`);
33
+
34
+ // Download function
35
+ function download(url, dest) {
36
+ return new Promise((resolve, reject) => {
37
+ const file = fs.createWriteStream(dest);
38
+
39
+ https.get(url, (response) => {
40
+ if (response.statusCode === 302 || response.statusCode === 301) {
41
+ // Follow redirect
42
+ download(response.headers.location, dest).then(resolve).catch(reject);
43
+ return;
44
+ }
45
+
46
+ if (response.statusCode !== 200) {
47
+ reject(new Error(`Download failed: ${response.statusCode}`));
48
+ return;
49
+ }
50
+
51
+ response.pipe(file);
52
+ file.on('finish', () => {
53
+ file.close();
54
+ resolve();
55
+ });
56
+ }).on('error', (err) => {
57
+ fs.unlink(dest, () => {});
58
+ reject(err);
59
+ });
60
+ });
61
+ }
62
+
63
+ // Main
64
+ async function main() {
65
+ try {
66
+ // Ensure bin directory exists
67
+ if (!fs.existsSync(BIN_DIR)) {
68
+ fs.mkdirSync(BIN_DIR, { recursive: true });
69
+ }
70
+
71
+ // Download binary
72
+ await download(downloadUrl, BIN_PATH);
73
+
74
+ // Make executable (Unix)
75
+ if (platform !== 'win32') {
76
+ fs.chmodSync(BIN_PATH, 0o755);
77
+ }
78
+
79
+ // On Windows, rename to .exe if needed
80
+ if (platform === 'win32' && !BIN_PATH.endsWith('.exe')) {
81
+ fs.renameSync(BIN_PATH, BIN_PATH + '.exe');
82
+ }
83
+
84
+ console.log('matrixcode installed successfully!');
85
+ console.log('Run: matrixcode --help');
86
+ } catch (err) {
87
+ console.error('Installation failed:', err.message);
88
+ console.error('\nYou can also install via cargo:');
89
+ console.error(' cargo install matrixcode');
90
+ process.exit(1);
91
+ }
92
+ }
93
+
94
+ main();
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 MatrixCode Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/install.js DELETED
@@ -1,221 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { execSync, spawnSync } = require('child_process');
4
- const fs = require('fs');
5
- const path = require('path');
6
- const os = require('os');
7
- const https = require('https');
8
-
9
- const BIN_DIR = path.join(__dirname, 'bin');
10
- const PACKAGE_VERSION = require('./package.json').version;
11
-
12
- // Platform mapping for GitHub releases (matches release.yml targets)
13
- const PLATFORM_MAP = {
14
- 'darwin-x64': { target: 'x86_64-apple-darwin', archive: 'tar.gz' },
15
- 'darwin-arm64': { target: 'aarch64-apple-darwin', archive: 'tar.gz' },
16
- 'linux-x64': { target: 'x86_64-unknown-linux-gnu', archive: 'tar.gz' },
17
- 'linux-arm64': { target: 'aarch64-unknown-linux-gnu', archive: 'tar.gz' },
18
- 'win32-x64': { target: 'x86_64-pc-windows-msvc', archive: 'zip' },
19
- 'win32-arm64': { target: 'aarch64-pc-windows-msvc', archive: 'zip' },
20
- };
21
-
22
- function getPlatform() {
23
- const platform = os.platform();
24
- const arch = os.arch();
25
- const key = `${platform}-${arch}`;
26
- return PLATFORM_MAP[key] || null;
27
- }
28
-
29
- function checkCommand(cmd) {
30
- try {
31
- execSync(`${cmd} --version`, { stdio: 'ignore' });
32
- return true;
33
- } catch {
34
- return false;
35
- }
36
- }
37
-
38
- function isMatrixcodeInstalled() {
39
- try {
40
- const result = spawnSync('matrixcode', ['--version'], { stdio: 'ignore' });
41
- return result.status === 0;
42
- } catch {
43
- return false;
44
- }
45
- }
46
-
47
- function installViaCargo() {
48
- console.log('[matrixcode] Installing via cargo install matrixcode...');
49
- try {
50
- execSync('cargo install matrixcode', { stdio: 'inherit' });
51
- console.log('[matrixcode] ✓ Installed successfully via cargo');
52
- return true;
53
- } catch (error) {
54
- console.error('[matrixcode] ✗ Failed to install via cargo:', error.message);
55
- return false;
56
- }
57
- }
58
-
59
- function downloadFile(url, dest) {
60
- return new Promise((resolve, reject) => {
61
- const file = fs.createWriteStream(dest);
62
- const request = (urlString) => {
63
- https.get(urlString, (response) => {
64
- if (response.statusCode === 302 || response.statusCode === 301) {
65
- // Follow redirect
66
- request(response.headers.location);
67
- return;
68
- }
69
- if (response.statusCode !== 200) {
70
- reject(new Error(`HTTP ${response.statusCode}`));
71
- return;
72
- }
73
- response.pipe(file);
74
- file.on('finish', () => {
75
- file.close();
76
- resolve();
77
- });
78
- }).on('error', (err) => {
79
- fs.unlink(dest, () => {});
80
- reject(err);
81
- });
82
- };
83
- request(url);
84
- });
85
- }
86
-
87
- async function downloadBinary() {
88
- const platformInfo = getPlatform();
89
- if (!platformInfo) {
90
- console.error(`[matrixcode] Unsupported platform: ${os.platform()}-${os.arch()}`);
91
- console.log('[matrixcode] Falling back to cargo install...');
92
- return installViaCargo();
93
- }
94
-
95
- const { target, archive } = platformInfo;
96
- const archiveName = `matrixcode-${target}.${archive}`;
97
- const downloadUrl = `https://github.com/bigfish1913/matrixcode/releases/download/v${PACKAGE_VERSION}/${archiveName}`;
98
-
99
- console.log(`[matrixcode] Downloading binary for ${target}...`);
100
- console.log(`[matrixcode] URL: ${downloadUrl}`);
101
-
102
- // Create bin directory
103
- if (!fs.existsSync(BIN_DIR)) {
104
- fs.mkdirSync(BIN_DIR, { recursive: true });
105
- }
106
-
107
- const archivePath = path.join(BIN_DIR, archiveName);
108
- const binaryName = os.platform() === 'win32' ? 'matrixcode.exe' : 'matrixcode';
109
- const targetPath = path.join(BIN_DIR, binaryName);
110
-
111
- try {
112
- await downloadFile(downloadUrl, archivePath);
113
- console.log('[matrixcode] ✓ Download complete, extracting...');
114
- } catch (error) {
115
- console.error(`[matrixcode] ✗ Failed to download: ${error.message}`);
116
- console.log('[matrixcode] Falling back to cargo install...');
117
- return installViaCargo();
118
- }
119
-
120
- // Extract archive
121
- try {
122
- if (archive === 'tar.gz') {
123
- // Use tar to extract (available on macOS and Linux)
124
- execSync(`tar -xzf "${archivePath}" -C "${BIN_DIR}"`, { stdio: 'inherit' });
125
- } else if (archive === 'zip') {
126
- // On Windows, use PowerShell
127
- execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${BIN_DIR}' -Force"`, { stdio: 'inherit' });
128
- }
129
-
130
- // Make binary executable (Unix)
131
- if (os.platform() !== 'win32') {
132
- fs.chmodSync(targetPath, 0o755);
133
- }
134
-
135
- // Clean up archive
136
- fs.unlinkSync(archivePath);
137
-
138
- console.log('[matrixcode] ✓ Binary installed successfully');
139
- return true;
140
- } catch (error) {
141
- console.error(`[matrixcode] ✗ Failed to extract: ${error.message}`);
142
- // Clean up
143
- try { fs.unlinkSync(archivePath); } catch {}
144
- console.log('[matrixcode] Falling back to cargo install...');
145
- return installViaCargo();
146
- }
147
- }
148
-
149
- function createWrapperScript() {
150
- const ext = os.platform() === 'win32' ? '.cmd' : '';
151
- const wrapperPath = path.join(BIN_DIR, `matrixcode${ext}`);
152
-
153
- // Make sure bin directory exists
154
- if (!fs.existsSync(BIN_DIR)) {
155
- fs.mkdirSync(BIN_DIR, { recursive: true });
156
- }
157
-
158
- if (os.platform() === 'win32') {
159
- // Windows batch script
160
- const content = `@echo off
161
- matrixcode %*
162
- `;
163
- fs.writeFileSync(wrapperPath, content);
164
- } else {
165
- // Unix shell script - just call the system-installed matrixcode
166
- const content = `#!/bin/sh
167
- exec matrixcode "$@"
168
- `;
169
- fs.writeFileSync(wrapperPath, content, { mode: 0o755 });
170
- }
171
-
172
- console.log('[matrixcode] ✓ Wrapper script created');
173
- }
174
-
175
- async function main() {
176
- console.log(`[matrixcode] v${PACKAGE_VERSION}`);
177
- console.log('');
178
-
179
- // Check if matrixcode is already installed
180
- if (isMatrixcodeInstalled()) {
181
- console.log('[matrixcode] ✓ matrixcode is already installed');
182
- createWrapperScript();
183
- return;
184
- }
185
-
186
- console.log('[matrixcode] matrixcode not found, installing...');
187
- console.log('');
188
-
189
- // Prefer cargo if available (more reliable)
190
- if (checkCommand('cargo')) {
191
- console.log('[matrixcode] Found cargo, installing via cargo...');
192
- if (installViaCargo()) {
193
- createWrapperScript();
194
- return;
195
- }
196
- }
197
-
198
- // Try downloading pre-built binary
199
- if (await downloadBinary()) {
200
- return;
201
- }
202
-
203
- // Final fallback: show manual instructions
204
- console.error('');
205
- console.error('[matrixcode] ✗ Automatic installation failed');
206
- console.error('');
207
- console.error('Please install manually using one of these methods:');
208
- console.error('');
209
- console.error(' # Option 1: Using cargo (recommended)');
210
- console.error(' cargo install matrixcode');
211
- console.error('');
212
- console.error(' # Option 2: Download from GitHub Releases');
213
- console.error(' https://github.com/bigfish1913/matrixcode/releases');
214
- console.error('');
215
- process.exit(1);
216
- }
217
-
218
- main().catch(err => {
219
- console.error('[matrixcode] Installation error:', err.message);
220
- process.exit(1);
221
- });