@anhlp/alp-core 0.0.1-beta.6 → 0.0.1-beta.8

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 (135) hide show
  1. package/dist/bridges.d.ts +5 -6
  2. package/dist/bridges.js +3 -4
  3. package/dist/library-edit.d.ts +51 -2
  4. package/dist/library-edit.js +160 -8
  5. package/dist/library.d.ts +14 -1
  6. package/dist/library.js +73 -5
  7. package/dist/models.d.ts +35 -0
  8. package/dist/models.js +17 -1
  9. package/dist/packaged.d.ts +37 -45
  10. package/dist/packaged.js +42 -156
  11. package/dist/packs.d.ts +57 -0
  12. package/dist/packs.js +247 -0
  13. package/dist/permissions.d.ts +3 -2
  14. package/dist/permissions.js +6 -3
  15. package/dist/profiles.js +6 -6
  16. package/dist/providers.d.ts +2 -5
  17. package/dist/providers.js +22 -6
  18. package/dist/skill-validate.d.ts +85 -0
  19. package/dist/skill-validate.js +298 -0
  20. package/dist/template-path.d.ts +2 -2
  21. package/dist/template-path.js +0 -5
  22. package/dist/types.d.ts +2 -0
  23. package/dist/upgrade.d.ts +10 -0
  24. package/dist/upgrade.js +112 -6
  25. package/dist/validation.js +6 -6
  26. package/package.json +18 -2
  27. package/src/bridges.js +9 -10
  28. package/src/library-edit.js +170 -8
  29. package/src/library.js +96 -6
  30. package/src/models.js +24 -0
  31. package/src/packaged.js +74 -191
  32. package/src/packs.js +246 -0
  33. package/src/permissions.d.ts +3 -2
  34. package/src/permissions.js +13 -3
  35. package/src/profiles.js +7 -7
  36. package/src/providers.js +22 -8
  37. package/src/resolver.js +1 -1
  38. package/src/skill-validate.js +287 -0
  39. package/src/template-path.js +1 -6
  40. package/src/types.d.ts +2 -0
  41. package/src/upgrade.js +54 -6
  42. package/src/validation.js +8 -7
  43. package/templates/ALP.md +52 -52
  44. package/templates/agents/lead/AGENT.md +77 -74
  45. package/templates/agents/main/AGENT.md +153 -145
  46. package/templates/agents/oracle/AGENT.md +38 -37
  47. package/templates/agents/peer/AGENT.md +56 -52
  48. package/templates/agents/reviewer/AGENT.md +63 -65
  49. package/templates/agents/supervisor/AGENT.md +63 -63
  50. package/templates/packs/architecture/agents/architect/AGENT.md +41 -0
  51. package/templates/packs/architecture/agents/architect/agent.json +5 -0
  52. package/templates/packs/architecture/agents/docs-maintainer/AGENT.md +33 -0
  53. package/templates/packs/architecture/agents/docs-maintainer/agent.json +4 -0
  54. package/templates/packs/architecture/pack.json +7 -0
  55. package/templates/packs/architecture/teams/blueprint/HOUSE_RULES.md +12 -0
  56. package/templates/packs/architecture/teams/blueprint/team.json +19 -0
  57. package/templates/packs/backend/pack.json +6 -0
  58. package/templates/packs/backend/skills/backend-development/SKILL.md +102 -0
  59. package/templates/packs/backend/skills/backend-development/references/api-design.md +96 -0
  60. package/templates/packs/backend/skills/backend-development/references/authentication.md +78 -0
  61. package/templates/packs/backend/skills/backend-development/references/error-handling.md +86 -0
  62. package/templates/packs/backend/skills/backend-development/references/testing.md +81 -0
  63. package/templates/packs/backend/skills/databases/SKILL.md +103 -0
  64. package/templates/packs/backend/skills/databases/references/query-performance.md +87 -0
  65. package/templates/packs/backend/skills/databases/references/schema-and-migrations.md +87 -0
  66. package/templates/packs/design/pack.json +6 -0
  67. package/templates/packs/design/skills/ui-design/SKILL.md +86 -0
  68. package/templates/packs/design/skills/ui-design/references/design-tokens.md +67 -0
  69. package/templates/packs/design/skills/ui-design/references/interaction-states.md +73 -0
  70. package/templates/packs/design/skills/ui-design/references/layout-and-typography.md +71 -0
  71. package/templates/packs/design/skills/ui-design/references/ui-review.md +83 -0
  72. package/templates/packs/frontend/pack.json +6 -0
  73. package/templates/packs/frontend/skills/frontend-development/SKILL.md +105 -0
  74. package/templates/packs/frontend/skills/frontend-development/references/accessibility.md +86 -0
  75. package/templates/packs/frontend/skills/frontend-development/references/components-and-state.md +79 -0
  76. package/templates/packs/frontend/skills/frontend-development/references/data-fetching.md +86 -0
  77. package/templates/packs/frontend/skills/frontend-development/references/frameworks.md +77 -0
  78. package/templates/packs/frontend/skills/frontend-development/references/performance.md +78 -0
  79. package/templates/packs/integration/pack.json +6 -0
  80. package/templates/packs/integration/skills/mcp-integration/SKILL.md +100 -0
  81. package/templates/packs/integration/skills/mcp-integration/references/server-implementation.md +95 -0
  82. package/templates/packs/integration/skills/mcp-integration/references/testing.md +78 -0
  83. package/templates/packs/integration/skills/mcp-integration/references/tool-design.md +97 -0
  84. package/templates/packs/operations/pack.json +6 -0
  85. package/templates/packs/operations/skills/devops/SKILL.md +85 -0
  86. package/templates/packs/operations/skills/devops/references/ci-cd.md +84 -0
  87. package/templates/packs/operations/skills/devops/references/containers.md +85 -0
  88. package/templates/packs/operations/skills/devops/references/deployment-and-rollback.md +85 -0
  89. package/templates/packs/operations/skills/devops/references/observability.md +86 -0
  90. package/templates/packs/quality/pack.json +6 -0
  91. package/templates/packs/quality/skills/web-testing/SKILL.md +102 -0
  92. package/templates/packs/quality/skills/web-testing/references/e2e.md +85 -0
  93. package/templates/packs/quality/skills/web-testing/references/performance-testing.md +85 -0
  94. package/templates/packs/quality/skills/web-testing/references/security-testing.md +78 -0
  95. package/templates/packs/quality/skills/web-testing/references/unit-and-component.md +78 -0
  96. package/templates/role-skills.json +4 -4
  97. package/templates/skills/architecture-docs/SKILL.md +81 -0
  98. package/templates/skills/architecture-docs/references/adr.md +62 -0
  99. package/templates/skills/architecture-docs/references/diagrams.md +60 -0
  100. package/templates/skills/architecture-docs/references/evidence-rules.md +49 -0
  101. package/templates/skills/bug-loop/SKILL.md +41 -40
  102. package/templates/skills/bug-loop/references/test-proof.md +21 -19
  103. package/templates/skills/compact/SKILL.md +2 -2
  104. package/templates/skills/curate/SKILL.md +6 -5
  105. package/templates/skills/feature-architecture/SKILL.md +90 -0
  106. package/templates/skills/feature-architecture/references/architecture-contract.md +95 -0
  107. package/templates/skills/feature-architecture/references/feature-design.md +69 -0
  108. package/templates/skills/feature-architecture/scripts/check-boundaries.mjs +270 -0
  109. package/templates/skills/goal-griller/SKILL.md +27 -27
  110. package/templates/skills/prompt-leverage/SKILL.md +29 -27
  111. package/templates/skills/prompt-leverage/references/brief-template.md +9 -9
  112. package/templates/skills/release-readiness/SKILL.md +83 -0
  113. package/templates/skills/release-readiness/references/checklist.md +40 -0
  114. package/templates/skills/release-readiness/references/verdict-template.md +53 -0
  115. package/templates/skills/safe-refactor/SKILL.md +84 -0
  116. package/templates/skills/safe-refactor/references/characterization-tests.md +57 -0
  117. package/templates/skills/safe-refactor/references/compatibility-checklist.md +56 -0
  118. package/templates/skills/security-review/SKILL.md +87 -0
  119. package/templates/skills/security-review/references/checklist.md +74 -0
  120. package/templates/skills/security-review/references/severity.md +61 -0
  121. package/templates/skills/sequence-execution-plan/SKILL.md +41 -38
  122. package/templates/skills/sequence-execution-plan/references/plan-template.md +5 -5
  123. package/templates/skills/skill-authoring/SKILL.md +84 -0
  124. package/templates/skills/skill-authoring/references/evaluation.md +45 -0
  125. package/templates/skills/skill-authoring/references/skill-anatomy.md +74 -0
  126. package/templates/skills/skill-authoring/references/trigger-design.md +52 -0
  127. package/templates/skills/smart-commits/SKILL.md +37 -36
  128. package/templates/skills/test-strategy/SKILL.md +83 -0
  129. package/templates/skills/test-strategy/references/contract-tests.md +46 -0
  130. package/templates/skills/test-strategy/references/risk-matrix.md +53 -0
  131. package/templates/skills/xia/SKILL.md +40 -38
  132. package/templates/teams/cafe/HOUSE_RULES.md +1 -1
  133. package/templates/teams/cafe/team.json +1 -1
  134. package/templates/teams/pho/HOUSE_RULES.md +1 -1
  135. package/templates/teams/pho/team.json +1 -1
