@hasna/instructions 0.7.1 → 0.7.4

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 (67) hide show
  1. package/README.md +47 -7
  2. package/dist/chunks/{apply-c3sd4agz.js → apply-1gyr8r0x.js} +3 -3
  3. package/dist/chunks/{apply-pnn7a3y7.js → apply-fyfzqc7s.js} +3 -3
  4. package/dist/chunks/{index-3djthcm6.js → index-27az1qb1.js} +28 -1
  5. package/dist/chunks/{index-r7nfef2g.js → index-6sbmg1vc.js} +3 -3
  6. package/dist/chunks/{index-pdpg8a44.js → index-axs3yftz.js} +2 -2
  7. package/dist/chunks/{index-aj66f6xr.js → index-dwagz53p.js} +92 -8
  8. package/dist/chunks/{index-6jncnnw7.js → index-enh4yv85.js} +274 -31
  9. package/dist/chunks/{index-ypcef3a2.js → index-n9arv47w.js} +2 -2
  10. package/dist/chunks/{index-n3fjspr0.js → index-preyvj8n.js} +28 -1
  11. package/dist/chunks/{index-jg8ptcwh.js → index-z27xp7fh.js} +2 -2
  12. package/dist/chunks/{local-0a9gja58.js → local-5dsm856v.js} +15 -4
  13. package/dist/chunks/{local-969ye538.js → local-yxsbs8x3.js} +15 -4
  14. package/dist/chunks/{sync-xtkbm5br.js → sync-6r1v8hd3.js} +4 -4
  15. package/dist/chunks/{sync-q5hvwq6e.js → sync-k3pab4s6.js} +4 -4
  16. package/dist/chunks/{template-wgnzdn7h.js → template-e4qrxs8p.js} +1 -1
  17. package/dist/chunks/{template-fsfxpe4p.js → template-nhn124zd.js} +1 -1
  18. package/dist/cli/index.js +1018 -584
  19. package/dist/data/config-store.d.ts +12 -4
  20. package/dist/data/config-store.d.ts.map +1 -1
  21. package/dist/db/configs.d.ts.map +1 -1
  22. package/dist/index.d.ts +8 -4
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1264 -601
  25. package/dist/lib/asset-plan.d.ts +4 -1
  26. package/dist/lib/asset-plan.d.ts.map +1 -1
  27. package/dist/lib/codewith-shared-todos-storage-standard.d.ts.map +1 -1
  28. package/dist/lib/dangerous-operation-guard-standard.d.ts.map +1 -1
  29. package/dist/lib/global-agent-rules-standard.d.ts.map +1 -1
  30. package/dist/lib/global-source-coverage.d.ts +12 -7
  31. package/dist/lib/global-source-coverage.d.ts.map +1 -1
  32. package/dist/lib/harness-discovery.d.ts +52 -0
  33. package/dist/lib/harness-discovery.d.ts.map +1 -0
  34. package/dist/lib/instruction-graph.d.ts +1 -1
  35. package/dist/lib/instruction-graph.d.ts.map +1 -1
  36. package/dist/lib/instruction-source-policy.d.ts +6 -0
  37. package/dist/lib/instruction-source-policy.d.ts.map +1 -0
  38. package/dist/lib/machine.d.ts.map +1 -1
  39. package/dist/lib/managed-skill-runtimes.d.ts +12 -28
  40. package/dist/lib/managed-skill-runtimes.d.ts.map +1 -1
  41. package/dist/lib/platform-profiles.d.ts.map +1 -1
  42. package/dist/lib/project-dashboard-standard.d.ts.map +1 -1
  43. package/dist/lib/session-apply.d.ts +35 -0
  44. package/dist/lib/session-apply.d.ts.map +1 -1
  45. package/dist/lib/session-refresh.d.ts +30 -0
  46. package/dist/lib/session-refresh.d.ts.map +1 -0
  47. package/dist/lib/session-render.d.ts +41 -1
  48. package/dist/lib/session-render.d.ts.map +1 -1
  49. package/dist/lib/transforms.d.ts +1 -0
  50. package/dist/lib/transforms.d.ts.map +1 -1
  51. package/dist/mcp/index.js +13 -12
  52. package/dist/mcp/server.d.ts.map +1 -1
  53. package/dist/sdk/index.d.ts +2 -0
  54. package/dist/sdk/index.d.ts.map +1 -1
  55. package/dist/sdk/index.js +172 -0
  56. package/dist/sdk/v1-client.d.ts +7 -1
  57. package/dist/sdk/v1-client.d.ts.map +1 -1
  58. package/dist/sdk/v1.generated.d.ts +26 -0
  59. package/dist/sdk/v1.generated.d.ts.map +1 -1
  60. package/dist/server/index.js +199 -8
  61. package/dist/server/openapi.d.ts +150 -0
  62. package/dist/server/openapi.d.ts.map +1 -1
  63. package/dist/server/v1.d.ts.map +1 -1
  64. package/dist/storage/cloud-store.d.ts.map +1 -1
  65. package/dist/types/index.d.ts +24 -2
  66. package/dist/types/index.d.ts.map +1 -1
  67. package/package.json +1 -1
