freestyle-sync 0.1.3 → 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.
Files changed (40) hide show
  1. package/README.md +28 -2
  2. package/{src/main.ts → dist/src/main.js} +597 -531
  3. package/dist/src/plugin-api.js +6 -0
  4. package/package.json +23 -6
  5. package/PUBLISHING.md +0 -3
  6. package/freestyle-sync.config.ts +0 -36
  7. package/plugins/agent-claude/package.json +0 -8
  8. package/plugins/agent-claude/src/index.ts +0 -113
  9. package/plugins/agent-codex/package.json +0 -8
  10. package/plugins/agent-codex/src/index.ts +0 -69
  11. package/plugins/agent-copilot/package.json +0 -8
  12. package/plugins/agent-copilot/src/index.ts +0 -552
  13. package/plugins/auth-aws/package.json +0 -8
  14. package/plugins/auth-aws/src/index.ts +0 -23
  15. package/plugins/auth-azure/package.json +0 -8
  16. package/plugins/auth-azure/src/index.ts +0 -23
  17. package/plugins/auth-docker/package.json +0 -8
  18. package/plugins/auth-docker/src/index.ts +0 -23
  19. package/plugins/auth-env/package.json +0 -8
  20. package/plugins/auth-env/src/index.ts +0 -35
  21. package/plugins/auth-gcloud/package.json +0 -8
  22. package/plugins/auth-gcloud/src/index.ts +0 -23
  23. package/plugins/auth-git/package.json +0 -8
  24. package/plugins/auth-git/src/index.ts +0 -43
  25. package/plugins/auth-github-cli/package.json +0 -8
  26. package/plugins/auth-github-cli/src/index.ts +0 -33
  27. package/plugins/auth-npm/package.json +0 -8
  28. package/plugins/auth-npm/src/index.ts +0 -32
  29. package/plugins/auth-ssh/package.json +0 -8
  30. package/plugins/auth-ssh/src/index.ts +0 -36
  31. package/plugins/auth-yarn/package.json +0 -8
  32. package/plugins/auth-yarn/src/index.ts +0 -19
  33. package/plugins/node-npm/package.json +0 -8
  34. package/plugins/node-npm/src/index.ts +0 -390
  35. package/plugins/shell-history/package.json +0 -8
  36. package/plugins/shell-history/src/index.ts +0 -64
  37. package/plugins/vscode/package.json +0 -8
  38. package/plugins/vscode/src/index.ts +0 -162
  39. package/src/plugin-api.ts +0 -110
  40. package/tsconfig.json +0 -18
@@ -0,0 +1,6 @@
1
+ export function definePlugin(plugin) {
2
+ return plugin;
3
+ }
4
+ export function defineConfig(config) {
5
+ return config;
6
+ }
package/package.json CHANGED
@@ -1,23 +1,28 @@
1
1
  {
2
2
  "name": "freestyle-sync",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
- "main": "src/main.ts",
5
+ "main": "dist/src/main.js",
6
6
  "exports": {
7
- ".": "./src/main.ts"
7
+ ".": "./dist/src/main.js"
8
8
  },
9
+ "files": [
10
+ "dist/src"
11
+ ],
9
12
  "workspaces": [
10
13
  "plugins/*"
11
14
  ],
12
15
  "bin": {
13
- "freestyle-sync": "src/main.ts"
16
+ "freestyle-sync": "dist/src/main.js"
14
17
  },
15
18
  "engines": {
16
19
  "node": ">=24"
17
20
  },
18
21
  "scripts": {
19
- "build": "tsc -p tsconfig.json",
22
+ "build": "rm -rf dist plugins/*/dist && tsc -p tsconfig.json && node scripts/prepare-plugin-packages.mjs",
20
23
  "check": "tsc --noEmit -p tsconfig.json",
24
+ "prepack": "npm run build",
25
+ "publish": "npm run check && npm run build && npm publish --workspaces --access public && npm publish",
21
26
  "start": "node src/main.ts"
22
27
  },
23
28
  "dependencies": {
@@ -27,5 +32,17 @@
27
32
  "devDependencies": {
28
33
  "@types/node": "^24.10.1",
29
34
  "typescript": "^5.9.3"
30
- }
35
+ },
36
+ "description": "Sync your current directory, it's dependencies, and your agent context into a VM. VM snapshots ensure only changes are uploaded.",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/freestyle-sh/freestyle-sync.git"
40
+ },
41
+ "keywords": [],
42
+ "author": "",
43
+ "license": "ISC",
44
+ "bugs": {
45
+ "url": "https://github.com/freestyle-sh/freestyle-sync/issues"
46
+ },
47
+ "homepage": "https://github.com/freestyle-sh/freestyle-sync#readme"
31
48
  }