package/dist/upgrade.js CHANGED
@@ -13,13 +13,118 @@ var legacy = {
13
13
  ".alp/agents/main/AGENT.md": "# Main agent\n\nHelp with tasks in this project.\n"
14
14
  };
15
15
  var teamV1 = {
16
- "ALP.md": ["c2785aac6538d10e79bd6fb59b11066ccdec77287edf950fad59aa57bf3417f1", "0875293195d35d965effb70bb150d1edbc789f66f72c545f7760dea4346b1a9a"],
17
- ".alp/agents/main/AGENT.md": ["15d217cbc5ede782790d1086124598d9a2b5ff13bcf971a37231962fcef1b47c", "e7201a1ed7800d7500b5c8091bd8a435aa9d5138f247c2b02b8bf76299387c90", "5001b807bbb686aa1a3b7ecadf9501428909e052e8231281454fd41cbe0ebf27", "90f9903fcc97ddf6336e1a28b81103dddc60a6038dcf74d326be8998862cb022", "9085ab906e2744a4151ae5c63dd66a545115cd4c876be1fd80f0a0ed4e623da8", "fb55cfb0852d07592090de2c49e6c5c2b57936cbffc823dd24767c2db5e5f7fb"],
18
- ".alp/agents/lead/AGENT.md": ["c259b085a3c102445f97e5c7d402ca68347bcc1a9b02d6ab96e02be6d8b6f9af", "2eef2a4474f757cd89b35b50638a1b23fe49a54c26bf0dedb24a96d7117ddd92", "6c71393c9b3aa655c4731bda96396ea3ec0d4da62cddb3ad50d1a24113416b77", "a382f0faa724e23a0ba9c212205978aa3fef87c3aecdf8823fba136e04568487", "547e3f8fc354b22c7beb3432182d68f4de1f24938375c8bfb167ae8afbf97de2"],
19
- ".alp/agents/peer/AGENT.md": ["f3dcf16c8c899a5378a468e922ca3956fd72cbb3e3798ed1109f11e01aa8f476", "39ccf3317eba3003faad77ebad4489fae3eb3c4d89258a03f619d1d3d65af0b7", "c59e45e8f22eb0daca9b8b5e1b19e90666156807f160e75a21eca48b5fee1102", "9623dbf76eda598f6267629e993663c149acb0efd253f3900a4ee1eda8f2f9e7"],
20
- ".alp/agents/oracle/AGENT.md": ["cdce1babcd587a190dc94a32a951ed70ce2c75f99c205a4049df940851ac7059"],
21
- ".alp/agents/reviewer/AGENT.md": ["6eab9f918c79335a0665bf4e3a3a26b66258684d6725c4c95637e70e8d355123"]
16
+ "ALP.md": [
17
+ "c2785aac6538d10e79bd6fb59b11066ccdec77287edf950fad59aa57bf3417f1",
18
+ "0875293195d35d965effb70bb150d1edbc789f66f72c545f7760dea4346b1a9a",
19
+ "fe0d5e6f64ef5a5030ee99feaf083f062a8e5136ac52d451e2ca7cdacb21d14f",
20
+ "e04fe558a26d6e3c9b08211c426a83c368e4f0d15b0929e55df8ab4e5c4bb932",
21
+ // 61181b5
22
+ "ff1a7da448b735a9b4f88e3d9b6006d048114d3becee96a331d225b63e453c56",
23
+ // ca2a971
24
+ "263135a3139eb40501f6e502271e946ec3db4692b63e39c2dd349ac0aaae6d62",
25
+ // 818ab2e
26
+ "e855f56ca0af0691c731ac5f2eb93d2528e339f2dbfd6f2376594f878d2c11e1",
27
+ // 1f827c6
28
+ "48c6a0f80b41958457f8dbaaad7a4b3118efeaf5feb6ae626501c2f7896b077d"
29
+ ],
30
+ // PR #330 (replaces 83388aa's hash, which never reached main)
31
+ ".alp/agents/main/AGENT.md": [
32
+ "15d217cbc5ede782790d1086124598d9a2b5ff13bcf971a37231962fcef1b47c",
33
+ "e7201a1ed7800d7500b5c8091bd8a435aa9d5138f247c2b02b8bf76299387c90",
34
+ "5001b807bbb686aa1a3b7ecadf9501428909e052e8231281454fd41cbe0ebf27",
35
+ "90f9903fcc97ddf6336e1a28b81103dddc60a6038dcf74d326be8998862cb022",
36
+ "9085ab906e2744a4151ae5c63dd66a545115cd4c876be1fd80f0a0ed4e623da8",
37
+ "fb55cfb0852d07592090de2c49e6c5c2b57936cbffc823dd24767c2db5e5f7fb",
38
+ "91b71f5750e75f707488b70618e1d65a63aabf7518762f97ea0fde999d36fead",
39
+ "60d92fa634e178244a38e99c074e169af1847d7512e268262148ec15ebf08bed",
40
+ // 61181b5
41
+ "b501142ebff430e2ac6d0c3ecb2673cbf0fe0e1fa123b73b113ba9b4aa5f3a39",
42
+ // ca2a971
43
+ "ddbd75ebacf5f13615fa3da4941a389b14b534742032c3046e0e6c214a46c989",
44
+ // ec26e6c
45
+ "5d610e7639bc8eaa29ad4119a5c090cbd286bd217f2f4a7d3abdd59725a985c1",
46
+ // a1acd92
47
+ "28037d678457a392a42510d57919b14a643ea729c2a358fa7aeee4b7a33e6727",
48
+ // 8d0e12a
49
+ "b4435cf5ef8cfab2238eee86298f21cfa508e3fdeb6b3e697fde94160c341fe7",
50
+ // 105f68f
51
+ "973539ce5dd998440cb59938f37260760f96f66a67b66369fcb28421acd49903",
52
+ // 40ce2de
53
+ "ab85e561f62a46e8838cc955984b66583a7325e69c1e7f2fd049479241553751",
54
+ // cc9215e
55
+ "8b8d0bff45d245543f543ecd15043be38fd03edd364c6750aac58b87785c1afa",
56
+ // 818ab2e
57
+ "2e82f110b108032c3c4444c306e73409bb6b481e5dc9ab080fe1ee2eb583fb78",
58
+ // b8d2fbc
59
+ "cde93f41883b26c2ef7636735d88be8fb202b143c479821647799c83b7d673dc",
60
+ // 9180aa1
61
+ "29f181001edfee5521d8f4965b33f501f8ef869f6af3abf74a05e5f1623809ac",
62
+ // f4d7986
63
+ "d6f8002a81e3e0b7bb5868a6834d7be37731cc307877d7a03513067be10cad2f",
64
+ // 1f827c6
65
+ "b9bdd073e22903e3813f13caf87c9341215476ed692b3f04bc0971b66fd93ac5"
66
+ ],
67
+ // 83388aa
68
+ ".alp/agents/lead/AGENT.md": [
69
+ "c259b085a3c102445f97e5c7d402ca68347bcc1a9b02d6ab96e02be6d8b6f9af",
70
+ "2eef2a4474f757cd89b35b50638a1b23fe49a54c26bf0dedb24a96d7117ddd92",
71
+ "6c71393c9b3aa655c4731bda96396ea3ec0d4da62cddb3ad50d1a24113416b77",
72
+ "a382f0faa724e23a0ba9c212205978aa3fef87c3aecdf8823fba136e04568487",
73
+ "547e3f8fc354b22c7beb3432182d68f4de1f24938375c8bfb167ae8afbf97de2",
74
+ "f3609df1486c0911459d8ee7d823b344369df0538654b0de6e9bc23170186b22",
75
+ "1674d7b96450824111ce885c828af51aa8924c38888bdeb583f4f31684c2bf60",
76
+ // 61181b5
77
+ "7cd01a44200fda79ae0979a4975c483494a35e2e8c144b4e56f0b61046fc1a67",
78
+ // ca2a971
79
+ "c622392fcb94aeec18efcb12fe9ed574117304af02c303d0f575a2181991b454",
80
+ // 8d0e12a
81
+ "6e9166b3b72333b76b4b2ef5a7778e142d6fd3c1023efd8a792bec1b12516415",
82
+ // 40ce2de
83
+ "8aef2591deb1ca12f3cbc843445688140aeb03f7c42bff8e15ef74bdd03be940",
84
+ // 1f827c6
85
+ "e241608ee9579ed894024cba8f9b7b60e75283179d68ebbd4cb28a526c78965d"
86
+ ],
87
+ // 83388aa
88
+ ".alp/agents/peer/AGENT.md": [
89
+ "f3dcf16c8c899a5378a468e922ca3956fd72cbb3e3798ed1109f11e01aa8f476",
90
+ "39ccf3317eba3003faad77ebad4489fae3eb3c4d89258a03f619d1d3d65af0b7",
91
+ "c59e45e8f22eb0daca9b8b5e1b19e90666156807f160e75a21eca48b5fee1102",
92
+ "9623dbf76eda598f6267629e993663c149acb0efd253f3900a4ee1eda8f2f9e7",
93
+ "20b0d2b6be74597ea1f39cf6d2d56c0ef2bffe39cb3bfe1ae41761748ef9bfae",
94
+ "da389b7fa194fcf4cb8683664d30e06197999d804ec4ee94c1889bb397f540a9",
95
+ // 61181b5
96
+ "c7c8f4c5468484bab165f8f32b141398a259d4e6e9966e304528d82858e6807e",
97
+ // ca2a971
98
+ "d7cbdac679c82086ce2601d0a2c82480f6b2300ea011a9e07862f1b900d6ac75"
99
+ ],
100
+ // 1f827c6
101
+ ".alp/agents/oracle/AGENT.md": [
102
+ "cdce1babcd587a190dc94a32a951ed70ce2c75f99c205a4049df940851ac7059",
103
+ "0907091b17aa8e54215b65171433f222b8491e9490a16a66b6a2b8cffc3f9023",
104
+ "ae6219e0141d290705ed45992f0cc78688d17c78757f7f1f72f1639432e110cc"
105
+ ],
106
+ // 1f827c6
107
+ ".alp/agents/reviewer/AGENT.md": [
108
+ "6eab9f918c79335a0665bf4e3a3a26b66258684d6725c4c95637e70e8d355123",
109
+ "1809de0be6473d5f9ceeae2d35128d52a0c0cde3968b45a7569ceae7a8a74416",
110
+ "56bebc192fda9d67bc2ceaf14d4f0cf274eaa40bf3e652caaf85c239eba1a253"
111
+ ],
112
+ // 1f827c6
113
+ ".alp/agents/supervisor/AGENT.md": [
114
+ "81ac93f4fbf2337224f838d39a9c4ef13fdba12d5fc7de681a00628bf9e69a27",
115
+ "a2be7e682b030d2ff122ba4e836b1c89858493a05937fa11ad1fa808e0df9c8d",
116
+ // 61181b5
117
+ "d26d642128bedb6c90d4a84b227877ae4ea8be0838de75f40d786c0ba55183ae",
118
+ // ec26e6c
119
+ "f920b505cda38c90f7014827352225846b6b1e35a40675e2f5d01b03cee250ce",
120
+ // cdbc297
121
+ "10e22e451264a901a7ad62e04189a91fae70940a62f4646f22c1135244986d03",
122
+ // cc9215e
123
+ "6c306170ee5218313c93dc8bc1049e1dd9daf401073fda4c476ff4b5630765ab"
124
+ ]
125
+ // 1f827c6
22
126
  };