@@ -4,6 +4,7 @@ var CONFIG_AGENTS = [
4
4
  "claude",
5
5
  "codex",
6
6
  "opencode",
7
+ "sumi",
7
8
  "cursor",
8
9
  "codewith",
9
10
  "aicopilot",
@@ -30,6 +31,32 @@ var ASSET_UNINSTALL_POLICIES = ["remove-managed", "retain"];
30
31
  var ASSET_ROLLBACK_POLICIES = ["snapshot", "installer-receipt", "none"];
31
32
  var INSTRUCTIONS_DOMAIN_ARCHIVE_SCHEMA = "hasna.instructions.domain-archive/v2";
32
33
 
34
+ class InvalidExpectedVersionError extends Error {
35
+ code = "INVALID_EXPECTED_VERSION";
36
+ constructor() {
37
+ super("expected_version must be a positive safe integer");
38
+ this.name = "InvalidExpectedVersionError";
39
+ }
40
+ }
41
+ function validateExpectedConfigVersion(value) {
42
+ if (value !== undefined && (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1)) {
43
+ throw new InvalidExpectedVersionError;
44
+ }
45
+ }
46
+
47
+ class ConfigVersionConflictError extends Error {
48
+ config_id;
49
+ expected_version;
50
+ code = "CONFIG_VERSION_CONFLICT";
51
+ status = 409;
52
+ constructor(config_id, expected_version) {
53
+ super(`Config version conflict: ${config_id} no longer has expected version ${expected_version}`);
54
+ this.config_id = config_id;
55
+ this.expected_version = expected_version;
56
+ this.name = "ConfigVersionConflictError";
57
+ }
58
+ }
59
+
33
60
  class ConfigNotFoundError extends Error {
34
61
  constructor(id) {
35
62
  super(`Config not found: ${id}`);
@@ -116,4 +143,4 @@ function isTemplate(content) {
116
143
  return VAR_PATTERN.test(content);
117
144
  }
118
145
 
119
- export { CONFIG_AGENTS, PROFILE_CONFIG_BINDING_SCHEMA, INSTRUCTION_ACTIVATION_MODES, INSTRUCTION_FALLBACKS, PROFILE_ASSET_BINDING_SCHEMA, ASSET_KINDS, ASSET_DESTINATION_STRATEGIES, ASSET_SCOPES, ASSET_UNINSTALL_POLICIES, ASSET_ROLLBACK_POLICIES, INSTRUCTIONS_DOMAIN_ARCHIVE_SCHEMA, ConfigNotFoundError, ProfileNotFoundError, ConfigApplyError, parseTemplateVars, extractTemplateVars, renderTemplate, renderTemplatePreview, isTemplate };
146
+ export { CONFIG_AGENTS, PROFILE_CONFIG_BINDING_SCHEMA, INSTRUCTION_ACTIVATION_MODES, INSTRUCTION_FALLBACKS, PROFILE_ASSET_BINDING_SCHEMA, ASSET_KINDS, ASSET_DESTINATION_STRATEGIES, ASSET_SCOPES, ASSET_UNINSTALL_POLICIES, ASSET_ROLLBACK_POLICIES, INSTRUCTIONS_DOMAIN_ARCHIVE_SCHEMA, validateExpectedConfigVersion, ConfigVersionConflictError, ConfigNotFoundError, ProfileNotFoundError, ConfigApplyError, parseTemplateVars, extractTemplateVars, renderTemplate, renderTemplatePreview, isTemplate };
@@ -5,7 +5,7 @@ import {
5
5
  expandPath,
6
6
  getConfigHome,
7
7
  normalizeTargetPath
8
- } from "./index-ypcef3a2.js";
8
+ } from "./index-n9arv47w.js";
9
9
  import {
10
10
  applyTransform,
11
11
  detectMachineContext,
@@ -13,7 +13,7 @@ import {
13
13
  resolveConfigStore,
14
14
  retiredOrUnsupportedAgentReason,
15
15
  templateizeMachineContent
16
- } from "./index-aj66f6xr.js";
16
+ } from "./index-dwagz53p.js";
17
17
  import {
18
18
  isSecretVarName,
19
19
  redactContent,
@@ -14,12 +14,14 @@ import {
14
14
  normalizeOsFamily,
15
15
  normalizeProfileAssetBinding,
16
16
  normalizeProfileConfigBinding
17
- } from "./index-aj66f6xr.js";
17
+ } from "./index-dwagz53p.js";
18
18
  import"./index-35z65jsa.js";
19
19
  import {
20
20
  ConfigNotFoundError,
21
- ProfileNotFoundError
22
- } from "./index-3djthcm6.js";
21
+ ConfigVersionConflictError,
22
+ ProfileNotFoundError,
23
+ validateExpectedConfigVersion
24
+ } from "./index-27az1qb1.js";
23
25
  import"./index-nnwp92tk.js";
24
26
 
25
27
  // src/db/database.ts
@@ -477,6 +479,7 @@ function listConfigSummariesPage(filter = {}, options = {}, db) {
477
479
  })), total, normalized);