package/PUBLISHING.md DELETED
@@ -1,3 +0,0 @@
1
- ```
2
- npm run check && npm run build && npm publish && npm publish --workspaces --access public
3
- ```
@@ -1,36 +0,0 @@
1
- import { claudeAgentPlugin } from "@freestyle-sync/agent-claude";
2
- import { codexAgentPlugin } from "@freestyle-sync/agent-codex";
3
- import { copilotAgentPlugin } from "@freestyle-sync/agent-copilot";
4
- import { awsAuthPlugin } from "@freestyle-sync/auth-aws";
5
- import { azureAuthPlugin } from "@freestyle-sync/auth-azure";
6
- import { dockerAuthPlugin } from "@freestyle-sync/auth-docker";
7
- import { envAuthPlugin } from "@freestyle-sync/auth-env";
8
- import { gcloudAuthPlugin } from "@freestyle-sync/auth-gcloud";
9
- import { gitAuthPlugin } from "@freestyle-sync/auth-git";
10
- import { githubCliAuthPlugin } from "@freestyle-sync/auth-github-cli";
11
- import { npmAuthPlugin } from "@freestyle-sync/auth-npm";
12
- import { sshAuthPlugin } from "@freestyle-sync/auth-ssh";
13
- import { yarnAuthPlugin } from "@freestyle-sync/auth-yarn";
14
- import { nodeNpmPlugin } from "@freestyle-sync/node-npm";
15
- import { shellHistoryPlugin } from "@freestyle-sync/shell-history";
16
- import { defineConfig } from "./src/plugin-api.ts";
17
-
18
- export default defineConfig({
19
- plugins: [
20
- envAuthPlugin(),
21
- gitAuthPlugin(),
22
- sshAuthPlugin(),
23
- githubCliAuthPlugin(),
24
- npmAuthPlugin(),
25
- yarnAuthPlugin(),
26
- dockerAuthPlugin(),
27
- awsAuthPlugin(),
28
- azureAuthPlugin(),
29
- gcloudAuthPlugin(),
30
- nodeNpmPlugin(),
31
- claudeAgentPlugin(),
32
- codexAgentPlugin(),
33
- copilotAgentPlugin(),
34
- shellHistoryPlugin(),
35
- ],
36
- });
@@ -1,8 +0,0 @@
1
- {
2
- "name": "@freestyle-sync/agent-claude",
3
- "version": "0.1.0",
4
- "type": "module",
5
- "exports": {
6
- ".": "./src/index.ts"
7
- }
8
- }
@@ -1,113 +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, type ContextCandidate, type PushvmPluginUtils, type RemoteVm } from "../../../src/plugin-api.ts";
6
-
7
- export function claudeAgentPlugin() {
8
- return definePlugin({
9
- name: "@freestyle-sync/agent-claude",
10
- collectEnvironment({ options }) {
11
- if (!options.includeAgentContext) return {};
12
- const apiKey = process.env.ANTHROPIC_API_KEY || claudeApiKeyFromMacKeychain();
13
- const env: Record<string, string> = {};
14
- if (apiKey) env.ANTHROPIC_API_KEY = apiKey;
15
- return env;
16
- },
17
- async discoverContextCandidates({ options }) {
18
- if (!options.includeAgentContext) return [];
19
- return existing([
20
- candidate(path.join(homedir(), ".claude"), "~/.claude", "Claude context", "context:claude"),
21
- candidate(path.join(homedir(), ".claude.json"), "~/.claude.json", "Claude config", "context:claude-json"),
22
- ]);
23
- },
24
- async afterProjectSync({ vm, utils }) {
25
- await installAgentCli(vm, utils.checkedExec, "claude", "@anthropic-ai/claude-code");
26
- },
27
- });
28
- }
29
-
30
- function claudeApiKeyFromMacKeychain() {
31
- if (process.platform !== "darwin") return undefined;
32
- try {
33
- const key = execFileSync("security", ["find-generic-password", "-s", "Claude Code", "-a", process.env.USER ?? "", "-w"], {
34
- encoding: "utf8",
35
- stdio: ["ignore", "pipe", "ignore"],
36
- }).trim();
37
- return key.startsWith("sk-ant-") ? key : undefined;
38
- } catch {
39
- return undefined;
40
- }
41
- }
42
-
43
- async function installAgentCli(
44
- vm: RemoteVm,
45
- checkedExec: PushvmPluginUtils["checkedExec"],
46
- binary: string,
47
- packageName: string,
48
- ) {
49
- await checkedExec(vm, `
50
- set -e
51
- export HOME="\${HOME:-/root}"
52
- export NVM_DIR=/root/.nvm
53
- if [ -s "$NVM_DIR/nvm.sh" ]; then
54
- . "$NVM_DIR/nvm.sh"
55
- nvm use --silent default >/dev/null 2>&1 || true
56
- fi
57
- binary_path=$(command -v ${binary} || true)
58
- if [ -z "$binary_path" ] && command -v npm >/dev/null 2>&1; then
59
- npm_prefix=$(npm prefix -g 2>/dev/null || true)
60
- if [ -n "$npm_prefix" ] && [ -x "$npm_prefix/bin/${binary}" ]; then
61
- binary_path="$npm_prefix/bin/${binary}"
62
- fi
63
- fi
64
- if [ -z "$binary_path" ]; then
65
- if ! command -v npm >/dev/null 2>&1; then
66
- echo "npm is required to install ${binary}" >&2
67
- exit 1
68
- fi
69
- npm install -g ${packageName}@latest
70
- binary_path=$(command -v ${binary} || true)
71
- if [ -z "$binary_path" ]; then
72
- npm_prefix=$(npm prefix -g 2>/dev/null || true)
73
- if [ -n "$npm_prefix" ] && [ -x "$npm_prefix/bin/${binary}" ]; then
74
- binary_path="$npm_prefix/bin/${binary}"
75
- fi
76
- fi
77
- fi
78
- if [ -z "$binary_path" ]; then
79
- echo "${binary} was not found after installing ${packageName}" >&2
80
- exit 1
81
- fi
82
- mkdir -p /usr/local/bin /root/.local/bin
83
- if [ "$binary_path" != "/usr/local/bin/${binary}" ]; then
84
- ln -sf "$binary_path" /usr/local/bin/${binary}
85
- fi
86
- if [ "$binary_path" != "/root/.local/bin/${binary}" ]; then
87
- ln -sf "$binary_path" /root/.local/bin/${binary}
88
- fi
89
- grep -qxF 'export PATH="/root/.local/bin:$PATH"' /root/.profile || printf '\n%s\n' 'export PATH="/root/.local/bin:$PATH"' >> /root/.profile
90
- test -x /usr/local/bin/${binary}
91
- test -x /root/.local/bin/${binary}
92
- `, 600000);
93
- }
94
-
95
- function candidate(source: string, remoteRoot: string, label: string, preferenceKey: string): ContextCandidate {
96
- return { source, remoteRoot: expandRemoteHome(remoteRoot), label, sensitive: true, preferenceKey, promptLabel: label };
97
- }
98
-
99
- async function existing(candidates: ContextCandidate[]) {
100
- const result: ContextCandidate[] = [];
101
- for (const item of candidates) if (await exists(item.source)) result.push(item);
102
- return result;
103
- }
104
-
105
- function expandRemoteHome(value: string) {
106
- if (value === "~") return "/root";
107
- if (value.startsWith("~/")) return `/root/${value.slice(2)}`;
108
- return value;
109
- }
110
-
111
- async function exists(filePath: string) {
112
- try { await stat(filePath); return true; } catch { return false; }
113
- }
@@ -1,8 +0,0 @@
1
- {
2
- "name": "@freestyle-sync/agent-codex",
3
- "version": "0.1.0",
4
- "type": "module",
5
- "exports": {
6
- ".": "./src/index.ts"
7
- }
8
- }
@@ -1,69 +0,0 @@
1
- import { stat } from "node:fs/promises";
2
- import { homedir } from "node:os";
3
- import path from "node:path";
4
- import { definePlugin, type ContextCandidate, type PushvmPluginUtils, type RemoteVm } from "../../../src/plugin-api.ts";
5
-
6
- export function codexAgentPlugin() {
7
- return definePlugin({
8
- name: "@freestyle-sync/agent-codex",
9
- async discoverContextCandidates({ options }) {
10
- if (!options.includeAgentContext) return [];
11
- const item: ContextCandidate = { 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
-
20
- async function installAgentCli(
21
- vm: RemoteVm,
22
- checkedExec: PushvmPluginUtils["checkedExec"],
23
- binary: string,
24
- packageName: string,
25
- ) {
26
- await checkedExec(vm, `
27
- set -e
28
- export HOME="\${HOME:-/root}"
29
- export NVM_DIR=/root/.nvm
30
- if [ -s "$NVM_DIR/nvm.sh" ]; then
31
- . "$NVM_DIR/nvm.sh"
32
- nvm use --silent default >/dev/null 2>&1 || true
33
- fi
34
- binary_path=$(command -v ${binary} || true)
35
- if [ -z "$binary_path" ] && command -v npm >/dev/null 2>&1; then
36
- npm_prefix=$(npm prefix -g 2>/dev/null || true)
37
- if [ -n "$npm_prefix" ] && [ -x "$npm_prefix/bin/${binary}" ]; then
38
- binary_path="$npm_prefix/bin/${binary}"
39
- fi
40
- fi
41
- if [ -z "$binary_path" ]; then
42
- if ! command -v npm >/dev/null 2>&1; then
43
- echo "npm is required to install ${binary}" >&2
44
- exit 1
45
- fi
46
- npm install -g ${packageName}@latest
47
- binary_path=$(command -v ${binary} || true)
48
- if [ -z "$binary_path" ]; then
49
- npm_prefix=$(npm prefix -g 2>/dev/null || true)
50
- if [ -n "$npm_prefix" ] && [ -x "$npm_prefix/bin/${binary}" ]; then
51
- binary_path="$npm_prefix/bin/${binary}"
52
- fi
53
- fi
54
- fi
55
- if [ -z "$binary_path" ]; then
56
- echo "${binary} was not found after installing ${packageName}" >&2
57
- exit 1
58
- fi
59
- mkdir -p /usr/local/bin
60
- if [ "$binary_path" != "/usr/local/bin/${binary}" ]; then
61
- ln -sf "$binary_path" /usr/local/bin/${binary}
62
- fi
63
- test -x /usr/local/bin/${binary}
64
- `, 600000);
65
- }
66
-
67
- async function exists(filePath: string) {
68
- try { await stat(filePath); return true; } catch { return false; }
69
- }
@@ -1,8 +0,0 @@
1
- {
2
- "name": "@freestyle-sync/agent-copilot",
3
- "version": "0.1.0",
4
- "type": "module",
5
- "exports": {
6
- ".": "./src/index.ts"
7
- }
8
- }