freestyle-sync 0.1.4 → 0.1.5
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 +28 -2
- package/dist/src/main.js +317 -72
- package/package.json +17 -4
- package/dist/freestyle-sync.config.js +0 -35
- package/dist/main.js +0 -1319
- package/dist/plugins/agent-claude/src/index.js +0 -116
- package/dist/plugins/agent-codex/src/index.js +0 -68
- package/dist/plugins/agent-copilot/src/index.js +0 -529
- package/dist/plugins/auth-aws/src/index.js +0 -29
- package/dist/plugins/auth-azure/src/index.js +0 -29
- package/dist/plugins/auth-context.js +0 -213
- package/dist/plugins/auth-docker/src/index.js +0 -29
- package/dist/plugins/auth-env/src/index.js +0 -35
- package/dist/plugins/auth-gcloud/src/index.js +0 -29
- package/dist/plugins/auth-git/src/index.js +0 -50
- package/dist/plugins/auth-github-cli/src/index.js +0 -39
- package/dist/plugins/auth-npm/src/index.js +0 -38
- package/dist/plugins/auth-ssh/src/index.js +0 -42
- package/dist/plugins/auth-yarn/src/index.js +0 -24
- package/dist/plugins/node-npm/src/index.js +0 -388
- package/dist/plugins/npm-native-deps.js +0 -307
- package/dist/plugins/shell-history/src/index.js +0 -65
- package/dist/plugins/vscode/src/index.js +0 -160
- package/dist/src/pushvm.config.js +0 -36
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { execFileSync } from "node:child_process";
|
|
2
|
-
import { stat } from "node:fs/promises";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { definePlugin } from "../../../src/plugin-api.js";
|
|
6
|
-
export function claudeAgentPlugin() {
|
|
7
|
-
return definePlugin({
|
|
8
|
-
name: "@freestyle-sync/agent-claude",
|
|
9
|
-
collectEnvironment({ options }) {
|
|
10
|
-
if (!options.includeAgentContext)
|
|
11
|
-
return {};
|
|
12
|
-
const apiKey = process.env.ANTHROPIC_API_KEY || claudeApiKeyFromMacKeychain();
|
|
13
|
-
const env = {};
|
|
14
|
-
if (apiKey)
|
|
15
|
-
env.ANTHROPIC_API_KEY = apiKey;
|
|
16
|
-
return env;
|
|
17
|
-
},
|
|
18
|
-
async discoverContextCandidates({ options }) {
|
|
19
|
-
if (!options.includeAgentContext)
|
|
20
|
-
return [];
|
|
21
|
-
return existing([
|
|
22
|
-
candidate(path.join(homedir(), ".claude"), "~/.claude", "Claude context", "context:claude"),
|
|
23
|
-
candidate(path.join(homedir(), ".claude.json"), "~/.claude.json", "Claude config", "context:claude-json"),
|
|
24
|
-
]);
|
|
25
|
-
},
|
|
26
|
-
async afterProjectSync({ vm, utils }) {
|
|
27
|
-
await installAgentCli(vm, utils.checkedExec, "claude", "@anthropic-ai/claude-code");
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function claudeApiKeyFromMacKeychain() {
|
|
32
|
-
if (process.platform !== "darwin")
|
|
33
|
-
return undefined;
|
|
34
|
-
try {
|
|
35
|
-
const key = execFileSync("security", ["find-generic-password", "-s", "Claude Code", "-a", process.env.USER ?? "", "-w"], {
|
|
36
|
-
encoding: "utf8",
|
|
37
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
38
|
-
}).trim();
|
|
39
|
-
return key.startsWith("sk-ant-") ? key : undefined;
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
async function installAgentCli(vm, checkedExec, binary, packageName) {
|
|
46
|
-
await checkedExec(vm, `
|
|
47
|
-
set -e
|
|
48
|
-
export HOME="\${HOME:-/root}"
|
|
49
|
-
export NVM_DIR=/root/.nvm
|
|
50
|
-
if [ -s "$NVM_DIR/nvm.sh" ]; then
|
|
51
|
-
. "$NVM_DIR/nvm.sh"
|
|
52
|
-
nvm use --silent default >/dev/null 2>&1 || true
|
|
53
|
-
fi
|
|
54
|
-
binary_path=$(command -v ${binary} || true)
|
|
55
|
-
if [ -z "$binary_path" ] && command -v npm >/dev/null 2>&1; then
|
|
56
|
-
npm_prefix=$(npm prefix -g 2>/dev/null || true)
|
|
57
|
-
if [ -n "$npm_prefix" ] && [ -x "$npm_prefix/bin/${binary}" ]; then
|
|
58
|
-
binary_path="$npm_prefix/bin/${binary}"
|
|
59
|
-
fi
|
|
60
|
-
fi
|
|
61
|
-
if [ -z "$binary_path" ]; then
|
|
62
|
-
if ! command -v npm >/dev/null 2>&1; then
|
|
63
|
-
echo "npm is required to install ${binary}" >&2
|
|
64
|
-
exit 1
|
|
65
|
-
fi
|
|
66
|
-
npm install -g ${packageName}@latest
|
|
67
|
-
binary_path=$(command -v ${binary} || true)
|
|
68
|
-
if [ -z "$binary_path" ]; then
|
|
69
|
-
npm_prefix=$(npm prefix -g 2>/dev/null || true)
|
|
70
|
-
if [ -n "$npm_prefix" ] && [ -x "$npm_prefix/bin/${binary}" ]; then
|
|
71
|
-
binary_path="$npm_prefix/bin/${binary}"
|
|
72
|
-
fi
|
|
73
|
-
fi
|
|
74
|
-
fi
|
|
75
|
-
if [ -z "$binary_path" ]; then
|
|
76
|
-
echo "${binary} was not found after installing ${packageName}" >&2
|
|
77
|
-
exit 1
|
|
78
|
-
fi
|
|
79
|
-
mkdir -p /usr/local/bin /root/.local/bin
|
|
80
|
-
if [ "$binary_path" != "/usr/local/bin/${binary}" ]; then
|
|
81
|
-
ln -sf "$binary_path" /usr/local/bin/${binary}
|
|
82
|
-
fi
|
|
83
|
-
if [ "$binary_path" != "/root/.local/bin/${binary}" ]; then
|
|
84
|
-
ln -sf "$binary_path" /root/.local/bin/${binary}
|
|
85
|
-
fi
|
|
86
|
-
grep -qxF 'export PATH="/root/.local/bin:$PATH"' /root/.profile || printf '\n%s\n' 'export PATH="/root/.local/bin:$PATH"' >> /root/.profile
|
|
87
|
-
test -x /usr/local/bin/${binary}
|
|
88
|
-
test -x /root/.local/bin/${binary}
|
|
89
|
-
`, 600000);
|
|
90
|
-
}
|
|
91
|
-
function candidate(source, remoteRoot, label, preferenceKey) {
|
|
92
|
-
return { source, remoteRoot: expandRemoteHome(remoteRoot), label, sensitive: true, preferenceKey, promptLabel: label };
|
|
93
|
-
}
|
|
94
|
-
async function existing(candidates) {
|
|
95
|
-
const result = [];
|
|
96
|
-
for (const item of candidates)
|
|
97
|
-
if (await exists(item.source))
|
|
98
|
-
result.push(item);
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
function expandRemoteHome(value) {
|
|
102
|
-
if (value === "~")
|
|
103
|
-
return "/root";
|
|
104
|
-
if (value.startsWith("~/"))
|
|
105
|
-
return `/root/${value.slice(2)}`;
|
|
106
|
-
return value;
|
|
107
|
-
}
|
|
108
|
-
async function exists(filePath) {
|
|
109
|
-
try {
|
|
110
|
-
await stat(filePath);
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { stat } from "node:fs/promises";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { definePlugin } from "../../../src/plugin-api.js";
|
|
5
|
-
export function codexAgentPlugin() {
|
|
6
|
-
return definePlugin({
|
|
7
|
-
name: "@freestyle-sync/agent-codex",
|
|
8
|
-
async discoverContextCandidates({ options }) {
|
|
9
|
-
if (!options.includeAgentContext)
|
|
10
|
-
return [];
|
|
11
|
-
const item = { source: path.join(homedir(), ".codex"), remoteRoot: "/root/.codex", label: "Codex context", sensitive: true, preferenceKey: "context:codex", promptLabel: "Codex context" };
|
|
12
|
-
return await exists(item.source) ? [item] : [];
|
|
13
|
-
},
|
|
14
|
-
async afterProjectSync({ vm, utils }) {
|
|
15
|
-
await installAgentCli(vm, utils.checkedExec, "codex", "@openai/codex");
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
async function installAgentCli(vm, checkedExec, binary, packageName) {
|
|
20
|
-
await checkedExec(vm, `
|
|
21
|
-
set -e
|
|
22
|
-
export HOME="\${HOME:-/root}"
|
|
23
|
-
export NVM_DIR=/root/.nvm
|
|
24
|
-
if [ -s "$NVM_DIR/nvm.sh" ]; then
|
|
25
|
-
. "$NVM_DIR/nvm.sh"
|
|
26
|
-
nvm use --silent default >/dev/null 2>&1 || true
|
|
27
|
-
fi
|
|
28
|
-
binary_path=$(command -v ${binary} || true)
|
|
29
|
-
if [ -z "$binary_path" ] && command -v npm >/dev/null 2>&1; then
|
|
30
|
-
npm_prefix=$(npm prefix -g 2>/dev/null || true)
|
|
31
|
-
if [ -n "$npm_prefix" ] && [ -x "$npm_prefix/bin/${binary}" ]; then
|
|
32
|
-
binary_path="$npm_prefix/bin/${binary}"
|
|
33
|
-
fi
|
|
34
|
-
fi
|
|
35
|
-
if [ -z "$binary_path" ]; then
|
|
36
|
-
if ! command -v npm >/dev/null 2>&1; then
|
|
37
|
-
echo "npm is required to install ${binary}" >&2
|
|
38
|
-
exit 1
|
|
39
|
-
fi
|
|
40
|
-
npm install -g ${packageName}@latest
|
|
41
|
-
binary_path=$(command -v ${binary} || true)
|
|
42
|
-
if [ -z "$binary_path" ]; then
|
|
43
|
-
npm_prefix=$(npm prefix -g 2>/dev/null || true)
|
|
44
|
-
if [ -n "$npm_prefix" ] && [ -x "$npm_prefix/bin/${binary}" ]; then
|
|
45
|
-
binary_path="$npm_prefix/bin/${binary}"
|
|
46
|
-
fi
|
|
47
|
-
fi
|
|
48
|
-
fi
|
|
49
|
-
if [ -z "$binary_path" ]; then
|
|
50
|
-
echo "${binary} was not found after installing ${packageName}" >&2
|
|
51
|
-
exit 1
|
|
52
|
-
fi
|
|
53
|
-
mkdir -p /usr/local/bin
|
|
54
|
-
if [ "$binary_path" != "/usr/local/bin/${binary}" ]; then
|
|
55
|
-
ln -sf "$binary_path" /usr/local/bin/${binary}
|
|
56
|
-
fi
|
|
57
|
-
test -x /usr/local/bin/${binary}
|
|
58
|
-
`, 600000);
|
|
59
|
-
}
|
|
60
|
-
async function exists(filePath) {
|
|
61
|
-
try {
|
|
62
|
-
await stat(filePath);
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|