@solidactions/cli 3.15.0 → 3.17.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 +46 -7
- package/dist/command-manifest.json +400 -1
- package/dist/commands/ai-init.js +8 -0
- package/dist/commands/database-push.js +6 -0
- package/dist/commands/database.js +747 -12
- package/dist/commands/dev.js +127 -1
- package/dist/commands/env-pull.js +93 -0
- package/dist/index.js +80 -0
- package/dist/utils/agent-freshness.js +240 -0
- package/dist/utils/agent-update-worker.js +65 -0
- package/dist/utils/database-data-plane.js +13 -2
- package/dist/utils/database-ingest-digest.js +56 -0
- package/dist/utils/examples-ref.js +7 -5
- package/dist/utils/mutating-commands.js +16 -0
- package/dist/utils/skills.js +32 -5
- package/package.json +1 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UPDATE_CLAIM_SUFFIX = exports.UPDATE_CACHE_FILE = exports.UPDATE_CLAIM_TTL_MS = exports.UPDATE_CHECK_INTERVAL_MS = exports.NUDGE_SUPPRESSION_ENV = void 0;
|
|
7
|
+
exports.isNewerVersion = isNewerVersion;
|
|
8
|
+
exports.isCoworkSandbox = isCoworkSandbox;
|
|
9
|
+
exports.collectAgentFreshness = collectAgentFreshness;
|
|
10
|
+
exports.claimUpdateCheck = claimUpdateCheck;
|
|
11
|
+
exports.launchDetachedUpdateCheck = launchDetachedUpdateCheck;
|
|
12
|
+
exports.emitAgentFreshnessNudges = emitAgentFreshnessNudges;
|
|
13
|
+
const fs_1 = __importDefault(require("fs"));
|
|
14
|
+
const os_1 = __importDefault(require("os"));
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const child_process_1 = require("child_process");
|
|
17
|
+
const skills_1 = require("./skills");
|
|
18
|
+
// One switch suppresses the complete nudge system, including the background
|
|
19
|
+
// update refresh. This is intentionally broader than muting the four lines:
|
|
20
|
+
// automation that opts out should get neither output nor surprise egress.
|
|
21
|
+
exports.NUDGE_SUPPRESSION_ENV = 'SOLIDACTIONS_NO_AGENT_NUDGES';
|
|
22
|
+
exports.UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
23
|
+
exports.UPDATE_CLAIM_TTL_MS = 10 * 60 * 1000;
|
|
24
|
+
exports.UPDATE_CACHE_FILE = 'agent-update-check.json';
|
|
25
|
+
exports.UPDATE_CLAIM_SUFFIX = '.claim';
|
|
26
|
+
function safeOneLine(value) {
|
|
27
|
+
return value.replace(/[\u0000-\u001f\u007f]/g, '?');
|
|
28
|
+
}
|
|
29
|
+
function parseVersion(version) {
|
|
30
|
+
const identifier = '[0-9A-Za-z-]+';
|
|
31
|
+
const match = version.match(new RegExp(`^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)`
|
|
32
|
+
+ `(?:-(${identifier}(?:\\.${identifier})*))?`
|
|
33
|
+
+ `(?:\\+(${identifier}(?:\\.${identifier})*))?$`));
|
|
34
|
+
if (!match)
|
|
35
|
+
return null;
|
|
36
|
+
const prerelease = match[4]?.split('.') ?? [];
|
|
37
|
+
if (prerelease.some((part) => /^\d+$/.test(part) && part.length > 1 && part.startsWith('0'))) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
core: [BigInt(match[1]), BigInt(match[2]), BigInt(match[3])],
|
|
42
|
+
prerelease,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** True only when `candidate` is a valid semver newer than `current`. */
|
|
46
|
+
function isNewerVersion(candidate, current) {
|
|
47
|
+
const left = parseVersion(candidate);
|
|
48
|
+
const right = parseVersion(current);
|
|
49
|
+
if (!left || !right)
|
|
50
|
+
return false;
|
|
51
|
+
for (let i = 0; i < 3; i += 1) {
|
|
52
|
+
if (left.core[i] !== right.core[i])
|
|
53
|
+
return left.core[i] > right.core[i];
|
|
54
|
+
}
|
|
55
|
+
if (left.prerelease.length === 0 || right.prerelease.length === 0) {
|
|
56
|
+
return left.prerelease.length === 0 && right.prerelease.length > 0;
|
|
57
|
+
}
|
|
58
|
+
const length = Math.max(left.prerelease.length, right.prerelease.length);
|
|
59
|
+
for (let i = 0; i < length; i += 1) {
|
|
60
|
+
const a = left.prerelease[i];
|
|
61
|
+
const b = right.prerelease[i];
|
|
62
|
+
if (a === undefined || b === undefined)
|
|
63
|
+
return a !== undefined;
|
|
64
|
+
if (a === b)
|
|
65
|
+
continue;
|
|
66
|
+
const aNumeric = /^\d+$/.test(a);
|
|
67
|
+
const bNumeric = /^\d+$/.test(b);
|
|
68
|
+
if (aNumeric && bNumeric)
|
|
69
|
+
return BigInt(a) > BigInt(b);
|
|
70
|
+
if (aNumeric !== bNumeric)
|
|
71
|
+
return !aNumeric;
|
|
72
|
+
return a > b;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
function readUpdateCache(cacheFile) {
|
|
77
|
+
try {
|
|
78
|
+
const parsed = JSON.parse(fs_1.default.readFileSync(cacheFile, 'utf8'));
|
|
79
|
+
if (typeof parsed.checkedAt !== 'string')
|
|
80
|
+
return null;
|
|
81
|
+
if (parsed.latestVersion !== undefined && typeof parsed.latestVersion !== 'string')
|
|
82
|
+
return null;
|
|
83
|
+
return { checkedAt: parsed.checkedAt, latestVersion: parsed.latestVersion };
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function findProjectRoot(startDir) {
|
|
90
|
+
let dir = path_1.default.resolve(startDir);
|
|
91
|
+
while (true) {
|
|
92
|
+
if (fs_1.default.existsSync(path_1.default.join(dir, 'solidactions.yaml')))
|
|
93
|
+
return dir;
|
|
94
|
+
const parent = path_1.default.dirname(dir);
|
|
95
|
+
if (parent === dir)
|
|
96
|
+
return null;
|
|
97
|
+
dir = parent;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function isCoworkSandbox(env) {
|
|
101
|
+
// Best-effort heuristic: Cowork does not publish a stable detection
|
|
102
|
+
// contract. False positives can be suppressed with the one nudge opt-out.
|
|
103
|
+
if (env.CLAUDE_CODE_IS_COWORK === '1')
|
|
104
|
+
return true;
|
|
105
|
+
return env.CLAUDE_CODE_ENTRYPOINT === 'local-agent' && env.SANDBOX_RUNTIME === '1';
|
|
106
|
+
}
|
|
107
|
+
function collectAgentFreshness(options) {
|
|
108
|
+
const cwd = path_1.default.resolve(options.cwd ?? process.cwd());
|
|
109
|
+
const env = options.env ?? process.env;
|
|
110
|
+
const homeDir = options.homeDir ?? os_1.default.homedir();
|
|
111
|
+
const now = options.now ?? new Date();
|
|
112
|
+
const updateCacheFile = path_1.default.join(homeDir, '.solidactions', exports.UPDATE_CACHE_FILE);
|
|
113
|
+
const suppressed = env[exports.NUDGE_SUPPRESSION_ENV] === '1';
|
|
114
|
+
if (suppressed) {
|
|
115
|
+
return {
|
|
116
|
+
lines: [],
|
|
117
|
+
updateCacheFile,
|
|
118
|
+
updateCache: null,
|
|
119
|
+
shouldRefreshUpdateCache: false,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const lines = [];
|
|
123
|
+
const updateCache = readUpdateCache(updateCacheFile);
|
|
124
|
+
if (updateCache?.latestVersion && isNewerVersion(updateCache.latestVersion, options.currentVersion)) {
|
|
125
|
+
lines.push(`AGENT NOTE: CLI ${safeOneLine(options.currentVersion)} outdated (${safeOneLine(updateCache.latestVersion)} available); newer versions add verbs not visible in this --help. Run: npm i -g @solidactions/cli`);
|
|
126
|
+
}
|
|
127
|
+
const checkedAt = updateCache ? Date.parse(updateCache.checkedAt) : Number.NaN;
|
|
128
|
+
const shouldRefreshUpdateCache = !Number.isFinite(checkedAt)
|
|
129
|
+
|| now.getTime() - checkedAt >= exports.UPDATE_CHECK_INTERVAL_MS
|
|
130
|
+
|| checkedAt > now.getTime();
|
|
131
|
+
const projectRoot = findProjectRoot(cwd);
|
|
132
|
+
const installedDirs = projectRoot ? (0, skills_1.findInstalledSkillDirs)(projectRoot) : [];
|
|
133
|
+
if (projectRoot && installedDirs.length === 0) {
|
|
134
|
+
lines.push('AGENT NOTE: Install SolidActions skills for this project. Run: solidactions ai init');
|
|
135
|
+
}
|
|
136
|
+
else if (projectRoot) {
|
|
137
|
+
const staleDir = installedDirs.find((dir) => !(0, skills_1.isSkillDirCurrent)(dir));
|
|
138
|
+
if (staleDir) {
|
|
139
|
+
lines.push(`AGENT NOTE: Refresh stale SolidActions skills at ${safeOneLine(staleDir)}. Run: solidactions ai init --update`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (projectRoot && installedDirs.length > 0 && isCoworkSandbox(env)) {
|
|
143
|
+
const skillsDir = installedDirs[0];
|
|
144
|
+
const safePath = safeOneLine(skillsDir);
|
|
145
|
+
lines.push(`AGENT NOTE: skills at ${safePath} are not auto-loaded in this environment — read ${safePath}/solidactions-*.md (or ${safePath}/*/SKILL.md) before proceeding`);
|
|
146
|
+
}
|
|
147
|
+
return { lines, updateCacheFile, updateCache, shouldRefreshUpdateCache };
|
|
148
|
+
}
|
|
149
|
+
function writeUpdateCheckStarted(cacheFile, cache, now) {
|
|
150
|
+
const dir = path_1.default.dirname(cacheFile);
|
|
151
|
+
fs_1.default.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
152
|
+
const next = { checkedAt: now.toISOString() };
|
|
153
|
+
if (cache?.latestVersion)
|
|
154
|
+
next.latestVersion = cache.latestVersion;
|
|
155
|
+
const tempFile = `${cacheFile}.${process.pid}.tmp`;
|
|
156
|
+
fs_1.default.writeFileSync(tempFile, `${JSON.stringify(next)}\n`, { mode: 0o600 });
|
|
157
|
+
fs_1.default.renameSync(tempFile, cacheFile);
|
|
158
|
+
}
|
|
159
|
+
/** Atomically own a refresh, or retake a claim abandoned beyond its TTL. */
|
|
160
|
+
function claimUpdateCheck(claimFile, now) {
|
|
161
|
+
fs_1.default.mkdirSync(path_1.default.dirname(claimFile), { recursive: true, mode: 0o700 });
|
|
162
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
163
|
+
try {
|
|
164
|
+
// flag: wx maps to O_CREAT | O_EXCL: exactly one concurrent caller wins.
|
|
165
|
+
fs_1.default.writeFileSync(claimFile, `${now.toISOString()}\n`, { flag: 'wx', mode: 0o600 });
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
if (error?.code !== 'EEXIST')
|
|
170
|
+
throw error;
|
|
171
|
+
if (attempt > 0)
|
|
172
|
+
return false;
|
|
173
|
+
let stale = false;
|
|
174
|
+
try {
|
|
175
|
+
stale = now.getTime() - fs_1.default.statSync(claimFile).mtimeMs > exports.UPDATE_CLAIM_TTL_MS;
|
|
176
|
+
}
|
|
177
|
+
catch (statError) {
|
|
178
|
+
if (statError?.code === 'ENOENT')
|
|
179
|
+
continue;
|
|
180
|
+
throw statError;
|
|
181
|
+
}
|
|
182
|
+
if (!stale)
|
|
183
|
+
return false;
|
|
184
|
+
try {
|
|
185
|
+
fs_1.default.unlinkSync(claimFile);
|
|
186
|
+
}
|
|
187
|
+
catch (unlinkError) {
|
|
188
|
+
if (unlinkError?.code !== 'ENOENT')
|
|
189
|
+
throw unlinkError;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
function launchDetachedUpdateCheck(cacheFile, claimFile) {
|
|
196
|
+
const worker = path_1.default.join(__dirname, 'agent-update-worker.js');
|
|
197
|
+
const child = (0, child_process_1.spawn)(process.execPath, [worker, cacheFile, claimFile], {
|
|
198
|
+
detached: true,
|
|
199
|
+
stdio: 'ignore',
|
|
200
|
+
windowsHide: true,
|
|
201
|
+
});
|
|
202
|
+
child.on('error', () => {
|
|
203
|
+
try {
|
|
204
|
+
fs_1.default.unlinkSync(claimFile);
|
|
205
|
+
}
|
|
206
|
+
catch { /* best effort */ }
|
|
207
|
+
});
|
|
208
|
+
child.unref();
|
|
209
|
+
}
|
|
210
|
+
/** Emit all applicable lines to stderr. Every failure is deliberately ignored. */
|
|
211
|
+
function emitAgentFreshnessNudges(options) {
|
|
212
|
+
try {
|
|
213
|
+
const result = collectAgentFreshness(options);
|
|
214
|
+
for (const line of result.lines)
|
|
215
|
+
process.stderr.write(`${line}\n`);
|
|
216
|
+
if (result.shouldRefreshUpdateCache) {
|
|
217
|
+
const now = options.now ?? new Date();
|
|
218
|
+
const claimFile = `${result.updateCacheFile}${exports.UPDATE_CLAIM_SUFFIX}`;
|
|
219
|
+
// O_EXCL elects one owner. A live claim skips this invocation;
|
|
220
|
+
// an abandoned claim becomes eligible for takeover after its TTL.
|
|
221
|
+
if (claimUpdateCheck(claimFile, now)) {
|
|
222
|
+
try {
|
|
223
|
+
writeUpdateCheckStarted(result.updateCacheFile, result.updateCache, now);
|
|
224
|
+
(options.launchUpdateCheck ?? launchDetachedUpdateCheck)(result.updateCacheFile, claimFile);
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
try {
|
|
228
|
+
fs_1.default.unlinkSync(claimFile);
|
|
229
|
+
}
|
|
230
|
+
catch { /* best effort */ }
|
|
231
|
+
throw error;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// Nudges are advisory: read-only commands, JSON output, and scripts must
|
|
238
|
+
// continue even when HOME is unwritable or state is malformed.
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const https_1 = __importDefault(require("https"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const cacheFile = process.argv[2];
|
|
10
|
+
const claimFile = process.argv[3];
|
|
11
|
+
const registryUrl = 'https://registry.npmjs.org/@solidactions%2Fcli/latest';
|
|
12
|
+
let finished = false;
|
|
13
|
+
function finish() {
|
|
14
|
+
if (finished)
|
|
15
|
+
return;
|
|
16
|
+
finished = true;
|
|
17
|
+
if (claimFile) {
|
|
18
|
+
try {
|
|
19
|
+
fs_1.default.unlinkSync(claimFile);
|
|
20
|
+
}
|
|
21
|
+
catch { /* best effort */ }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function writeCache(latestVersion) {
|
|
25
|
+
const dir = path_1.default.dirname(cacheFile);
|
|
26
|
+
fs_1.default.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
27
|
+
const tempFile = `${cacheFile}.${process.pid}.tmp`;
|
|
28
|
+
fs_1.default.writeFileSync(tempFile, `${JSON.stringify({ checkedAt: new Date().toISOString(), latestVersion })}\n`, { mode: 0o600 });
|
|
29
|
+
fs_1.default.renameSync(tempFile, cacheFile);
|
|
30
|
+
}
|
|
31
|
+
if (cacheFile) {
|
|
32
|
+
const request = https_1.default.get(registryUrl, {
|
|
33
|
+
headers: { accept: 'application/json', 'user-agent': '@solidactions/cli update check' },
|
|
34
|
+
timeout: 5_000,
|
|
35
|
+
}, (response) => {
|
|
36
|
+
if (response.statusCode !== 200) {
|
|
37
|
+
response.resume();
|
|
38
|
+
response.on('end', finish);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let body = '';
|
|
42
|
+
response.setEncoding('utf8');
|
|
43
|
+
response.on('data', (chunk) => {
|
|
44
|
+
if (body.length <= 64 * 1024)
|
|
45
|
+
body += chunk;
|
|
46
|
+
});
|
|
47
|
+
response.on('end', () => {
|
|
48
|
+
try {
|
|
49
|
+
const version = JSON.parse(body)?.version;
|
|
50
|
+
if (typeof version === 'string' && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {
|
|
51
|
+
writeCache(version);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Offline, malformed, and unwritable-cache failures are silent.
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
finish();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
response.on('error', finish);
|
|
62
|
+
});
|
|
63
|
+
request.on('timeout', () => request.destroy());
|
|
64
|
+
request.on('error', finish);
|
|
65
|
+
}
|
|
@@ -59,12 +59,20 @@ exports.DEFAULT_DATABASE_DATA_PLANE_TIMEOUT_MS = 120_000;
|
|
|
59
59
|
class DatabaseOperationError extends Error {
|
|
60
60
|
code;
|
|
61
61
|
status;
|
|
62
|
-
|
|
62
|
+
// Populated only for `size_limit_exceeded` (the storage-cap refusal
|
|
63
|
+
// `ingest_prepare` and `create` can return) — the one error extra a
|
|
64
|
+
// caller currently needs beyond `code`/`message`/`status` to compose a
|
|
65
|
+
// useful message (spec/#1700 ingest: "surfaced with the limit").
|
|
66
|
+
sizeLimitBytes;
|
|
67
|
+
constructor(code, message, status, sizeLimitBytes) {
|
|
63
68
|
super(message);
|
|
64
69
|
this.code = code;
|
|
65
70
|
if (status !== undefined) {
|
|
66
71
|
this.status = status;
|
|
67
72
|
}
|
|
73
|
+
if (sizeLimitBytes !== undefined) {
|
|
74
|
+
this.sizeLimitBytes = sizeLimitBytes;
|
|
75
|
+
}
|
|
68
76
|
// A public command error is deliberately data-only. In particular, it
|
|
69
77
|
// must never retain an upstream stack, request, response, config, or
|
|
70
78
|
// cause that could contain either control- or data-plane credentials.
|
|
@@ -89,7 +97,10 @@ function safeDatabaseRequestError(error) {
|
|
|
89
97
|
const message = code === 'unauthenticated'
|
|
90
98
|
? `${appMessage} Run solidactions login to authenticate again.`
|
|
91
99
|
: appMessage;
|
|
92
|
-
|
|
100
|
+
const sizeLimitBytes = typeof response?.data?.size_limit_bytes === 'number'
|
|
101
|
+
? response.data.size_limit_bytes
|
|
102
|
+
: undefined;
|
|
103
|
+
return new DatabaseOperationError(code, message, status, sizeLimitBytes);
|
|
93
104
|
}
|
|
94
105
|
function positiveTimeout(value, fallback) {
|
|
95
106
|
return typeof value === 'number' && Number.isFinite(value) && value > 0
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/utils/database-ingest-digest.ts
|
|
3
|
+
//
|
|
4
|
+
// RFC 8785 (JCS) canonicalization, restricted to the fixed, flat ingest
|
|
5
|
+
// identity object spec §6.4 defines — every field is a string except the
|
|
6
|
+
// literal integer `v: 1`, so a full JCS number-formatting implementation
|
|
7
|
+
// is unnecessary; lexicographic key sorting plus JSON's own string
|
|
8
|
+
// escaping is JCS-compliant for this shape. Laravel
|
|
9
|
+
// (App\Domains\Databases\Analytical\Support\CanonicalBatchDigest) computes
|
|
10
|
+
// the identical digest over the identical object shape server-side; this
|
|
11
|
+
// file and its Laravel counterpart MUST stay byte-for-byte in sync — do
|
|
12
|
+
// not "improve" the canonicalization here without updating both sides.
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.canonicalIngestDigest = canonicalIngestDigest;
|
|
15
|
+
exports.defaultIngestBatchId = defaultIngestBatchId;
|
|
16
|
+
exports.ingestFormatFromExtension = ingestFormatFromExtension;
|
|
17
|
+
const crypto_1 = require("crypto");
|
|
18
|
+
function canonicalizeFlatObject(fields) {
|
|
19
|
+
const keys = Object.keys(fields).sort();
|
|
20
|
+
const parts = keys.map((key) => `${JSON.stringify(key)}:${JSON.stringify(fields[key])}`);
|
|
21
|
+
return `{${parts.join(',')}}`;
|
|
22
|
+
}
|
|
23
|
+
/** The §6.4 canonical digest: lower-case hex sha256 of the JCS body. */
|
|
24
|
+
function canonicalIngestDigest(identity) {
|
|
25
|
+
const canonical = canonicalizeFlatObject({
|
|
26
|
+
v: 1,
|
|
27
|
+
database_id: identity.databaseId,
|
|
28
|
+
// NOTE: JS `.trim()` strips a wider whitespace set than PHP `trim()`
|
|
29
|
+
// (e.g. NBSP/BOM/OGHAM SPACE MARK/U+3000) — inert here, since the
|
|
30
|
+
// server PHP-trims the same table name before this digest is ever
|
|
31
|
+
// computed server-side, so a character JS strips but PHP doesn't
|
|
32
|
+
// fails the `^[a-z][a-z0-9_]{0,62}$` gate with a 422 first. Do not
|
|
33
|
+
// "fix" this asymmetry without re-verifying byte-for-byte parity
|
|
34
|
+
// with the PHP canonical digest (`CanonicalBatchDigest`).
|
|
35
|
+
table: identity.table.trim().toLowerCase(),
|
|
36
|
+
mode: identity.mode,
|
|
37
|
+
ack: 'durable',
|
|
38
|
+
format: identity.format,
|
|
39
|
+
content_sha256: identity.contentSha256.toLowerCase(),
|
|
40
|
+
});
|
|
41
|
+
return (0, crypto_1.createHash)('sha256').update(canonical, 'utf8').digest('hex');
|
|
42
|
+
}
|
|
43
|
+
/** The CLI's default batch id: the first 32 hex chars of the canonical digest. */
|
|
44
|
+
function defaultIngestBatchId(identity) {
|
|
45
|
+
return canonicalIngestDigest(identity).slice(0, 32);
|
|
46
|
+
}
|
|
47
|
+
function ingestFormatFromExtension(filePath) {
|
|
48
|
+
const ext = filePath.toLowerCase().split('.').pop();
|
|
49
|
+
if (ext === 'parquet')
|
|
50
|
+
return 'parquet';
|
|
51
|
+
if (ext === 'csv')
|
|
52
|
+
return 'csv';
|
|
53
|
+
if (ext === 'jsonl')
|
|
54
|
+
return 'jsonl';
|
|
55
|
+
throw new Error(`Unsupported ingest file extension ".${ext}" — use .parquet, .csv, or .jsonl.`);
|
|
56
|
+
}
|
|
@@ -29,9 +29,11 @@ exports.EXAMPLES_REF = void 0;
|
|
|
29
29
|
* SDK, replace this with a derivation the way sdk-version.ts does.
|
|
30
30
|
*
|
|
31
31
|
* Currently: the merged solidactions-examples mainline as of CLI v3.8.0
|
|
32
|
-
* (includes ex#
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* release
|
|
32
|
+
* (includes ex#34 "workspace-database + Drizzle example", which is what makes
|
|
33
|
+
* `ai examples` able to install workspace-database-drizzle — the runnable
|
|
34
|
+
* connect + drizzle-kit-migration example #140 exists to point people at).
|
|
35
|
+
* Repinned at release per the standing #1146 contract: on every CLI release,
|
|
36
|
+
* repin EXAMPLES_REF to the examples repo's merged mainline SHA and verify the
|
|
37
|
+
* exact ref during the release ritual.
|
|
36
38
|
*/
|
|
37
|
-
exports.EXAMPLES_REF = '
|
|
39
|
+
exports.EXAMPLES_REF = '47e887d348b45ab948c904a29c1354cbbc23cdab';
|
|
@@ -49,6 +49,13 @@ exports.MUTATING_COMMANDS = new Set([
|
|
|
49
49
|
'database exec',
|
|
50
50
|
'database import',
|
|
51
51
|
'database push',
|
|
52
|
+
'database ingest',
|
|
53
|
+
'database drop-table',
|
|
54
|
+
// `optimize` dispatches a real server-side operation that rewrites the
|
|
55
|
+
// database's stored files (`StartOptimizeOperation` — a job, not just a
|
|
56
|
+
// read of existing state), the same class of deliberate write action as
|
|
57
|
+
// `run start`/`skill exec`.
|
|
58
|
+
'database optimize',
|
|
52
59
|
// Plain `database pull` is read-only (GET, writes a local file only —
|
|
53
60
|
// same family as project/env/doc/skill pull). But `--writable`
|
|
54
61
|
// (databaseWritablePullWithConfig, src/commands/database.ts:1320) mints
|
|
@@ -100,8 +107,17 @@ exports.READONLY_COMMANDS = new Set([
|
|
|
100
107
|
// Runs locally; does not touch server state for any workspace.
|
|
101
108
|
'dev',
|
|
102
109
|
'database list',
|
|
110
|
+
'database show',
|
|
103
111
|
'database schema',
|
|
104
112
|
'database query',
|
|
113
|
+
// `connect` never calls the server's admission gate — it is a pure,
|
|
114
|
+
// synchronous read of the database row (no side effects at all).
|
|
115
|
+
'database connect',
|
|
116
|
+
// `wake` is the same admission-only call `query` already makes
|
|
117
|
+
// incidentally (both can dispatch the async wake job, never touching
|
|
118
|
+
// application data) — its whole purpose is that read-intent pre-warm,
|
|
119
|
+
// spec §4.2.
|
|
120
|
+
'database wake',
|
|
105
121
|
// Downloads a dump and writes it to a local file only, like the `pull`
|
|
106
122
|
// family below — the data-plane request happens to be a POST, but no
|
|
107
123
|
// server state changes.
|
package/dist/utils/skills.js
CHANGED
|
@@ -3,16 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SOLIDACTIONS_SKILL_NAMES = void 0;
|
|
6
|
+
exports.SOLIDACTIONS_SKILL_NAMES = exports.SKILLS_VERSION_FILE = exports.BUNDLED_SKILLS_VERSION = void 0;
|
|
7
7
|
exports.skillTargetDir = skillTargetDir;
|
|
8
8
|
exports.installSkills = installSkills;
|
|
9
9
|
exports.fetchAiHelperContent = fetchAiHelperContent;
|
|
10
10
|
exports.hasSolidActionsSkills = hasSolidActionsSkills;
|
|
11
|
+
exports.findInstalledSkillDirs = findInstalledSkillDirs;
|
|
12
|
+
exports.isSkillDirCurrent = isSkillDirCurrent;
|
|
11
13
|
const fs_1 = __importDefault(require("fs"));
|
|
12
14
|
const path_1 = __importDefault(require("path"));
|
|
13
15
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
14
16
|
const github_1 = require("./github");
|
|
15
17
|
const examples_ref_1 = require("./examples-ref");
|
|
18
|
+
exports.BUNDLED_SKILLS_VERSION = examples_ref_1.EXAMPLES_REF;
|
|
19
|
+
exports.SKILLS_VERSION_FILE = '.solidactions-version';
|
|
16
20
|
exports.SOLIDACTIONS_SKILL_NAMES = [
|
|
17
21
|
'solidactions-getting-started',
|
|
18
22
|
'solidactions-workflow-coding',
|
|
@@ -53,6 +57,11 @@ async function installSkills(targetDir) {
|
|
|
53
57
|
fs_1.default.writeFileSync(filePath, content, 'utf8');
|
|
54
58
|
written.push(filePath);
|
|
55
59
|
}
|
|
60
|
+
// Stamp only after every fetch/write succeeds. A partial/offline install
|
|
61
|
+
// must remain visibly stale so the next run can tell the agent to repair it.
|
|
62
|
+
const versionFile = path_1.default.join(targetDir, exports.SKILLS_VERSION_FILE);
|
|
63
|
+
fs_1.default.writeFileSync(versionFile, `${exports.BUNDLED_SKILLS_VERSION}\n`, 'utf8');
|
|
64
|
+
written.push(versionFile);
|
|
56
65
|
return { written };
|
|
57
66
|
}
|
|
58
67
|
/**
|
|
@@ -68,15 +77,33 @@ async function fetchAiHelperContent(targetFile) {
|
|
|
68
77
|
* these files are how AI assistants self-rescue on env-scope/deploy traps.
|
|
69
78
|
*/
|
|
70
79
|
function hasSolidActionsSkills(projectDir) {
|
|
80
|
+
return findInstalledSkillDirs(projectDir).length > 0;
|
|
81
|
+
}
|
|
82
|
+
/** Return every helper-specific directory containing SolidActions skills. */
|
|
83
|
+
function findInstalledSkillDirs(projectDir) {
|
|
84
|
+
const installed = [];
|
|
71
85
|
for (const target of ['CLAUDE.md', 'AGENTS.md']) {
|
|
72
86
|
const dir = skillTargetDir(target, projectDir);
|
|
73
87
|
if (!fs_1.default.existsSync(dir)) {
|
|
74
88
|
continue;
|
|
75
89
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
try {
|
|
91
|
+
const entries = fs_1.default.readdirSync(dir);
|
|
92
|
+
if (entries.some((f) => f.startsWith('solidactions-') && f.endsWith('.md'))) {
|
|
93
|
+
installed.push(dir);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// Advisory discovery must not make an otherwise valid CLI command fail.
|
|
79
98
|
}
|
|
80
99
|
}
|
|
81
|
-
return
|
|
100
|
+
return installed;
|
|
101
|
+
}
|
|
102
|
+
function isSkillDirCurrent(skillDir) {
|
|
103
|
+
try {
|
|
104
|
+
return fs_1.default.readFileSync(path_1.default.join(skillDir, exports.SKILLS_VERSION_FILE), 'utf8').trim() === exports.BUNDLED_SKILLS_VERSION;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
82
109
|
}
|