@hasna/instructions 0.7.0 → 0.7.2
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 +52 -11
- package/dist/chunks/{apply-7svah2qm.js → apply-ps6jjt6k.js} +3 -3
- package/dist/chunks/{apply-jp13sa1e.js → apply-wj7wh5km.js} +3 -3
- package/dist/chunks/{index-1cnyjnd7.js → index-18j7x3xw.js} +2 -2
- package/dist/chunks/{index-3djthcm6.js → index-27az1qb1.js} +28 -1
- package/dist/chunks/{index-fwbs6tma.js → index-ape24zc0.js} +2 -2
- package/dist/chunks/{index-bzyxvwcd.js → index-ek15201v.js} +2 -2
- package/dist/chunks/{index-arrrx0ed.js → index-mvckkf15.js} +39 -20
- package/dist/chunks/{index-7m4j8a33.js → index-n6nh6f5r.js} +235 -20
- package/dist/chunks/{index-4pfq42t5.js → index-pq18fdbj.js} +146 -32
- package/dist/chunks/{index-n3fjspr0.js → index-preyvj8n.js} +28 -1
- package/dist/chunks/{index-z3ma4aqk.js → index-y8410ve0.js} +3 -3
- package/dist/chunks/{local-5wvv5xv3.js → local-1c1qxzvx.js} +155 -4
- package/dist/chunks/{local-zxa5dpf4.js → local-hc67bynj.js} +155 -4
- package/dist/chunks/{s3-backup-n2z4fwyh.js → s3-backup-hxe3zpfz.js} +1 -1
- package/dist/chunks/{s3-object-store-90tgbh6k.js → s3-object-store-n0s82swt.js} +1 -1
- package/dist/chunks/{sync-r8t7zsp3.js → sync-12m3vs6g.js} +4 -4
- package/dist/chunks/{sync-2075deve.js → sync-azd9t4p8.js} +4 -4
- package/dist/chunks/{template-wgnzdn7h.js → template-e4qrxs8p.js} +1 -1
- package/dist/chunks/{template-fsfxpe4p.js → template-nhn124zd.js} +1 -1
- package/dist/cli/index.js +860 -181
- package/dist/data/config-store.d.ts +22 -6
- package/dist/data/config-store.d.ts.map +1 -1
- package/dist/db/configs.d.ts +4 -1
- package/dist/db/configs.d.ts.map +1 -1
- package/dist/db/local.d.ts +1 -1
- package/dist/db/local.d.ts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +940 -134
- package/dist/lib/asset-plan.d.ts.map +1 -1
- package/dist/lib/codewith-shared-todos-storage-standard.d.ts.map +1 -1
- package/dist/lib/compact-output.d.ts +2 -18
- package/dist/lib/compact-output.d.ts.map +1 -1
- package/dist/lib/dangerous-operation-guard-standard.d.ts.map +1 -1
- package/dist/lib/export.d.ts.map +1 -1
- package/dist/lib/global-agent-rules-standard.d.ts.map +1 -1
- package/dist/lib/global-source-coverage.d.ts +12 -7
- package/dist/lib/global-source-coverage.d.ts.map +1 -1
- package/dist/lib/import.d.ts.map +1 -1
- package/dist/lib/instruction-graph.d.ts +1 -1
- package/dist/lib/instruction-graph.d.ts.map +1 -1
- package/dist/lib/instruction-source-policy.d.ts +6 -0
- package/dist/lib/instruction-source-policy.d.ts.map +1 -0
- package/dist/lib/platform-profiles.d.ts.map +1 -1
- package/dist/lib/project-dashboard-standard.d.ts.map +1 -1
- package/dist/lib/session-apply.d.ts +24 -0
- package/dist/lib/session-apply.d.ts.map +1 -1
- package/dist/lib/session-refresh.d.ts +30 -0
- package/dist/lib/session-refresh.d.ts.map +1 -0
- package/dist/lib/session-render.d.ts +34 -1
- package/dist/lib/session-render.d.ts.map +1 -1
- package/dist/lib/transforms.d.ts +1 -0
- package/dist/lib/transforms.d.ts.map +1 -1
- package/dist/mcp/index.js +23 -22
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/sdk/index.js +46 -3
- package/dist/sdk/v1-client.d.ts +10 -3
- package/dist/sdk/v1-client.d.ts.map +1 -1
- package/dist/sdk/v1.generated.d.ts +52 -2
- package/dist/sdk/v1.generated.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +215 -15
- package/dist/server/openapi.d.ts +240 -3
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/server/v1.d.ts.map +1 -1
- package/dist/storage/cloud-store.d.ts +2 -15
- package/dist/storage/cloud-store.d.ts.map +1 -1
- package/dist/storage/index.js +39 -20
- package/dist/storage/s3-object-store.d.ts.map +1 -1
- package/dist/types/index.d.ts +49 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -7,11 +7,13 @@ import {
|
|
|
7
7
|
normalizeOsFamily,
|
|
8
8
|
normalizeProfileAssetBinding,
|
|
9
9
|
normalizeProfileConfigBinding
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-n6nh6f5r.js";
|
|
11
11
|
import {
|
|
12
12
|
ConfigNotFoundError,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
ConfigVersionConflictError,
|
|
14
|
+
ProfileNotFoundError,
|
|
15
|
+
validateExpectedConfigVersion
|
|
16
|
+
} from "./index-preyvj8n.js";
|
|
15
17
|
import {
|
|
16
18
|
getDatabase,
|
|
17
19
|
insertFeedback,
|
|
@@ -163,7 +165,145 @@ function listConfigs(filter, db) {
|
|
|
163
165
|
const rows = d.query(`SELECT * FROM configs ${where} ORDER BY category, name`).all(...params);
|
|
164
166
|
return rows.map(rowToConfig);
|
|
165
167
|
}
|
|
168
|
+
function listConfigsPage(filter = {}, options = {}, db) {
|
|
169
|
+
const d = db || getDatabase();
|
|
170
|
+
const conditions = [];
|
|
171
|
+
const params = [];
|
|
172
|
+
if (filter.category) {
|
|
173
|
+
conditions.push("category = ?");
|
|
174
|
+
params.push(filter.category);
|
|
175
|
+
}
|
|
176
|
+
if (filter.agent) {
|
|
177
|
+
conditions.push("agent = ?");
|
|
178
|
+
params.push(filter.agent);
|
|
179
|
+
}
|
|
180
|
+
if (filter.kind) {
|
|
181
|
+
conditions.push("kind = ?");
|
|
182
|
+
params.push(filter.kind);
|
|
183
|
+
}
|
|
184
|
+
if (filter.is_template !== undefined) {
|
|
185
|
+
conditions.push("is_template = ?");
|
|
186
|
+
params.push(filter.is_template ? 1 : 0);
|
|
187
|
+
}
|
|
188
|
+
if (filter.search) {
|
|
189
|
+
conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
|
|
190
|
+
const q = `%${filter.search}%`;
|
|
191
|
+
params.push(q, q, q);
|
|
192
|
+
}
|
|
193
|
+
if (filter.tags?.length) {
|
|
194
|
+
conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
|
|
195
|
+
for (const tag of filter.tags)
|
|
196
|
+
params.push(`%"${tag}"%`);
|
|
197
|
+
}
|
|
198
|
+
const where = conditions.length ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
199
|
+
const normalized = normalizeBoundedReadOptions(options);
|
|
200
|
+
const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
|
|
201
|
+
const pageParams = [...params, normalized.limit, normalized.cursor];
|
|
202
|
+
const rows = d.query(`SELECT * FROM configs ${where} ORDER BY id LIMIT ? OFFSET ?`).all(...pageParams);
|
|
203
|
+
return boundedReadPage(rows.map(rowToConfig), total, normalized);
|
|
204
|
+
}
|
|
205
|
+
function listConfigIdentitiesPage(filter = {}, options = {}, db) {
|
|
206
|
+
const d = db || getDatabase();
|
|
207
|
+
const conditions = [];
|
|
208
|
+
const params = [];
|
|
209
|
+
if (filter.category) {
|
|
210
|
+
conditions.push("category = ?");
|
|
211
|
+
params.push(filter.category);
|
|
212
|
+
}
|
|
213
|
+
if (filter.agent) {
|
|
214
|
+
conditions.push("agent = ?");
|
|
215
|
+
params.push(filter.agent);
|
|
216
|
+
}
|
|
217
|
+
if (filter.kind) {
|
|
218
|
+
conditions.push("kind = ?");
|
|
219
|
+
params.push(filter.kind);
|
|
220
|
+
}
|
|
221
|
+
if (filter.is_template !== undefined) {
|
|
222
|
+
conditions.push("is_template = ?");
|
|
223
|
+
params.push(filter.is_template ? 1 : 0);
|
|
224
|
+
}
|
|
225
|
+
if (filter.search) {
|
|
226
|
+
conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
|
|
227
|
+
const q = `%${filter.search}%`;
|
|
228
|
+
params.push(q, q, q);
|
|
229
|
+
}
|
|
230
|
+
if (filter.tags?.length) {
|
|
231
|
+
conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
|
|
232
|
+
for (const tag of filter.tags)
|
|
233
|
+
params.push(`%"${tag}"%`);
|
|
234
|
+
}
|
|
235
|
+
const where = conditions.length ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
236
|
+
const normalized = normalizeBoundedReadOptions(options);
|
|
237
|
+
const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
|
|
238
|
+
const pageParams = [...params, normalized.limit, normalized.cursor];
|
|
239
|
+
const rows = d.query(`SELECT id, name, slug, kind, category, agent, format, is_template, version, created_at, updated_at, synced_at
|
|
240
|
+
FROM configs ${where} ORDER BY id LIMIT ? OFFSET ?`).all(...pageParams);
|
|
241
|
+
return boundedReadPage(rows.map((row) => ({
|
|
242
|
+
...row,
|
|
243
|
+
kind: row.kind,
|
|
244
|
+
category: row.category,
|
|
245
|
+
agent: row.agent,
|
|
246
|
+
format: row.format,
|
|
247
|
+
is_template: Boolean(row.is_template)
|
|
248
|
+
})), total, normalized);
|
|
249
|
+
}
|
|
250
|
+
function listConfigSummariesPage(filter = {}, options = {}, db) {
|
|
251
|
+
const d = db || getDatabase();
|
|
252
|
+
const conditions = [];
|
|
253
|
+
const params = [];
|
|
254
|
+
if (filter.category) {
|
|
255
|
+
conditions.push("category = ?");
|
|
256
|
+
params.push(filter.category);
|
|
257
|
+
}
|
|
258
|
+
if (filter.agent) {
|
|
259
|
+
conditions.push("agent = ?");
|
|
260
|
+
params.push(filter.agent);
|
|
261
|
+
}
|
|
262
|
+
if (filter.kind) {
|
|
263
|
+
conditions.push("kind = ?");
|
|
264
|
+
params.push(filter.kind);
|
|
265
|
+
}
|
|
266
|
+
if (filter.is_template !== undefined) {
|
|
267
|
+
conditions.push("is_template = ?");
|
|
268
|
+
params.push(filter.is_template ? 1 : 0);
|
|
269
|
+
}
|
|
270
|
+
if (filter.search) {
|
|
271
|
+
conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
|
|
272
|
+
const q = `%${filter.search}%`;
|
|
273
|
+
params.push(q, q, q);
|
|
274
|
+
}
|
|
275
|
+
if (filter.tags && filter.tags.length > 0) {
|
|
276
|
+
conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
|
|
277
|
+
for (const tag of filter.tags)
|
|
278
|
+
params.push(`%"${tag}"%`);
|
|
279
|
+
}
|
|
280
|
+
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
281
|
+
const normalized = normalizeBoundedReadOptions(options);
|
|
282
|
+
const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
|
|
283
|
+
const pageParams = [...params, normalized.limit, normalized.cursor];
|
|
284
|
+
const rows = d.query(`SELECT id, name, slug, kind, category, agent, target_path, format,
|
|
285
|
+
CASE WHEN json_valid(outputs) AND json_type(outputs) = 'array' THEN json_array_length(outputs) ELSE 0 END AS output_count, description, tags,
|
|
286
|
+
is_template, version, updated_at
|
|
287
|
+
FROM configs ${where} ORDER BY category, name, id LIMIT ? OFFSET ?`).all(...pageParams);
|
|
288
|
+
return boundedReadPage(rows.map((row) => ({
|
|
289
|
+
id: row.id,
|
|
290
|
+
slug: row.slug,
|
|
291
|
+
name: row.name,
|
|
292
|
+
category: row.category,
|
|
293
|
+
agent: row.agent,
|
|
294
|
+
kind: row.kind,
|
|
295
|
+
format: row.format,
|
|
296
|
+
target_path: row.target_path,
|
|
297
|
+
output_count: Number(row.output_count ?? 0),
|
|
298
|
+
version: row.version,
|
|
299
|
+
is_template: Boolean(row.is_template),
|
|
300
|
+
updated_at: row.updated_at,
|
|
301
|
+
description: row.description,
|
|
302
|
+
tags: JSON.parse(row.tags || "[]")
|
|
303
|
+
})), total, normalized);
|
|
304
|
+
}
|
|
166
305
|
function updateConfig(idOrSlug, input, db) {
|
|
306
|
+
validateExpectedConfigVersion(input.expected_version);
|
|
167
307
|
const d = db || getDatabase();
|
|
168
308
|
const existing = getConfig(idOrSlug, d);
|
|
169
309
|
const ts = now();
|
|
@@ -219,7 +359,15 @@ function updateConfig(idOrSlug, input, db) {
|
|
|
219
359
|
}
|
|
220
360
|
return d.transaction(() => {
|
|
221
361
|
params.push(existing.id);
|
|
222
|
-
|
|
362
|
+
const condition = input.expected_version === undefined ? "" : " AND version = ?";
|
|
363
|
+
if (input.expected_version !== undefined)
|
|
364
|
+
params.push(input.expected_version);
|
|
365
|
+
const result = d.run(`UPDATE configs SET ${updates.join(", ")} WHERE id = ?${condition}`, params);
|
|
366
|
+
if (result.changes !== 1) {
|
|
367
|
+
if (input.expected_version !== undefined)
|
|
368
|
+
throw new ConfigVersionConflictError(existing.id, input.expected_version);
|
|
369
|
+
throw new ConfigNotFoundError(existing.id);
|
|
370
|
+
}
|
|
223
371
|
const updated = getConfigById(existing.id, d);
|
|
224
372
|
createSnapshot(updated.id, updated.content, updated.version, d);
|
|
225
373
|
return updated;
|
|
@@ -497,7 +645,10 @@ export {
|
|
|
497
645
|
listSnapshots,
|
|
498
646
|
listProfilesPage,
|
|
499
647
|
listMachines,
|
|
648
|
+
listConfigsPage,
|
|
500
649
|
listConfigs,
|
|
650
|
+
listConfigSummariesPage,
|
|
651
|
+
listConfigIdentitiesPage,
|
|
501
652
|
insertFeedback,
|
|
502
653
|
getSnapshotByVersion,
|
|
503
654
|
getSnapshot,
|
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
syncProject,
|
|
13
13
|
syncToDir,
|
|
14
14
|
syncToDisk
|
|
15
|
-
} from "./index-
|
|
16
|
-
import"./index-
|
|
17
|
-
import"./index-
|
|
15
|
+
} from "./index-ek15201v.js";
|
|
16
|
+
import"./index-ape24zc0.js";
|
|
17
|
+
import"./index-pq18fdbj.js";
|
|
18
18
|
import"./index-35z65jsa.js";
|
|
19
|
-
import"./index-
|
|
19
|
+
import"./index-27az1qb1.js";
|
|
20
20
|
import"./index-nnwp92tk.js";
|
|
21
21
|
export {
|
|
22
22
|
syncToDisk,
|
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
syncProject,
|
|
13
13
|
syncToDir,
|
|
14
14
|
syncToDisk
|
|
15
|
-
} from "./index-
|
|
16
|
-
import"./index-
|
|
17
|
-
import"./index-
|
|
18
|
-
import"./index-
|
|
15
|
+
} from "./index-18j7x3xw.js";
|
|
16
|
+
import"./index-y8410ve0.js";
|
|
17
|
+
import"./index-n6nh6f5r.js";
|
|
18
|
+
import"./index-preyvj8n.js";
|
|
19
19
|
import"./index-fpeyzn3n.js";
|
|
20
20
|
import"./index-bsan4c16.js";
|
|
21
21
|
export {
|