127
+ var shippedRoleHashes = teamV1;
23
128
  var renamedProfiles = { smart: "pho", supervised: "cafe" };
24
129
  async function skillFiles(directory) {
25
130
  const files = /* @__PURE__ */ new Map();
@@ -196,5 +301,6 @@ async function retireAgentCopies(root, result, backupPath, replace) {
196
301
  });
197
302
  }
198
303
  export {
304
+ shippedRoleHashes,
199
305
  upgradeProject
200
306
  };
@@ -1,7 +1,7 @@
1
1
  // packages/core/src/validation.js
2
2
  import path from "node:path";
3
3
  import { AlpError } from "./errors.js";
4
- import { MODELS } from "./models.js";
4
+ import { EFFORTS, knownModel } from "./models.js";
5
5
  import { validatePermissions } from "./permissions.js";
6
6
  import { validateVerify } from "./verify.js";
7
7
  var object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
@@ -10,7 +10,6 @@ var stringMap = (value) => object(value) && Object.values(value).every((v) => ty
10
10
  function requireValue(condition, code, source, message) {
11
11
  if (!condition) throw new AlpError(code, `${source}: ${message}`);
12
12
  }
13
- var EFFORTS = ["none", "off", "low", "medium", "high", "xhigh", "max", "ultra", "ultracode"];
14
13
  var PROJECT_SETTINGS = ["$schema", "defaultAgent", "workflow", "runtime", "permissions", "verify", "delegation", "team", "profile", "templateDefaults", "compact", "curate"];
15
14
  var USER_SETTINGS = ["$schema", "language", "permissions", "limits", "recovery", "web", "curate"];
16
15
  var RETIRED_SETTINGS = { project: {}, user: {} };
@@ -98,8 +97,9 @@ function validateSettings(settings, source) {
98
97
  const where = `${key}.${team}.${agent}`;
99
98
  check(object(config), `${where} must be an object`);
100
99
  if (config.autocompact !== void 0) validateAutoCompact(config.autocompact, check, `${where}.autocompact`);
100
+ if (config.commands !== void 0) check(Array.isArray(config.commands) && config.commands.every((name) => typeof name === "string" && /^[^\s/]{1,256}$/.test(name)), `${where}.commands must be a list of command names, without whitespace or /`);
101
101
  if (Object.hasOwn(config, "profiles")) {
102
- check(Object.keys(config).every((key2) => ["profiles", "autocompact"].includes(key2)), `${where}: use profiles and autocompact`);
102
+ check(Object.keys(config).every((key2) => ["profiles", "autocompact", "commands"].includes(key2)), `${where}: use profiles, autocompact and commands`);
103
103
  check(Array.isArray(config.profiles) && config.profiles.length > 0, `${where}.profiles must be a nonempty list`);
104
104
  const models = [];
105
105
  for (const [index, entry] of config.profiles.entries()) {
@@ -109,7 +109,7 @@ function validateSettings(settings, source) {
109
109
  const [provider, model, effort] = entry.split(":");
110
110
  check(model !== "*" || agent !== "oracle" && agent !== "main", `${at}: ${agent} runs on a named model, not any model`);
111
111
  if (effort !== void 0) {
112
- const known = MODELS.find((candidate) => candidate.runtime === provider && candidate.id === model);
112
+ const known = knownModel(`${provider}:${model}`);
113
113
  check(EFFORTS.includes(effort), `${at}: effort ${effort} is unsupported`);
114
114
  check(!known?.efforts.length || known.efforts.includes(effort), `${at}: ${provider}:${model} takes effort ${known?.efforts.join(", ")}`);
115
115
  }
@@ -123,14 +123,14 @@ function validateSettings(settings, source) {
123
123
  check(new Set(models).size === models.length, `${where}.profiles must not repeat the same model`);
124
124
  check(agent !== "main" || config.profiles.length === 1, `${where}.profiles: main runs on exactly one model`);
125
125
  } else if (agent === "oracle") {
126
- const entries = Object.entries(config).filter(([key2]) => key2 !== "autocompact");
126
+ const entries = Object.entries(config).filter(([key2]) => key2 !== "autocompact" && key2 !== "commands");
127
127
  check(entries.length > 0 && entries.every(([provider]) => ["claude", "codex"].includes(provider)), `${where} must define profiles or claude/codex lenses`);
128
128
  for (const [provider, lens] of entries) {
129
129
  validateChoice(lens, `${where}.${provider}`);
130
130
  check(lens.provider === provider && nonempty(lens.model), `${where}.${provider}: specify matching provider and model`);
131
131
  }
132
132
  } else {
133
- const { autocompact, ...legacy } = config;
133
+ const { autocompact, commands, ...legacy } = config;
134
134
  validateChoice(legacy, where);
135
135
  }
136
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anhlp/alp-core",
3
- "version": "0.0.1-beta.6",
3
+ "version": "0.0.1-beta.8",
4
4
  "type": "module",
5
5
  "description": "ALP core module",
6
6
  "files": [
@@ -294,13 +294,29 @@
294
294
  },
295
295
  "types": "./dist/packaged.d.ts",
296
296
  "default": "./src/packaged.js"
297
+ },
298
+ "./skill-validate": {
299
+ "alp-source": {
300
+ "types": "./src/skill-validate.js",
301
+ "default": "./src/skill-validate.js"
302
+ },
303
+ "types": "./dist/skill-validate.d.ts",
304
+ "default": "./src/skill-validate.js"
305
+ },
306
+ "./packs": {
307
+ "alp-source": {
308
+ "types": "./src/packs.js",
309
+ "default": "./src/packs.js"
310
+ },
311
+ "types": "./dist/packs.d.ts",
312
+ "default": "./src/packs.js"
297
313
  }
298
314
  },
299
315
  "engines": {
300
316
  "node": ">=22.12"
301
317
  },
302
318
  "dependencies": {
303
- "@anhlp/alp-protocol": "0.0.1-beta.6"
319
+ "@anhlp/alp-protocol": "0.0.1-beta.8"
304
320
  },
305
321
  "scripts": {
306
322
  "build": "node ../../scripts/build-workspace.mjs core",
package/src/bridges.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { createRequire } from 'node:module';
2
- import { isExecutableName, isPackaged, isSelf, ROLE_ARGS } from './packaged.js';
2
+ import { isExecutableName, stablePath } from './packaged.js';
3
3
 
4
4
  /**
5
5
  * The stdio MCP bridges an agent CLI starts to reach alpd's tools (ACP agents and Antigravity).
6
- * Under Node they run as `node -e <source>`; the ALP executable cannot evaluate `-e`, so it runs
7
- * them as `alp bridge acp|antigravity`, which calls runBridge (t-1e02).
6
+ * They run as `node -e <source>`; `alp bridge acp|antigravity` (which calls runBridge) remains for
7
+ * the MCP entries the single-file executable of 0.0.1-beta.5/6 wrote.
8
8
  */
9
9
 
10
10
  export const ACP_BRIDGE = `
@@ -87,20 +87,19 @@ export function runBridge(kind) {
87
87
  }
88
88
 
89
89
  /**
90
- * The command an agent CLI runs to start a bridge: `node -e <source>` under Node, the executable's
91
- * `bridge <kind>` subcommand when packaged.
90
+ * The command an agent CLI runs to start a bridge: `node -e <source>` under this Node.
92
91
  * @param {'acp' | 'antigravity'} kind
93
92
  * @returns {{ command: string, args: string[] }}
94
93
  */
95
94
  export function bridgeCommand(kind) {
96
95
  if (!Object.hasOwn(BRIDGES, kind)) throw new Error(`Unknown bridge: ${kind}; expected acp or antigravity`);
97
- if (isPackaged()) return { command: process.execPath, args: [...ROLE_ARGS[kind === 'acp' ? 'bridge-acp' : 'bridge-antigravity']] };
98
- return { command: process.execPath, args: ['-e', BRIDGES[kind]] };
96
+ // Agents keep this command in their MCP configuration: name the ALP bundle's Node through app/current.
97
+ return { command: stablePath(process.execPath), args: ['-e', BRIDGES[kind]] };
99
98
  }
100
99
 
101
100
  /**
102
- * Whether an MCP server entry is one of ALP's bridge launchers: the `-e` source, or the ALP
103
- * executable's `bridge <kind>` (only when its command is named alp, so another server is kept).
101
+ * Whether an MCP server entry is one of ALP's bridge launchers: the `-e` source, or `alp bridge <kind>`
102
+ * as the single-file executable of 0.0.1-beta.5/6 wrote it (only when its command is named alp, so another server is kept).
104
103
  * @param {'acp' | 'antigravity'} kind
105
104
  * @param {unknown} args
106
105
  * @param {unknown} [command]
@@ -109,5 +108,5 @@ export function isBridgeArgs(kind, args, command = undefined) {
109
108
  if (!Array.isArray(args)) return false;
110
109
  const marker = kind === 'antigravity' ? '// ALP Antigravity bridge v1' : undefined;
111
110
  if (marker && args.some(arg => typeof arg === 'string' && arg.startsWith(marker))) return true;
112
- return typeof command === 'string' && (isExecutableName(command) || isSelf(command)) && args.length === 2 && args[0] === 'bridge' && args[1] === kind;
111
+ return typeof command === 'string' && isExecutableName(command) && args.length === 2 && args[0] === 'bridge' && args[1] === kind;
113
112
  }
@@ -1,4 +1,4 @@
1
- import { lstat, mkdir, readdir, rename, rm, stat, writeFile } from 'node:fs/promises';
1
+ import { cp, lstat, mkdir, readdir, rename, rm, stat, writeFile } from 'node:fs/promises';
2
2
  import { createHash, randomUUID } from 'node:crypto';
3
3
  import path from 'node:path';
4
4
  import { moveFile } from './atomic.js';
@@ -8,6 +8,26 @@ import { agentSources, builtinText, jsonObject, libraryEntries, optionalText } f
8
8
  import { teamSources, validateTeam } from './teams.js';
9
9
  import { normalizeMcp, validateAgentConfig, validateHook } from './validation.js';
10
10
  import { validateProvider } from './providers.js';
11
+ import { checkFrontmatter, skillReferences, specName, splitSkill } from './skill-validate.js';
12
+
13
+ /**
14
+ * A SKILL.md with its frontmatter `name` set to `name`, so a copied or renamed skill stays valid:
15
+ * the name must equal the skill's directory. A SKILL.md without frontmatter is left as it is.
16
+ */
17
+ export function withSkillName(body, name) {
18
+ const match = /^(\uFEFF?---(\r?\n))([\s\S]*?)(\r?\n---[ \t]*(?:\r?\n|$))/.exec(body);
19
+ if (!match) return body;
20
+ const lines = match[3].split(/\r?\n/);
21
+ const at = lines.findIndex(line => /^name[ \t]*:/.test(line));
22
+ if (at >= 0) lines[at] = `name: ${name}`;
23
+ else lines.unshift(`name: ${name}`);
24
+ return match[1] + lines.join(match[2]) + match[4] + body.slice(match[0].length);
25
+ }
26
+
27
+ /** A skill's new name, when it carries the format's name into its frontmatter: the format's rules. */
28
+ function skillTarget(body, name) {
29
+ if (splitSkill(body).frontmatter !== undefined && !specName(name)) fail('INVALID_NAME', `'${name}' is not a skill name: use 1-64 lowercase letters, digits and single hyphens`);
30
+ }
11
31
 
12
32
  /**
13
33
  * Editing the library (ALPD §43): agents, skills, MCP servers, hooks and teams, in the
@@ -178,12 +198,12 @@ export async function getEntry(kind, name, { root, library, templates, scope } =
178
198
  async function readGiven(library) {
179
199
  const file = path.join(library, 'role-skills.json');
180
200
  const text = await optionalText(file);
181
- if (text === undefined) return { file, roles: {} };
201
+ if (text === undefined) return { file, roles: Object.create(null) };
182
202
  let roles;
183
203
  try { roles = JSON.parse(text); }
184
204
  catch (cause) { throw new AlpError('INVALID_LIBRARY', `${file}: ${cause.message}`, { cause }); }
185
205
  if (!object(roles)) fail('INVALID_LIBRARY', `${file}: expected an object of agent names to skill lists`);
186
- return { file, roles };
206
+ return { file, roles: Object.assign(Object.create(null), roles) };
187
207
  }
188
208
 
189
209
  /** The skills the library gives `agent`, as role-skills.json lists them. */
@@ -209,6 +229,102 @@ export async function setGivenSkills(agent, skills, { library } = {}) {
209
229
  return { skills: unique };
210
230
  }
211
231
 
232
+ /** Where alp_skill_retire keeps retired skills, and the metadata file it writes in each. */
233
+ export const RETIRED_SKILLS = 'retired-skills';
234
+ export const RETIRED_METADATA = 'retired.json';
235
+ // <name>-<ISO time with ':' and '.' replaced by '-'>, as alp_skill_retire names the folder.
236
+ const RETIRED_FOLDER = /^(.+)-(\d{4}-\d\d-\d\dT\d\d-\d\d-\d\d-\d{3}Z)$/;
237
+
238
+ async function retiredMetadata(directory) {
239
+ const text = await optionalText(path.join(directory, RETIRED_METADATA));
240
+ if (text === undefined) return undefined;
241
+ let data;
242
+ try { data = JSON.parse(text); } catch (cause) { throw new AlpError('INVALID_LIBRARY', `${path.join(directory, RETIRED_METADATA)}: ${cause.message}`, { cause }); }
243
+ if (!object(data) || !Array.isArray(data.roles) || !data.roles.every(validName)) fail('INVALID_LIBRARY', `${path.join(directory, RETIRED_METADATA)}: expected { name, roles: [...] }`);
244
+ return data;
245
+ }
246
+
247
+ /**
248
+ * The library's retired skills, newest first. `roles` is what retired.json recorded,
249
+ * or null for a skill retired before ALP wrote it.
250
+ * @returns {Promise<{ name: string, directory: string, retiredAt: string, roles: string[] | null, agent: string | null }[]>}
251
+ */
252
+ export async function listRetiredSkills({ library } = {}) {
253
+ if (!library) fail('INVALID_SCOPE', 'No library: ALP_HOME is not set');
254
+ const root = path.join(library, RETIRED_SKILLS);
255
+ const entries = await readdir(root, { withFileTypes: true }).catch(error => { if (error.code === 'ENOENT') return []; throw error; });
256
+ const rows = [];
257
+ for (const entry of entries) {
258
+ const match = entry.isDirectory() && RETIRED_FOLDER.exec(entry.name);
259
+ if (!match) continue;
260
+ const directory = path.join(root, entry.name);
261
+ // A corrupt retired.json must not hide the other retired skills: list the copy
262
+ // without roles, and restore then asks for --roles or --no-roles.
263
+ let meta, invalid;
264
+ try { meta = await retiredMetadata(directory); } catch (error) { invalid = error.message; }
265
+ const stamp = match[2].replace(/T(\d\d)-(\d\d)-(\d\d)-(\d{3})Z$/, 'T$1:$2:$3.$4Z');
266
+ rows.push({ name: match[1], directory, retiredAt: typeof meta?.retiredAt === 'string' ? meta.retiredAt : stamp, roles: meta ? meta.roles : null, agent: typeof meta?.agent === 'string' ? meta.agent : null, ...(invalid ? { invalid } : {}) });
267
+ }
268
+ return rows.sort((a, b) => b.retiredAt.localeCompare(a.retiredAt) || b.directory.localeCompare(a.directory));
269
+ }
270
+
271
+ /**
272
+ * Moves a retired skill back to <library>/skills/<name> and gives it to roles again in
273
+ * role-skills.json: `roles` when given ([] for none), else the roles retired.json recorded.
274
+ * Takes `from` when given, else the newest retired copy of the name. Refuses when the
275
+ * library already has the skill, or when neither `roles` nor retired.json says the roles.
276
+ * @returns {Promise<{ name: string, restored: string, from: string, roles: string[] }>}
277
+ */
278
+ export async function restoreSkill(name, { library, from, roles } = {}) {
279
+ nameOf(name);
280
+ if (!library) fail('INVALID_SCOPE', 'No library: ALP_HOME is not set');
281
+ if (roles !== undefined && (!Array.isArray(roles) || !roles.every(validName))) fail('INVALID_ENTRY', 'Roles must be a list of agent names');
282
+ let source;
283
+ if (from !== undefined) {
284
+ source = path.resolve(from);
285
+ const info = await lstat(source).catch(() => undefined);
286
+ if (info?.isSymbolicLink()) fail('INVALID_ENTRY', `${source} is a symbolic link; pass the directory itself`);
287
+ if (!info?.isDirectory()) fail('NOT_FOUND', `${source} is not a directory`);
288
+ } else {
289
+ const found = (await listRetiredSkills({ library })).find(row => row.name === name);
290
+ if (!found) fail('NOT_FOUND', `No retired skill '${name}' in ${path.join(library, RETIRED_SKILLS)}`);
291
+ source = found.directory;
292
+ }
293
+ if (!(await exists(path.join(source, 'SKILL.md')))) fail('NOT_FOUND', `${source} has no SKILL.md`);
294
+ const target = path.join(library, 'skills', name);
295
+ if (await lstat(target).then(() => true, () => false)) fail('ALREADY_EXISTS', `The library already has a skill '${name}' (${target}); nothing was restored`);
296
+ const metaFile = path.join(source, RETIRED_METADATA);
297
+ const metaText = await optionalText(metaFile);
298
+ let meta;
299
+ try { meta = await retiredMetadata(source); } catch (error) { if (error?.code !== 'INVALID_LIBRARY' || roles === undefined) throw error; }
300
+ if (meta && meta.name !== undefined && meta.name !== name) fail('INVALID_ENTRY', `${metaFile} is for the skill '${meta.name}', not '${name}'`);
301
+ const given = roles ?? meta?.roles;
302
+ if (!given) fail('ROLES_REQUIRED', `${source} does not record the roles that had '${name}'; pass --roles a,b or --no-roles`);
303
+ const unique = [...new Set(given)];
304
+ const { file: rolesFile, roles: current } = await readGiven(library);
305
+ const before = await optionalText(rolesFile);
306
+ await mkdir(path.dirname(target), { recursive: true });
307
+ await moveFile(source, target);
308
+ try {
309
+ if (metaText !== undefined) await rm(path.join(target, RETIRED_METADATA), { force: true });
310
+ if (unique.length) {
311
+ for (const role of unique) {
312
+ const list = Array.isArray(current[role]) ? current[role] : [];
313
+ if (!list.includes(name)) list.push(name);
314
+ current[role] = list;
315
+ }
316
+ await writeAtomic(rolesFile, JSON.stringify(current, null, 2) + '\n');
317
+ }
318
+ } catch (error) {
319
+ // Put everything back, so a failed restore changes nothing.
320
+ if (before !== undefined) await writeAtomic(rolesFile, before).catch(() => {});
321
+ if (metaText !== undefined) await writeFile(path.join(target, RETIRED_METADATA), metaText).catch(() => {});
322
+ await moveFile(target, source).catch(() => {});
323
+ throw error;
324
+ }
325
+ return { name, restored: target, from: source, roles: unique };
326
+ }
327
+
212
328
  /** Every entry of a kind with its source and users, as `alp <kind>` lists them. */
213
329
  export async function listEntries(kind, { root, library, templates } = {}) {
214
330
  kindOf(kind);
@@ -312,10 +428,24 @@ const exists = target => stat(target).then(() => true, () => false);
312
428
  /**
313
429
  * Creates or replaces an entry in a scope. `revision` is what getEntry returned for
314
430
  * that scope (null to create); a different current revision refuses the save.
315
- * @returns {Promise<{ revision: string | null }>}
431
+ * `strict` (the CLI creating a skill): a new skill must meet the skill format; `warnings` names
432
+ * files its SKILL.md points to that are not there yet. Edits and other callers are unchanged.
433
+ * @param {string} kind
434
+ * @param {string} name
435
+ * @param {any} content
436
+ * @param {{ scope?: any, root?: string, library?: string, templates?: Record<string, string>, revision?: string | null, policy?: string, strict?: boolean }} [options]
437
+ * @returns {Promise<{ revision: string | null, warnings?: string[] }>}
316
438
  */
317
- export async function saveEntry(kind, name, content, { scope, root, library, templates, revision, policy } = {}) {
439
+ export async function saveEntry(kind, name, content, { scope, root, library, templates, revision, policy, strict = false } = {}) {
318
440
  kindOf(kind); nameOf(name);
441
+ // A new skill made by the CLI (strict) meets the skill format; existing skills are saved as before.
442
+ const warnings = [];
443
+ if (strict && kind === 'skills' && revision === null && typeof content?.body === 'string') {
444
+ const errors = checkFrontmatter(splitSkill(content.body).frontmatter, name, { strict: true }).findings.filter(finding => finding.level === 'error');
445
+ if (errors.length) fail('INVALID_ENTRY', `skills '${name}' does not meet the skill format: ${errors.map(finding => finding.message).join('; ')}`);
446
+ const links = skillReferences(splitSkill(content.body).body);
447
+ if (links.length) warnings.push(`SKILL.md points to ${links.join(', ')}: add ${links.length > 1 ? 'those files' : 'that file'} beside it, in the skill's directory`);
448
+ }
319
449
  if (policy === 'project-data') {
320
450
  assertProjectDataContent(kind, content);
321
451
  await projectDataEntry(kind, name, { scope, root, library, templates });
@@ -336,7 +466,7 @@ export async function saveEntry(kind, name, content, { scope, root, library, tem
336
466
  if (empty) { await rm(target, { force: true }); continue; }
337
467
  await writeAtomic(target, type === 'json' ? JSON.stringify(value, null, 2) + '\n' : value.endsWith('\n') ? value : `${value}\n`);
338
468
  }
339
- return { revision: revisionOf(await readLayer(kind, name, directory)) };
469
+ return { revision: revisionOf(await readLayer(kind, name, directory)), ...(warnings.length ? { warnings } : {}) };
340
470
  }
341
471
 
342
472
  /**
@@ -371,8 +501,37 @@ export async function duplicateEntry(kind, from, to, { scope, root, library, tem
371
501
  await projectDataEntry(kind, from, { scope, root, library, templates });
372
502
  await projectDataEntry(kind, to, { scope, root, library, templates });
373
503
  }
374
- const { content } = await getEntry(kind, from, { root, library, templates });
375
- return saveEntry(kind, to, structuredClone(content), { scope, root, library, templates, revision: null, policy });
504
+ const entry = await getEntry(kind, from, { root, library, templates });
505
+ if (kind === 'skills') { skillTarget(entry.content.body, to); entry.content.body = withSkillName(entry.content.body, to); }
506
+ // A skill is its directory: its references, scripts and assets go with SKILL.md, bytes and modes kept.
507
+ const resources = kind === 'skills' && policy !== 'project-data' ? await skillResources(entry.source === 'project' ? path.join(path.resolve(root), '.alp', 'skills', from) : path.join(library, 'skills', from)) : [];
508
+ const saved = await saveEntry(kind, to, structuredClone(entry.content), { scope, root, library, templates, revision: null, policy });
509
+ if (resources.length) {
510
+ const target = path.join(base(scope, { root, library }, kind), kind, to);
511
+ try { for (const [source, relative] of resources) await cp(source, path.join(target, relative), { recursive: true, errorOnExist: true, force: false }); }
512
+ catch (error) {
513
+ // Half a copy is no skill: the new entry (made just above, so nobody else's) goes again.
514
+ await rm(target, { recursive: true, force: true });
515
+ throw error;
516
+ }
517
+ }
518
+ return saved;
519
+ }
520
+
521
+ /** A skill directory's entries besides SKILL.md, as [absolute, relative]; refused when it holds a link. */
522
+ async function skillResources(directory) {
523
+ const found = [];
524
+ const walk = async relative => {
525
+ for (const item of await readdir(path.join(directory, relative), { withFileTypes: true }).catch(error => { if (error.code === 'ENOENT') return []; throw error; })) {
526
+ const rel = path.join(relative, item.name);
527
+ if (item.name === '.git' || item.name === 'node_modules') continue;
528
+ if (item.isSymbolicLink()) fail('UNSAFE_LIBRARY_WRITE', `${path.join(directory, rel)} is a symbolic link; copy the skill by hand`);
529
+ if (item.isDirectory()) await walk(rel);
530
+ else if (item.isFile() && rel !== 'SKILL.md') found.push([path.join(directory, rel), rel]);
531
+ }
532
+ };
533
+ await walk('');
534
+ return found;
376
535
  }
377
536
 
378
537
  /** Renames an entry within a scope; refused while others refer to it by its old name. */
@@ -389,9 +548,12 @@ export async function renameEntry(kind, from, to, { scope, root, library, templa
389
548
  const users = await usersOf(kind, from, { root, library, templates });
390
549
  if (users.length) fail('IN_USE', `${kind} '${from}' is used by ${users.join(', ')}; change them first`);
391
550
  await check(kind, to, content, { scope, root, library, templates });
551
+ if (kind === 'skills') skillTarget(content.body, to);
392
552
  if (ownDirectory(kind)) {
393
553
  if (await exists(path.join(directory, kind, to))) fail('REVISION_CONFLICT', `${path.join(directory, kind, to)} already exists`);
394
554
  await rename(path.join(directory, kind, from), path.join(directory, kind, to));
555
+ // The moved skill's frontmatter names its new directory.
556
+ if (kind === 'skills' && withSkillName(content.body, to) !== content.body) await writeAtomic(path.join(directory, kind, to, 'SKILL.md'), withSkillName(content.body, to));
395
557
  } else {
396
558
  await rename(path.join(directory, kind, `${from}.json`), path.join(directory, kind, `${to}.json`));
397
559
  }