agentlink-sh 0.28.0 → 0.30.1

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.
@@ -1,194 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/utils.ts
4
- import { execSync, spawn } from "child_process";
5
- import crypto from "crypto";
6
- import fs from "fs";
7
- import path from "path";
8
- var LOG_FILE = "agentlink-debug.log";
9
- var debugEnabled = false;
10
- var logInitialized = false;
11
- function ensureLogFile() {
12
- if (!logInitialized) {
13
- fs.writeFileSync(LOG_FILE, "");
14
- logInitialized = true;
15
- }
16
- }
17
- function appendLog(msg, force = false) {
18
- if (!debugEnabled && !force) return;
19
- ensureLogFile();
20
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
21
- fs.appendFileSync(LOG_FILE, `[${timestamp}] ${msg}
22
- `);
23
- }
24
- function initLog(debug) {
25
- debugEnabled = debug;
26
- if (debug) {
27
- ensureLogFile();
28
- }
29
- }
30
- function runCommand(cmd, cwd, onData, env) {
31
- appendLog(`$ ${cmd}${cwd ? ` (in ${cwd})` : ""}`);
32
- return new Promise((resolve, reject) => {
33
- const child = spawn(cmd, {
34
- cwd,
35
- stdio: ["ignore", "pipe", "pipe"],
36
- shell: true,
37
- env: env ? { ...process.env, ...env } : void 0
38
- });
39
- const stdout = [];
40
- const stderr = [];
41
- child.stdout.on("data", (data) => {
42
- const text = data.toString();
43
- stdout.push(text);
44
- if (onData) {
45
- for (const line of text.split("\n").filter(Boolean)) {
46
- onData(line.trim());
47
- }
48
- }
49
- });
50
- child.stderr.on("data", (data) => {
51
- const text = data.toString();
52
- stderr.push(text);
53
- if (onData) {
54
- for (const line of text.split("\n").filter(Boolean)) {
55
- onData(line.trim());
56
- }
57
- }
58
- });
59
- child.on("close", (code) => {
60
- const out = stdout.join("").trim();
61
- const errOut = stderr.join("").trim();
62
- if (out) appendLog(out);
63
- if (errOut) appendLog(`STDERR: ${errOut}`);
64
- if (code !== 0) {
65
- appendLog(`$ ${cmd}${cwd ? ` (in ${cwd})` : ""}`, true);
66
- appendLog(`EXIT CODE ${code}`, true);
67
- if (errOut) appendLog(`STDERR: ${errOut}`, true);
68
- const detail = errOut;
69
- const isUnixCacheError = detail.includes("EACCES") && detail.includes(".npm");
70
- const isWindowsCacheError = detail.includes("EPERM") && detail.toLowerCase().includes("npm-cache");
71
- if (isUnixCacheError || isWindowsCacheError) {
72
- const fix = process.platform === "win32" ? ` npm cache clean --force` : ` sudo chown -R $(id -u):$(id -g) ~/.npm`;
73
- reject(new Error(
74
- `npm cache has incorrect permissions.
75
-
76
- Fix it by running:
77
-
78
- ${fix}
79
-
80
- Then re-run the command.`
81
- ));
82
- return;
83
- }
84
- const msg = detail ? `Command failed: ${cmd}
85
- ${detail}` : `Command failed: ${cmd}`;
86
- reject(new Error(msg));
87
- } else {
88
- resolve(out);
89
- }
90
- });
91
- child.on("error", (err) => {
92
- appendLog(`$ ${cmd}${cwd ? ` (in ${cwd})` : ""}`, true);
93
- appendLog(`SPAWN ERROR: ${err.message}`, true);
94
- reject(
95
- new Error(`Command failed: ${cmd}
96
- ${err.message}`)
97
- );
98
- });
99
- });
100
- }
101
- var GIT_CLEAN_IGNORED = /* @__PURE__ */ new Set([
102
- ".agentlink-progress.json",
103
- "agentlink-debug.log"
104
- ]);
105
- async function assertGitClean(projectDir, allowDirty) {
106
- if (allowDirty) return;
107
- let status;
108
- try {
109
- status = await runCommand("git status --porcelain", projectDir);
110
- } catch {
111
- return;
112
- }
113
- const dirty = status.split("\n").filter((line) => {
114
- if (!line.trim()) return false;
115
- const filePath = line.slice(3).split(" -> ").pop()?.trim() ?? "";
116
- return !GIT_CLEAN_IGNORED.has(filePath);
117
- });
118
- if (dirty.length > 0) {
119
- throw new Error(
120
- "You have uncommitted changes. Commit or stash them first so the update\nis easy to review and rollback (git diff / git checkout .).\n git stash \u2014 stash changes temporarily\n git commit -am \u2026 \u2014 commit changes\n --allow-dirty \u2014 skip this check (rollback will be messy)"
121
- );
122
- }
123
- }
124
- async function listChangedFiles(projectDir) {
125
- let status;
126
- try {
127
- status = await runCommand("git status --porcelain", projectDir);
128
- } catch {
129
- return [];
130
- }
131
- return status.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => line.slice(3).split(" -> ").pop()?.trim() ?? "").filter((p) => p && !GIT_CLEAN_IGNORED.has(p));
132
- }
133
- function delay(ms) {
134
- return new Promise((resolve) => setTimeout(resolve, ms));
135
- }
136
- function checkCommand(cmd) {
137
- const locator = process.platform === "win32" ? "where" : "which";
138
- try {
139
- execSync(`${locator} ${cmd}`, { stdio: "ignore" });
140
- return true;
141
- } catch {
142
- return false;
143
- }
144
- }
145
- function skillDisplayName(skill) {
146
- if (skill.includes("@")) return skill.split("@").pop();
147
- const flag = skill.match(/--skill\s+(\S+)/);
148
- if (flag) return flag[1];
149
- return skill.split("/").pop();
150
- }
151
- function generateDbPassword(length = 32) {
152
- const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
153
- const bytes = crypto.randomBytes(length);
154
- return Array.from(bytes, (b) => chars[b % chars.length]).join("");
155
- }
156
- function slugifyProjectName(name) {
157
- return name.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9.-]/g, "").replace(/-+/g, "-").replace(/^-|-$/g, "");
158
- }
159
- function validateProjectName(name, mode = "new") {
160
- const slug = slugifyProjectName(name);
161
- if (!slug) return "Project name is required.";
162
- if (mode === "new" && fs.existsSync(slug))
163
- return `Directory "${slug}" already exists.`;
164
- return void 0;
165
- }
166
- function ensureGitignorePattern(cwd, pattern, comment = "Agent Link \u2014 database backups (may contain sensitive data)") {
167
- const gitignorePath = path.join(cwd, ".gitignore");
168
- let content = "";
169
- if (fs.existsSync(gitignorePath)) {
170
- content = fs.readFileSync(gitignorePath, "utf-8");
171
- const patternNoSlash = pattern.replace(/\/$/, "");
172
- const alreadyPresent = content.split("\n").map((l) => l.trim()).some((l) => l === pattern || l === patternNoSlash);
173
- if (alreadyPresent) return;
174
- }
175
- const needsLeadingNewline = content.length > 0 && !content.endsWith("\n");
176
- const block = (needsLeadingNewline ? "\n" : "") + (content.length > 0 ? "\n" : "") + `# ${comment}
177
- ${pattern}
178
- `;
179
- fs.writeFileSync(gitignorePath, content + block);
180
- }
181
-
182
- export {
183
- initLog,
184
- runCommand,
185
- assertGitClean,
186
- listChangedFiles,
187
- delay,
188
- checkCommand,
189
- skillDisplayName,
190
- generateDbPassword,
191
- slugifyProjectName,
192
- validateProjectName,
193
- ensureGitignorePattern
194
- };
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/theme.ts
4
- var rgb = (r, g, b) => (s) => `\x1B[38;2;${r};${g};${b}m${s}\x1B[0m`;
5
- var blue = rgb(92, 184, 228);
6
- var amber = rgb(232, 168, 56);
7
- var red = rgb(239, 68, 68);
8
- var dim = (s) => `\x1B[2m${s}\x1B[0m`;
9
- var bold = (s) => `\x1B[1m${s}\x1B[0m`;
10
- var link = (url, label) => `\x1B]8;;${url}\x07${label ?? url}\x1B]8;;\x07`;
11
- function deprecated(oldCmd, newCmd) {
12
- console.error(
13
- amber(
14
- `Warning: \`${oldCmd}\` is deprecated and will be removed in the next major version. Use \`${newCmd}\` instead.`
15
- )
16
- );
17
- }
18
-
19
- export {
20
- blue,
21
- amber,
22
- red,
23
- dim,
24
- bold,
25
- link,
26
- deprecated
27
- };
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- AUTH_CONFIG,
4
- AUTH_CONFIG_DEV_OVERRIDES,
5
- OAUTH_CLIENT_ID,
6
- OAUTH_CLIENT_SECRET,
7
- POSTGREST_CONFIG,
8
- RESEND_SMTP,
9
- SUPPORTED_PGDELTA,
10
- SUPPORTED_SUPABASE_CLI,
11
- pgd,
12
- pgdeltaBin,
13
- sb,
14
- supabaseBin
15
- } from "./chunk-ILLYV7U7.js";
16
- export {
17
- AUTH_CONFIG,
18
- AUTH_CONFIG_DEV_OVERRIDES,
19
- OAUTH_CLIENT_ID,
20
- OAUTH_CLIENT_SECRET,
21
- POSTGREST_CONFIG,
22
- RESEND_SMTP,
23
- SUPPORTED_PGDELTA,
24
- SUPPORTED_SUPABASE_CLI,
25
- pgd,
26
- pgdeltaBin,
27
- sb,
28
- supabaseBin
29
- };
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- dbApply,
4
- dbBackup,
5
- dbMigrate,
6
- dbPassword,
7
- dbRebuild,
8
- dbSql,
9
- dbTypes,
10
- dbUrlCheck,
11
- readEnvValue,
12
- resolveDbMode,
13
- resolveDbUrl
14
- } from "./chunk-DFDS5V5Z.js";
15
- import "./chunk-K5XVJEHP.js";
16
- import "./chunk-IV5ZSOKF.js";
17
- import "./chunk-MHI6VJ75.js";
18
- import "./chunk-ILLYV7U7.js";
19
- export {
20
- dbApply,
21
- dbBackup,
22
- dbMigrate,
23
- dbPassword,
24
- dbRebuild,
25
- dbSql,
26
- dbTypes,
27
- dbUrlCheck,
28
- readEnvValue,
29
- resolveDbMode,
30
- resolveDbUrl
31
- };
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- assertGitClean,
4
- checkCommand,
5
- delay,
6
- ensureGitignorePattern,
7
- generateDbPassword,
8
- initLog,
9
- listChangedFiles,
10
- runCommand,
11
- skillDisplayName,
12
- slugifyProjectName,
13
- validateProjectName
14
- } from "./chunk-IV5ZSOKF.js";
15
- export {
16
- assertGitClean,
17
- checkCommand,
18
- delay,
19
- ensureGitignorePattern,
20
- generateDbPassword,
21
- initLog,
22
- listChangedFiles,
23
- runCommand,
24
- skillDisplayName,
25
- slugifyProjectName,
26
- validateProjectName
27
- };