@hasna/instructions 0.7.0 → 0.7.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.
Files changed (48) hide show
  1. package/README.md +18 -4
  2. package/dist/chunks/{apply-7svah2qm.js → apply-c3sd4agz.js} +2 -2
  3. package/dist/chunks/{apply-jp13sa1e.js → apply-pnn7a3y7.js} +2 -2
  4. package/dist/chunks/{index-7m4j8a33.js → index-6jncnnw7.js} +117 -4
  5. package/dist/chunks/{index-4pfq42t5.js → index-aj66f6xr.js} +118 -27
  6. package/dist/chunks/{index-bzyxvwcd.js → index-jg8ptcwh.js} +2 -2
  7. package/dist/chunks/{index-arrrx0ed.js → index-mvckkf15.js} +39 -20
  8. package/dist/chunks/{index-1cnyjnd7.js → index-pdpg8a44.js} +2 -2
  9. package/dist/chunks/{index-z3ma4aqk.js → index-r7nfef2g.js} +1 -1
  10. package/dist/chunks/{index-fwbs6tma.js → index-ypcef3a2.js} +1 -1
  11. package/dist/chunks/{local-5wvv5xv3.js → local-0a9gja58.js} +141 -1
  12. package/dist/chunks/{local-zxa5dpf4.js → local-969ye538.js} +141 -1
  13. package/dist/chunks/{s3-backup-n2z4fwyh.js → s3-backup-hxe3zpfz.js} +1 -1
  14. package/dist/chunks/{s3-object-store-90tgbh6k.js → s3-object-store-n0s82swt.js} +1 -1
  15. package/dist/chunks/{sync-r8t7zsp3.js → sync-q5hvwq6e.js} +3 -3
  16. package/dist/chunks/{sync-2075deve.js → sync-xtkbm5br.js} +3 -3
  17. package/dist/cli/index.js +269 -53
  18. package/dist/data/config-store.d.ts +10 -2
  19. package/dist/data/config-store.d.ts.map +1 -1
  20. package/dist/db/configs.d.ts +4 -1
  21. package/dist/db/configs.d.ts.map +1 -1
  22. package/dist/db/local.d.ts +1 -1
  23. package/dist/db/local.d.ts.map +1 -1
  24. package/dist/index.js +282 -36
  25. package/dist/lib/compact-output.d.ts +2 -18
  26. package/dist/lib/compact-output.d.ts.map +1 -1
  27. package/dist/lib/export.d.ts.map +1 -1
  28. package/dist/lib/import.d.ts.map +1 -1
  29. package/dist/mcp/index.js +17 -17
  30. package/dist/mcp/server.d.ts.map +1 -1
  31. package/dist/sdk/index.js +27 -3
  32. package/dist/sdk/v1-client.d.ts +4 -3
  33. package/dist/sdk/v1-client.d.ts.map +1 -1
  34. package/dist/sdk/v1.generated.d.ts +32 -2
  35. package/dist/sdk/v1.generated.d.ts.map +1 -1
  36. package/dist/server/index.d.ts +1 -1
  37. package/dist/server/index.d.ts.map +1 -1
  38. package/dist/server/index.js +93 -7
  39. package/dist/server/openapi.d.ts +117 -3
  40. package/dist/server/openapi.d.ts.map +1 -1
  41. package/dist/server/v1.d.ts.map +1 -1
  42. package/dist/storage/cloud-store.d.ts +2 -15
  43. package/dist/storage/cloud-store.d.ts.map +1 -1
  44. package/dist/storage/index.js +39 -20
  45. package/dist/storage/s3-object-store.d.ts.map +1 -1
  46. package/dist/types/index.d.ts +33 -0
  47. package/dist/types/index.d.ts.map +1 -1
  48. package/package.json +3 -3
@@ -14,7 +14,7 @@ import {
14
14
  normalizeOsFamily,
15
15
  normalizeProfileAssetBinding,
16
16
  normalizeProfileConfigBinding
17
- } from "./index-4pfq42t5.js";
17
+ } from "./index-aj66f6xr.js";
18
18
  import"./index-35z65jsa.js";