478
480
  }
479
481
  function updateConfig(idOrSlug, input, db) {
482
+ validateExpectedConfigVersion(input.expected_version);
480
483
  const d = db || getDatabase();
481
484
  const existing = getConfig(idOrSlug, d);
482
485
  const ts = now();
@@ -532,7 +535,15 @@ function updateConfig(idOrSlug, input, db) {
532
535
  }
533
536
  return d.transaction(() => {
534
537
  params.push(existing.id);
535
- d.run(`UPDATE configs SET ${updates.join(", ")} WHERE id = ?`, params);
538
+ const condition = input.expected_version === undefined ? "" : " AND version = ?";
539
+ if (input.expected_version !== undefined)
540
+ params.push(input.expected_version);
541
+ const result = d.run(`UPDATE configs SET ${updates.join(", ")} WHERE id = ?${condition}`, params);
542
+ if (result.changes !== 1) {
543
+ if (input.expected_version !== undefined)
544
+ throw new ConfigVersionConflictError(existing.id, input.expected_version);
545
+ throw new ConfigNotFoundError(existing.id);
546
+ }
536
547
  const updated = getConfigById(existing.id, d);
537
548
  createSnapshot(updated.id, updated.content, updated.version, d);
538
549
  return updated;
@@ -7,11 +7,13 @@ import {
7
7
  normalizeOsFamily,
8
8
  normalizeProfileAssetBinding,
9
9
  normalizeProfileConfigBinding
10
- } from "./index-6jncnnw7.js";
10
+ } from "./index-enh4yv85.js";
11
11
  import {
12
12
  ConfigNotFoundError,
13
- ProfileNotFoundError
14
- } from "./index-n3fjspr0.js";
13
+ ConfigVersionConflictError,
14
+ ProfileNotFoundError,
15
+ validateExpectedConfigVersion
16
+ } from "./index-preyvj8n.js";
15
17
  import {
16
18
  getDatabase,
17
19
  insertFeedback,
@@ -301,6 +303,7 @@ function listConfigSummariesPage(filter = {}, options = {}, db) {
301
303
  })), total, normalized);
302
304
  }
303
305
  function updateConfig(idOrSlug, input, db) {
306
+ validateExpectedConfigVersion(input.expected_version);
304
307
  const d = db || getDatabase();
305
308
  const existing = getConfig(idOrSlug, d);
306
309
  const ts = now();
@@ -356,7 +359,15 @@ function updateConfig(idOrSlug, input, db) {
356
359
  }
357
360
  return d.transaction(() => {
358
361
  params.push(existing.id);
359
- d.run(`UPDATE configs SET ${updates.join(", ")} WHERE id = ?`, params);
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
+ }
360
371
  const updated = getConfigById(existing.id, d);
361
372
  createSnapshot(updated.id, updated.content, updated.version, d);
362
373
  return updated;
@@ -12,10 +12,10 @@ import {
12
12
  syncProject,
13
13
  syncToDir,
14
14
  syncToDisk
15
- } from "./index-pdpg8a44.js";
16
- import"./index-r7nfef2g.js";
17
- import"./index-6jncnnw7.js";
18
- import"./index-n3fjspr0.js";
15
+ } from "./index-axs3yftz.js";
16
+ import"./index-6sbmg1vc.js";
17
+ import"./index-enh4yv85.js";
18
+ import"./index-preyvj8n.js";
19
19
  import"./index-fpeyzn3n.js";
20
20
  import"./index-bsan4c16.js";
21
21
  export {
@@ -12,11 +12,11 @@ import {
12
12
  syncProject,
13
13
  syncToDir,
14
14
  syncToDisk
15
- } from "./index-jg8ptcwh.js";
16
- import"./index-ypcef3a2.js";
17
- import"./index-aj66f6xr.js";
15
+ } from "./index-z27xp7fh.js";
16
+ import"./index-n9arv47w.js";
17
+ import"./index-dwagz53p.js";
18
18
  import"./index-35z65jsa.js";
19
- import"./index-3djthcm6.js";
19
+ import"./index-27az1qb1.js";
20
20
  import"./index-nnwp92tk.js";
21
21
  export {
22
22
  syncToDisk,
@@ -5,7 +5,7 @@ import {
5
5
  parseTemplateVars,
6
6
  renderTemplate,
7
7
  renderTemplatePreview
8
- } from "./index-n3fjspr0.js";
8
+ } from "./index-preyvj8n.js";
9
9
  import"./index-bsan4c16.js";
10
10
  export {
11
11
  renderTemplatePreview,
@@ -5,7 +5,7 @@ import {
5
5
  parseTemplateVars,
6
6
  renderTemplate,
7
7
  renderTemplatePreview
8
- } from "./index-3djthcm6.js";
8
+ } from "./index-27az1qb1.js";
9
9
  import"./index-nnwp92tk.js";
10
10
  export {
11
11
  renderTemplatePreview,