agent-worktree 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/bin/wt.js +59 -0
- package/install.js +55 -0
- package/package.json +26 -0
package/bin/wt.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execFileSync } = require("child_process");
|
|
4
|
+
const { join } = require("path");
|
|
5
|
+
|
|
6
|
+
// ============================================================
|
|
7
|
+
// Platform Detection
|
|
8
|
+
// ============================================================
|
|
9
|
+
|
|
10
|
+
const PLATFORMS = {
|
|
11
|
+
"darwin-arm64": "@nekocode/agent-worktree-darwin-arm64",
|
|
12
|
+
"darwin-x64": "@nekocode/agent-worktree-darwin-x64",
|
|
13
|
+
"linux-x64": "@nekocode/agent-worktree-linux-x64",
|
|
14
|
+
"win32-x64": "@nekocode/agent-worktree-win32-x64",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function getPlatformPackage() {
|
|
18
|
+
const key = `${process.platform}-${process.arch}`;
|
|
19
|
+
const pkg = PLATFORMS[key];
|
|
20
|
+
if (!pkg) {
|
|
21
|
+
console.error(`Unsupported platform: ${key}`);
|
|
22
|
+
console.error(`Supported platforms: ${Object.keys(PLATFORMS).join(", ")}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
return pkg;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ============================================================
|
|
29
|
+
// Binary Resolution
|
|
30
|
+
// ============================================================
|
|
31
|
+
|
|
32
|
+
function getBinaryPath() {
|
|
33
|
+
const pkg = getPlatformPackage();
|
|
34
|
+
const exe = process.platform === "win32" ? "wt.exe" : "wt";
|
|
35
|
+
try {
|
|
36
|
+
const pkgPath = require.resolve(`${pkg}/package.json`);
|
|
37
|
+
return join(pkgPath, "..", "bin", exe);
|
|
38
|
+
} catch {
|
|
39
|
+
console.error(`Platform package not found: ${pkg}`);
|
|
40
|
+
console.error("Try reinstalling: npm install -g agent-worktree");
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ============================================================
|
|
46
|
+
// Execute
|
|
47
|
+
// ============================================================
|
|
48
|
+
|
|
49
|
+
const binary = getBinaryPath();
|
|
50
|
+
const args = process.argv.slice(2);
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
execFileSync(binary, args, { stdio: "inherit" });
|
|
54
|
+
} catch (err) {
|
|
55
|
+
if (err.status !== undefined) {
|
|
56
|
+
process.exit(err.status);
|
|
57
|
+
}
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
package/install.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Postinstall: Verify Platform Package & Install Shell Wrapper
|
|
3
|
+
// ============================================================
|
|
4
|
+
|
|
5
|
+
const { execFileSync } = require("child_process");
|
|
6
|
+
const { join } = require("path");
|
|
7
|
+
|
|
8
|
+
// ============================================================
|
|
9
|
+
// Platform Verification
|
|
10
|
+
// ============================================================
|
|
11
|
+
|
|
12
|
+
const PLATFORMS = {
|
|
13
|
+
"darwin-arm64": "@nekocode/agent-worktree-darwin-arm64",
|
|
14
|
+
"darwin-x64": "@nekocode/agent-worktree-darwin-x64",
|
|
15
|
+
"linux-x64": "@nekocode/agent-worktree-linux-x64",
|
|
16
|
+
"win32-x64": "@nekocode/agent-worktree-win32-x64",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const key = `${process.platform}-${process.arch}`;
|
|
20
|
+
const pkg = PLATFORMS[key];
|
|
21
|
+
|
|
22
|
+
if (!pkg) {
|
|
23
|
+
console.warn(`[agent-worktree] Warning: Unsupported platform ${key}`);
|
|
24
|
+
console.warn(`[agent-worktree] Supported: ${Object.keys(PLATFORMS).join(", ")}`);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let binaryPath;
|
|
29
|
+
try {
|
|
30
|
+
const pkgPath = require.resolve(`${pkg}/package.json`);
|
|
31
|
+
const exe = process.platform === "win32" ? "wt.exe" : "wt";
|
|
32
|
+
binaryPath = join(pkgPath, "..", "bin", exe);
|
|
33
|
+
} catch {
|
|
34
|
+
console.warn(`[agent-worktree] Warning: Platform package ${pkg} not installed`);
|
|
35
|
+
console.warn(`[agent-worktree] This may happen if npm failed to install optional dependencies`);
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ============================================================
|
|
40
|
+
// Shell Wrapper Installation
|
|
41
|
+
// ============================================================
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
console.log("[agent-worktree] Installing shell integration...");
|
|
45
|
+
execFileSync(binaryPath, ["setup"], { stdio: "inherit" });
|
|
46
|
+
if (process.platform === "win32") {
|
|
47
|
+
console.log("[agent-worktree] Shell integration installed. Restart PowerShell to apply changes.");
|
|
48
|
+
} else {
|
|
49
|
+
console.log("[agent-worktree] Shell integration installed. Restart your shell or run: source ~/.bashrc (or ~/.zshrc)");
|
|
50
|
+
}
|
|
51
|
+
} catch (err) {
|
|
52
|
+
// Non-fatal: user can run `wt setup` manually
|
|
53
|
+
console.warn("[agent-worktree] Warning: Could not install shell integration automatically");
|
|
54
|
+
console.warn("[agent-worktree] Run 'wt setup' manually to enable shell integration");
|
|
55
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-worktree",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Git worktree workflow tool for AI agents",
|
|
5
|
+
"keywords": ["cli", "git", "worktree", "ai", "agent"],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/nekocode/agent-worktree"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"wt": "bin/wt.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "node install.js"
|
|
16
|
+
},
|
|
17
|
+
"optionalDependencies": {
|
|
18
|
+
"@nekocode/agent-worktree-darwin-arm64": "0.1.0",
|
|
19
|
+
"@nekocode/agent-worktree-darwin-x64": "0.1.0",
|
|
20
|
+
"@nekocode/agent-worktree-linux-x64": "0.1.0",
|
|
21
|
+
"@nekocode/agent-worktree-win32-x64": "0.1.0"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=14"
|
|
25
|
+
}
|
|
26
|
+
}
|