@goody9807/codeview 0.1.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/README.md +40 -0
- package/bin/codeview.js +36 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @goody9807/codeview
|
|
2
|
+
|
|
3
|
+
CodeView — 把代码仓库解析成符号图存入 LanceDB,供 AI Agent 查询。
|
|
4
|
+
|
|
5
|
+
本包是 **npm 安装入口**:一个轻量透传壳(~25 行 JS),按平台 spawn 对应的 Rust 二进制并透传 argv / stdio / exit code。所有逻辑(解析、查询、文本格式化)都在 Rust binary 内。
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @goody9807/codeview
|
|
9
|
+
codeview stats /path/to/repo # 仓库索引质量汇总
|
|
10
|
+
codeview inspect <node-id> --repo /path/to/repo
|
|
11
|
+
codeview index /path/to/repo # 建立符号索引
|
|
12
|
+
codeview query --repo /path/to/repo symbols --name-prefix Foo
|
|
13
|
+
codeview status / codeview stop
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## 工作原理
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
npm i -g @goody9807/codeview
|
|
20
|
+
└─ optionalDependencies 按 os/cpu 只装一个平台子包:
|
|
21
|
+
@goody9807/codeview-darwin-arm64 | -darwin-x64 | -linux-x64 | -win32-x64
|
|
22
|
+
└─ bin/codeview.js → require.resolve(平台子包/bin/codeview) → spawn 透传
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
二进制随 npm tarball 走,无需 CDN、离线可用。壳是 Node 兼容 CJS,无需预装 Bun。
|
|
26
|
+
|
|
27
|
+
## 支持平台
|
|
28
|
+
|
|
29
|
+
| platform | arch | npm 子包 |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| darwin | arm64 | `@goody9807/codeview-darwin-arm64` |
|
|
32
|
+
| darwin | x64 | `@goody9807/codeview-darwin-x64` |
|
|
33
|
+
| linux | x64 | `@goody9807/codeview-linux-x64` |
|
|
34
|
+
| win32 | x64 | `@goody9807/codeview-win32-x64` |
|
|
35
|
+
|
|
36
|
+
Linux 需 `libstdc++`(几乎所有发行版自带)。模型文件(Qwen2.5-Coder ONNX)不打进二进制,首次运行自动下载或设 `CODEVIEW_MODEL_PATH`。
|
|
37
|
+
|
|
38
|
+
## 开发
|
|
39
|
+
|
|
40
|
+
壳源码在 `src/index.ts`,构建:`bun run build`(→ `bin/codeview.js`)。Rust 二进制构建在仓库根 `cargo build --release -p codeview`。详见仓库根 `docs/PACKAGING.md`。
|
package/bin/codeview.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var { spawn } = require("node:child_process");
|
|
3
|
+
var { argv, stderr, exit, platform, arch } = require("node:process");
|
|
4
|
+
var PLATFORM_MAP = {
|
|
5
|
+
darwin: { arm64: "darwin-arm64", x64: "darwin-x64" },
|
|
6
|
+
linux: { arm64: "linux-arm64", x64: "linux-x64" },
|
|
7
|
+
win32: { x64: "win32-x64" }
|
|
8
|
+
};
|
|
9
|
+
function fail(msg) {
|
|
10
|
+
stderr.write(msg);
|
|
11
|
+
exit(1);
|
|
12
|
+
throw new Error("unreachable");
|
|
13
|
+
}
|
|
14
|
+
function resolveBinary() {
|
|
15
|
+
const suffix = PLATFORM_MAP[platform]?.[arch];
|
|
16
|
+
if (!suffix) {
|
|
17
|
+
fail(`codeview: unsupported platform ${platform}-${arch}
|
|
18
|
+
`);
|
|
19
|
+
}
|
|
20
|
+
const pkg = `@goody9807/codeview-${suffix}`;
|
|
21
|
+
const binName = platform === "win32" ? "bin/codeview.exe" : "bin/codeview";
|
|
22
|
+
try {
|
|
23
|
+
return require.resolve(`${pkg}/${binName}`);
|
|
24
|
+
} catch {
|
|
25
|
+
fail(`codeview: platform package ${pkg} not installed.
|
|
26
|
+
` + ` try: npm install -g @goody9807/codeview
|
|
27
|
+
`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
var child = spawn(resolveBinary(), argv.slice(2), { stdio: "inherit" });
|
|
31
|
+
child.on("exit", (code) => exit(code ?? 1));
|
|
32
|
+
child.on("error", (err) => {
|
|
33
|
+
stderr.write(`codeview: failed to launch binary: ${err.message}
|
|
34
|
+
`);
|
|
35
|
+
exit(1);
|
|
36
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@goody9807/codeview",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CodeView CLI — 透传壳,spawn 平台 Rust 二进制。所有逻辑在 Rust binary 内。",
|
|
5
|
+
"bin": {
|
|
6
|
+
"codeview": "bin/codeview.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin"
|
|
10
|
+
],
|
|
11
|
+
"optionalDependencies": {
|
|
12
|
+
"@goody9807/codeview-darwin-arm64": "0.1.0",
|
|
13
|
+
"@goody9807/codeview-darwin-x64": "0.1.0",
|
|
14
|
+
"@goody9807/codeview-linux-x64": "0.1.0",
|
|
15
|
+
"@goody9807/codeview-win32-x64": "0.1.0"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "bun build src/index.ts --format=cjs --target=node --outfile bin/codeview.js",
|
|
19
|
+
"prepublishOnly": "bun run build",
|
|
20
|
+
"dev": "bun run src/index.ts",
|
|
21
|
+
"test": "bun test"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "^6.0",
|
|
25
|
+
"@types/bun": "latest",
|
|
26
|
+
"@types/node": "^22"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|