19
19
  import {
20
20
  ConfigNotFoundError,
@@ -339,6 +339,143 @@ function listConfigs(filter, db) {
339
339
  const rows = d.query(`SELECT * FROM configs ${where} ORDER BY category, name`).all(...params);
340
340
  return rows.map(rowToConfig);
341
341
  }
342
+ function listConfigsPage(filter = {}, options = {}, db) {
343
+ const d = db || getDatabase();
344
+ const conditions = [];
345
+ const params = [];
346
+ if (filter.category) {
347
+ conditions.push("category = ?");
348
+ params.push(filter.category);
349
+ }
350
+ if (filter.agent) {
351
+ conditions.push("agent = ?");
352
+ params.push(filter.agent);
353
+ }
354
+ if (filter.kind) {
355
+ conditions.push("kind = ?");
356
+ params.push(filter.kind);
357
+ }
358
+ if (filter.is_template !== undefined) {
359
+ conditions.push("is_template = ?");
360
+ params.push(filter.is_template ? 1 : 0);
361
+ }
362
+ if (filter.search) {
363
+ conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
364
+ const q = `%${filter.search}%`;
365
+ params.push(q, q, q);
366
+ }
367
+ if (filter.tags?.length) {
368
+ conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
369
+ for (const tag of filter.tags)
370
+ params.push(`%"${tag}"%`);
371
+ }
372
+ const where = conditions.length ? `WHERE ${conditions.join(" AND ")}` : "";
373
+ const normalized = normalizeBoundedReadOptions(options);
374
+ const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
375
+ const pageParams = [...params, normalized.limit, normalized.cursor];
376
+ const rows = d.query(`SELECT * FROM configs ${where} ORDER BY id LIMIT ? OFFSET ?`).all(...pageParams);
377
+ return boundedReadPage(rows.map(rowToConfig), total, normalized);
378
+ }
379
+ function listConfigIdentitiesPage(filter = {}, options = {}, db) {
380
+ const d = db || getDatabase();
381
+ const conditions = [];
382
+ const params = [];
383
+ if (filter.category) {
384
+ conditions.push("category = ?");
385
+ params.push(filter.category);
386
+ }
387
+ if (filter.agent) {
388
+ conditions.push("agent = ?");
389
+ params.push(filter.agent);
390
+ }
391
+ if (filter.kind) {
392
+ conditions.push("kind = ?");
393
+ params.push(filter.kind);
394
+ }
395
+ if (filter.is_template !== undefined) {
396
+ conditions.push("is_template = ?");
397
+ params.push(filter.is_template ? 1 : 0);
398
+ }
399
+ if (filter.search) {
400
+ conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
401
+ const q = `%${filter.search}%`;
402
+ params.push(q, q, q);
403
+ }
404
+ if (filter.tags?.length) {
405
+ conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
406
+ for (const tag of filter.tags)
407
+ params.push(`%"${tag}"%`);
408
+ }
409
+ const where = conditions.length ? `WHERE ${conditions.join(" AND ")}` : "";
410
+ const normalized = normalizeBoundedReadOptions(options);
411
+ const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
412
+ const pageParams = [...params, normalized.limit, normalized.cursor];
413
+ const rows = d.query(`SELECT id, name, slug, kind, category, agent, format, is_template, version, created_at, updated_at, synced_at
414
+ FROM configs ${where} ORDER BY id LIMIT ? OFFSET ?`).all(...pageParams);
415
+ return boundedReadPage(rows.map((row) => ({
416
+ ...row,
417
+ kind: row.kind,
418
+ category: row.category,
419
+ agent: row.agent,
420
+ format: row.format,
421
+ is_template: Boolean(row.is_template)
422
+ })), total, normalized);
423
+ }
424
+ function listConfigSummariesPage(filter = {}, options = {}, db) {
425
+ const d = db || getDatabase();
426
+ const conditions = [];
427
+ const params = [];
428
+ if (filter.category) {
429
+ conditions.push("category = ?");
430
+ params.push(filter.category);
431
+ }
432
+ if (filter.agent) {
433
+ conditions.push("agent = ?");
434
+ params.push(filter.agent);
435
+ }
436
+ if (filter.kind) {
437
+ conditions.push("kind = ?");
438
+ params.push(filter.kind);
439
+ }
440
+ if (filter.is_template !== undefined) {
441
+ conditions.push("is_template = ?");
442
+ params.push(filter.is_template ? 1 : 0);
443
+ }
444
+ if (filter.search) {
445
+ conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
446
+ const q = `%${filter.search}%`;
447
+ params.push(q, q, q);
448
+ }
449
+ if (filter.tags && filter.tags.length > 0) {
450
+ conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
451
+ for (const tag of filter.tags)
452
+ params.push(`%"${tag}"%`);
453
+ }
454
+ const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
455
+ const normalized = normalizeBoundedReadOptions(options);
456
+ const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
457
+ const pageParams = [...params, normalized.limit, normalized.cursor];
458
+ const rows = d.query(`SELECT id, name, slug, kind, category, agent, target_path, format,
459
+ CASE WHEN json_valid(outputs) AND json_type(outputs) = 'array' THEN json_array_length(outputs) ELSE 0 END AS output_count, description, tags,
460
+ is_template, version, updated_at
461
+ FROM configs ${where} ORDER BY category, name, id LIMIT ? OFFSET ?`).all(...pageParams);
462
+ return boundedReadPage(rows.map((row) => ({
463
+ id: row.id,
464
+ slug: row.slug,
465
+ name: row.name,
466
+ category: row.category,
467
+ agent: row.agent,
468
+ kind: row.kind,
469
+ format: row.format,
470
+ target_path: row.target_path,
471
+ output_count: Number(row.output_count ?? 0),
472
+ version: row.version,
473
+ is_template: Boolean(row.is_template),
474
+ updated_at: row.updated_at,
475
+ description: row.description,
476
+ tags: JSON.parse(row.tags || "[]")
477
+ })), total, normalized);
478
+ }
342
479
  function updateConfig(idOrSlug, input, db) {
343
480
  const d = db || getDatabase();
344
481
  const existing = getConfig(idOrSlug, d);
@@ -673,7 +810,10 @@ export {
673
810
  listSnapshots,
674
811
  listProfilesPage,
675
812
  listMachines,
813
+ listConfigsPage,
676
814
  listConfigs,
815
+ listConfigSummariesPage,
816
+ listConfigIdentitiesPage,
677
817
  insertFeedback,
678
818
  getSnapshotByVersion,
679
819
  getSnapshot,
@@ -7,7 +7,7 @@ import {
7
7
  normalizeOsFamily,
8
8
  normalizeProfileAssetBinding,
9
9
  normalizeProfileConfigBinding
10
- } from "./index-7m4j8a33.js";
10
+ } from "./index-6jncnnw7.js";
11
11
  import {
12
12
  ConfigNotFoundError,
13
13
  ProfileNotFoundError
@@ -163,6 +163,143 @@ function listConfigs(filter, db) {
163
163
  const rows = d.query(`SELECT * FROM configs ${where} ORDER BY category, name`).all(...params);
164
164
  return rows.map(rowToConfig);
165
165
  }
166
+ function listConfigsPage(filter = {}, options = {}, db) {
167
+ const d = db || getDatabase();
168
+ const conditions = [];
169
+ const params = [];
170
+ if (filter.category) {
171
+ conditions.push("category = ?");
172
+ params.push(filter.category);
173
+ }
174
+ if (filter.agent) {
175
+ conditions.push("agent = ?");
176
+ params.push(filter.agent);
177
+ }
178
+ if (filter.kind) {
179
+ conditions.push("kind = ?");
180
+ params.push(filter.kind);
181
+ }
182
+ if (filter.is_template !== undefined) {
183
+ conditions.push("is_template = ?");
184
+ params.push(filter.is_template ? 1 : 0);
185
+ }
186
+ if (filter.search) {
187
+ conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
188
+ const q = `%${filter.search}%`;
189
+ params.push(q, q, q);
190
+ }
191
+ if (filter.tags?.length) {
192
+ conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
193
+ for (const tag of filter.tags)
194
+ params.push(`%"${tag}"%`);
195
+ }
196
+ const where = conditions.length ? `WHERE ${conditions.join(" AND ")}` : "";
197
+ const normalized = normalizeBoundedReadOptions(options);
198
+ const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
199
+ const pageParams = [...params, normalized.limit, normalized.cursor];
200
+ const rows = d.query(`SELECT * FROM configs ${where} ORDER BY id LIMIT ? OFFSET ?`).all(...pageParams);
201
+ return boundedReadPage(rows.map(rowToConfig), total, normalized);
202
+ }
203
+ function listConfigIdentitiesPage(filter = {}, options = {}, db) {
204
+ const d = db || getDatabase();
205
+ const conditions = [];
206
+ const params = [];
207
+ if (filter.category) {
208
+ conditions.push("category = ?");
209
+ params.push(filter.category);
210
+ }
211
+ if (filter.agent) {
212
+ conditions.push("agent = ?");
213
+ params.push(filter.agent);
214
+ }
215
+ if (filter.kind) {
216
+ conditions.push("kind = ?");
217
+ params.push(filter.kind);
218
+ }
219
+ if (filter.is_template !== undefined) {
220
+ conditions.push("is_template = ?");
221
+ params.push(filter.is_template ? 1 : 0);
222
+ }
223
+ if (filter.search) {
224
+ conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
225
+ const q = `%${filter.search}%`;
226
+ params.push(q, q, q);
227
+ }
228
+ if (filter.tags?.length) {
229
+ conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
230
+ for (const tag of filter.tags)
231
+ params.push(`%"${tag}"%`);
232
+ }
233
+ const where = conditions.length ? `WHERE ${conditions.join(" AND ")}` : "";
234
+ const normalized = normalizeBoundedReadOptions(options);
235
+ const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
236
+ const pageParams = [...params, normalized.limit, normalized.cursor];
237
+ const rows = d.query(`SELECT id, name, slug, kind, category, agent, format, is_template, version, created_at, updated_at, synced_at
238
+ FROM configs ${where} ORDER BY id LIMIT ? OFFSET ?`).all(...pageParams);
239
+ return boundedReadPage(rows.map((row) => ({
240
+ ...row,
241
+ kind: row.kind,
242
+ category: row.category,
243
+ agent: row.agent,
244
+ format: row.format,
245
+ is_template: Boolean(row.is_template)
246
+ })), total, normalized);
247
+ }
248
+ function listConfigSummariesPage(filter = {}, options = {}, db) {
249
+ const d = db || getDatabase();
250
+ const conditions = [];
251
+ const params = [];
252
+ if (filter.category) {
253
+ conditions.push("category = ?");
254
+ params.push(filter.category);
255
+ }
256
+ if (filter.agent) {
257
+ conditions.push("agent = ?");
258
+ params.push(filter.agent);
259
+ }
260
+ if (filter.kind) {
261
+ conditions.push("kind = ?");
262
+ params.push(filter.kind);
263
+ }
264
+ if (filter.is_template !== undefined) {
265
+ conditions.push("is_template = ?");
266
+ params.push(filter.is_template ? 1 : 0);
267
+ }
268
+ if (filter.search) {
269
+ conditions.push("(name LIKE ? OR description LIKE ? OR content LIKE ?)");
270
+ const q = `%${filter.search}%`;
271
+ params.push(q, q, q);
272
+ }
273
+ if (filter.tags && filter.tags.length > 0) {
274
+ conditions.push(`(${filter.tags.map(() => "tags LIKE ?").join(" AND ")})`);
275
+ for (const tag of filter.tags)
276
+ params.push(`%"${tag}"%`);
277
+ }
278
+ const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
279
+ const normalized = normalizeBoundedReadOptions(options);
280
+ const total = d.query(`SELECT COUNT(*) AS total FROM configs ${where}`).get(...params)?.total ?? 0;
281
+ const pageParams = [...params, normalized.limit, normalized.cursor];
282
+ const rows = d.query(`SELECT id, name, slug, kind, category, agent, target_path, format,
283
+ CASE WHEN json_valid(outputs) AND json_type(outputs) = 'array' THEN json_array_length(outputs) ELSE 0 END AS output_count, description, tags,
284
+ is_template, version, updated_at
285
+ FROM configs ${where} ORDER BY category, name, id LIMIT ? OFFSET ?`).all(...pageParams);
286
+ return boundedReadPage(rows.map((row) => ({
287
+ id: row.id,
288
+ slug: row.slug,
289
+ name: row.name,
290
+ category: row.category,
291
+ agent: row.agent,
292
+ kind: row.kind,
293
+ format: row.format,
294
+ target_path: row.target_path,
295
+ output_count: Number(row.output_count ?? 0),
296
+ version: row.version,
297
+ is_template: Boolean(row.is_template),
298
+ updated_at: row.updated_at,
299
+ description: row.description,
300
+ tags: JSON.parse(row.tags || "[]")
301
+ })), total, normalized);
302
+ }
166
303
  function updateConfig(idOrSlug, input, db) {
167
304
  const d = db || getDatabase();
168
305
  const existing = getConfig(idOrSlug, d);
@@ -497,7 +634,10 @@ export {
497
634
  listSnapshots,
498
635
  listProfilesPage,
499
636
  listMachines,
637
+ listConfigsPage,
500
638
  listConfigs,
639
+ listConfigSummariesPage,
640
+ listConfigIdentitiesPage,
501
641
  insertFeedback,
502
642
  getSnapshotByVersion,
503
643
  getSnapshot,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  assertSafeInstructionsObjectKey,
4
4
  assertSafeInstructionsObjectVersionId
5
- } from "./index-arrrx0ed.js";
5
+ } from "./index-mvckkf15.js";
6
6
  import {
7
7
  normalizeInstructionsS3Prefix
8
8
  } from "./index-8rb7ng2y.js";
@@ -4,7 +4,7 @@ import {
4
4
  assertSafeInstructionsObjectVersionId,
5
5
  createInstructionsS3ObjectStore,
6
6
  memoryInstructionsObjectStore
7
- } from "./index-arrrx0ed.js";
7
+ } from "./index-mvckkf15.js";
8
8
  import"./index-bsan4c16.js";
9
9
  export {
10
10
  memoryInstructionsObjectStore,
@@ -12,9 +12,9 @@ import {
12
12
  syncProject,
13
13
  syncToDir,
14
14
  syncToDisk
15
- } from "./index-bzyxvwcd.js";
16
- import"./index-fwbs6tma.js";
17
- import"./index-4pfq42t5.js";
15
+ } from "./index-jg8ptcwh.js";
16
+ import"./index-ypcef3a2.js";
17
+ import"./index-aj66f6xr.js";
18
18
  import"./index-35z65jsa.js";
19
19
  import"./index-3djthcm6.js";
20
20
  import"./index-nnwp92tk.js";
@@ -12,9 +12,9 @@ import {
12
12
  syncProject,
13
13
  syncToDir,
14
14
  syncToDisk
15
- } from "./index-1cnyjnd7.js";
16
- import"./index-z3ma4aqk.js";
17
- import"./index-7m4j8a33.js";
15
+ } from "./index-pdpg8a44.js";
16
+ import"./index-r7nfef2g.js";
17
+ import"./index-6jncnnw7.js";
18
18
  import"./index-n3fjspr0.js";
19
19
  import"./index-fpeyzn3n.js";
20
20
  import"./index-bsan4c16.js";