@litfamily/litcodex 1.0.1 → 1.0.3

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 (211) hide show
  1. package/README.md +22 -23
  2. package/dist/cli.d.ts +1 -1
  3. package/dist/cli.js +2 -38
  4. package/dist/install/generated-skill-payload-hashes.d.ts +12 -17
  5. package/dist/install/generated-skill-payload-hashes.js +12 -17
  6. package/dist/install/skill-catalog.d.ts +1 -1
  7. package/dist/install/skill-catalog.js +1 -6
  8. package/dist/install/skill-resource-hashes.d.ts +1 -1
  9. package/dist/install/skill-resource-hashes.js +1 -1
  10. package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
  11. package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
  12. package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
  13. package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
  14. package/marketplace/plugins/litcodex/components/lit-loop/directive.md +1 -1
  15. package/marketplace/plugins/litcodex/components/lit-loop/directives/browser-drive.md +1 -1
  16. package/marketplace/plugins/litcodex/components/lit-loop/directives/deep-interview.md +3 -3
  17. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-comprehend.md +1 -1
  18. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-crucible.md +1 -1
  19. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-handoff.md +2 -2
  20. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-init.md +1 -1
  21. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-plan.md +2 -2
  22. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-recap.md +1 -1
  23. package/marketplace/plugins/litcodex/components/lit-loop/directives/lit-scientific-visualization.md +2 -2
  24. package/marketplace/plugins/litcodex/components/lit-loop/directives/litgoal.md +1 -1
  25. package/marketplace/plugins/litcodex/components/lit-loop/directives/litresearch.md +1 -1
  26. package/marketplace/plugins/litcodex/components/lit-loop/directives/litwork.md +2 -2
  27. package/marketplace/plugins/litcodex/components/lit-loop/directives/review-work.md +1 -1
  28. package/marketplace/plugins/litcodex/components/lit-loop/directives/start-work.md +1 -1
  29. package/marketplace/plugins/litcodex/components/lit-loop/dist/cli.js +3 -20
  30. package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.d.ts +5 -5
  31. package/marketplace/plugins/litcodex/components/lit-loop/dist/codex-hook.js +20 -19
  32. package/marketplace/plugins/litcodex/components/lit-loop/dist/directive.js +1 -1
  33. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.d.ts +2 -1
  34. package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +4 -27
  35. package/marketplace/plugins/litcodex/components/lit-loop/dist/lit-mark.d.ts +2 -0
  36. package/marketplace/plugins/litcodex/components/lit-loop/dist/lit-mark.js +49 -0
  37. package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.d.ts +0 -2
  38. package/marketplace/plugins/litcodex/components/lit-loop/dist/markers.js +0 -2
  39. package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.d.ts +1 -3
  40. package/marketplace/plugins/litcodex/components/lit-loop/dist/modes.js +1 -10
  41. package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
  42. package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
  43. package/marketplace/plugins/litcodex/components/rules/dist/static-injection.js +2 -2
  44. package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
  45. package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
  46. package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
  47. package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
  48. package/marketplace/plugins/litcodex/hooks/hooks.json +19 -19
  49. package/marketplace/plugins/litcodex/skills/autoconference/SKILL.md +1 -1
  50. package/marketplace/plugins/litcodex/skills/autoresearch/SKILL.md +1 -1
  51. package/marketplace/plugins/litcodex/skills/browser-drive/SKILL.md +3 -3
  52. package/marketplace/plugins/litcodex/skills/browser-drive/scripts/capability-probe.mjs +13 -5
  53. package/marketplace/plugins/litcodex/skills/coding-session-audit/SKILL.md +2 -2
  54. package/marketplace/plugins/litcodex/skills/comment-checker/SKILL.md +1 -1
  55. package/marketplace/plugins/litcodex/skills/debugging/SKILL.md +1 -1
  56. package/marketplace/plugins/litcodex/skills/deep-interview/SKILL.md +3 -3
  57. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/SKILL.md +1 -1
  58. package/marketplace/plugins/litcodex/skills/frontend-ui-ux/references/complete-contract.md +1 -1
  59. package/marketplace/plugins/litcodex/skills/lit-burnoff/SKILL.md +1 -1
  60. package/marketplace/plugins/litcodex/skills/lit-burnoff-file/SKILL.md +1 -1
  61. package/marketplace/plugins/litcodex/skills/lit-code/SKILL.md +1 -1
  62. package/marketplace/plugins/litcodex/skills/lit-commit/SKILL.md +1 -1
  63. package/marketplace/plugins/litcodex/skills/lit-comprehend/SKILL.md +1 -1
  64. package/marketplace/plugins/litcodex/skills/lit-crucible/SKILL.md +1 -1
  65. package/marketplace/plugins/litcodex/skills/lit-fetch/SKILL.md +1 -1
  66. package/marketplace/plugins/litcodex/skills/lit-handoff/SKILL.md +4 -4
  67. package/marketplace/plugins/litcodex/skills/lit-init/SKILL.md +1 -1
  68. package/marketplace/plugins/litcodex/skills/lit-korean/SKILL.md +1 -1
  69. package/marketplace/plugins/litcodex/skills/lit-loop/SKILL.md +1 -1
  70. package/marketplace/plugins/litcodex/skills/lit-plan/SKILL.md +1 -1
  71. package/marketplace/plugins/litcodex/skills/lit-recap/SKILL.md +1 -1
  72. package/marketplace/plugins/litcodex/skills/lit-scientific-visualization/SKILL.md +4 -4
  73. package/marketplace/plugins/litcodex/skills/lit-team/SKILL.md +1 -1
  74. package/marketplace/plugins/litcodex/skills/litcodex-contribute-bug-fix/SKILL.md +1 -1
  75. package/marketplace/plugins/litcodex/skills/litcodex-doctor/SKILL.md +1 -1
  76. package/marketplace/plugins/litcodex/skills/litcodex-report-bug/SKILL.md +1 -1
  77. package/marketplace/plugins/litcodex/skills/litgoal/SKILL.md +1 -1
  78. package/marketplace/plugins/litcodex/skills/litresearch/SKILL.md +2 -2
  79. package/marketplace/plugins/litcodex/skills/litwork/SKILL.md +1 -1
  80. package/marketplace/plugins/litcodex/skills/lsp/SKILL.md +1 -1
  81. package/marketplace/plugins/litcodex/skills/lsp-setup/SKILL.md +1 -1
  82. package/marketplace/plugins/litcodex/skills/refactor/SKILL.md +1 -1
  83. package/marketplace/plugins/litcodex/skills/review-work/SKILL.md +1 -1
  84. package/marketplace/plugins/litcodex/skills/rules/SKILL.md +1 -1
  85. package/marketplace/plugins/litcodex/skills/start-work/SKILL.md +1 -1
  86. package/marketplace/plugins/litcodex/skills/structural-search/SKILL.md +1 -1
  87. package/marketplace/plugins/litcodex/skills/visual-qa/SKILL.md +1 -1
  88. package/marketplace/plugins/litcodex/skills/visual-qa/references/complete-contract.md +1 -1
  89. package/marketplace/plugins/litcodex/skills/wikify/SKILL.md +1 -1
  90. package/node_modules/@litcodex/lit-loop/README.md +1 -7
  91. package/node_modules/@litcodex/lit-loop/directive.md +1 -1
  92. package/node_modules/@litcodex/lit-loop/directives/browser-drive.md +1 -1
  93. package/node_modules/@litcodex/lit-loop/directives/deep-interview.md +3 -3
  94. package/node_modules/@litcodex/lit-loop/directives/lit-comprehend.md +1 -1
  95. package/node_modules/@litcodex/lit-loop/directives/lit-crucible.md +1 -1
  96. package/node_modules/@litcodex/lit-loop/directives/lit-handoff.md +2 -2
  97. package/node_modules/@litcodex/lit-loop/directives/lit-init.md +1 -1
  98. package/node_modules/@litcodex/lit-loop/directives/lit-plan.md +2 -2
  99. package/node_modules/@litcodex/lit-loop/directives/lit-recap.md +1 -1
  100. package/node_modules/@litcodex/lit-loop/directives/lit-scientific-visualization.md +2 -2
  101. package/node_modules/@litcodex/lit-loop/directives/litgoal.md +1 -1
  102. package/node_modules/@litcodex/lit-loop/directives/litresearch.md +1 -1
  103. package/node_modules/@litcodex/lit-loop/directives/litwork.md +2 -2
  104. package/node_modules/@litcodex/lit-loop/directives/review-work.md +1 -1
  105. package/node_modules/@litcodex/lit-loop/directives/start-work.md +1 -1
  106. package/node_modules/@litcodex/lit-loop/dist/cli.js +3 -20
  107. package/node_modules/@litcodex/lit-loop/dist/codex-hook.d.ts +5 -5
  108. package/node_modules/@litcodex/lit-loop/dist/codex-hook.js +20 -19
  109. package/node_modules/@litcodex/lit-loop/dist/directive.js +1 -1
  110. package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +2 -1
  111. package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +4 -27
  112. package/node_modules/@litcodex/lit-loop/dist/lit-mark.d.ts +2 -0
  113. package/node_modules/@litcodex/lit-loop/dist/lit-mark.js +49 -0
  114. package/node_modules/@litcodex/lit-loop/dist/markers.d.ts +0 -2
  115. package/node_modules/@litcodex/lit-loop/dist/markers.js +0 -2
  116. package/node_modules/@litcodex/lit-loop/dist/modes.d.ts +1 -3
  117. package/node_modules/@litcodex/lit-loop/dist/modes.js +1 -10
  118. package/node_modules/@litcodex/lit-loop/package.json +1 -1
  119. package/node_modules/@litcodex/lit-loop/skills/browser-drive/SKILL.md +3 -3
  120. package/node_modules/@litcodex/lit-loop/skills/browser-drive/scripts/capability-probe.mjs +13 -5
  121. package/node_modules/@litcodex/lit-loop/skills/deep-interview/SKILL.md +3 -3
  122. package/node_modules/@litcodex/lit-loop/skills/lit-burnoff/SKILL.md +1 -1
  123. package/node_modules/@litcodex/lit-loop/skills/lit-burnoff-file/SKILL.md +1 -1
  124. package/node_modules/@litcodex/lit-loop/skills/lit-code/SKILL.md +1 -1
  125. package/node_modules/@litcodex/lit-loop/skills/lit-commit/SKILL.md +1 -1
  126. package/node_modules/@litcodex/lit-loop/skills/lit-comprehend/SKILL.md +1 -1
  127. package/node_modules/@litcodex/lit-loop/skills/lit-crucible/SKILL.md +1 -1
  128. package/node_modules/@litcodex/lit-loop/skills/lit-fetch/SKILL.md +1 -1
  129. package/node_modules/@litcodex/lit-loop/skills/lit-handoff/SKILL.md +4 -4
  130. package/node_modules/@litcodex/lit-loop/skills/lit-init/SKILL.md +1 -1
  131. package/node_modules/@litcodex/lit-loop/skills/lit-korean/SKILL.md +1 -1
  132. package/node_modules/@litcodex/lit-loop/skills/lit-loop/SKILL.md +1 -1
  133. package/node_modules/@litcodex/lit-loop/skills/lit-plan/SKILL.md +1 -1
  134. package/node_modules/@litcodex/lit-loop/skills/lit-recap/SKILL.md +1 -1
  135. package/node_modules/@litcodex/lit-loop/skills/lit-scientific-visualization/SKILL.md +4 -4
  136. package/node_modules/@litcodex/lit-loop/skills/lit-team/SKILL.md +1 -1
  137. package/node_modules/@litcodex/lit-loop/skills/litgoal/SKILL.md +1 -1
  138. package/node_modules/@litcodex/lit-loop/skills/litresearch/SKILL.md +2 -2
  139. package/node_modules/@litcodex/lit-loop/skills/litwork/SKILL.md +1 -1
  140. package/node_modules/@litcodex/lit-loop/skills/review-work/SKILL.md +1 -1
  141. package/node_modules/@litcodex/lit-loop/skills/start-work/SKILL.md +1 -1
  142. package/package.json +2 -2
  143. package/readme-assets/badge-version.svg +1 -1
  144. package/readme-assets/cover-motion.webp +0 -0
  145. package/marketplace/plugins/litcodex/components/lit-loop/directives/skill-observer.md +0 -105
  146. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/apply.d.ts +0 -16
  147. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/apply.js +0 -227
  148. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/config.d.ts +0 -13
  149. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/config.js +0 -12
  150. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/curator.d.ts +0 -14
  151. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/curator.js +0 -112
  152. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/hook.d.ts +0 -19
  153. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/hook.js +0 -435
  154. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/ownership.d.ts +0 -6
  155. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/ownership.js +0 -145
  156. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/paths.d.ts +0 -18
  157. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/paths.js +0 -43
  158. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/review.d.ts +0 -28
  159. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/review.js +0 -702
  160. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/store.d.ts +0 -32
  161. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/store.js +0 -667
  162. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/transaction.d.ts +0 -26
  163. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/transaction.js +0 -524
  164. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/types.d.ts +0 -81
  165. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/types.js +0 -246
  166. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/usage.d.ts +0 -6
  167. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop/usage.js +0 -119
  168. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop-cli.d.ts +0 -8
  169. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-loop-cli.js +0 -111
  170. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer-cli.d.ts +0 -3
  171. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer-cli.js +0 -116
  172. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer-route.d.ts +0 -6
  173. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer-route.js +0 -12
  174. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer.d.ts +0 -18
  175. package/marketplace/plugins/litcodex/components/lit-loop/dist/skill-observer.js +0 -946
  176. package/marketplace/plugins/litcodex/skills/skill-observer/SKILL.md +0 -215
  177. package/marketplace/plugins/litcodex/skills/skill-observer/agents/openai.yaml +0 -6
  178. package/marketplace/plugins/litcodex/skills/skill-observer/references/review-contract.md +0 -77
  179. package/node_modules/@litcodex/lit-loop/directives/skill-observer.md +0 -105
  180. package/node_modules/@litcodex/lit-loop/dist/skill-loop/apply.d.ts +0 -16
  181. package/node_modules/@litcodex/lit-loop/dist/skill-loop/apply.js +0 -227
  182. package/node_modules/@litcodex/lit-loop/dist/skill-loop/config.d.ts +0 -13
  183. package/node_modules/@litcodex/lit-loop/dist/skill-loop/config.js +0 -12
  184. package/node_modules/@litcodex/lit-loop/dist/skill-loop/curator.d.ts +0 -14
  185. package/node_modules/@litcodex/lit-loop/dist/skill-loop/curator.js +0 -112
  186. package/node_modules/@litcodex/lit-loop/dist/skill-loop/hook.d.ts +0 -19
  187. package/node_modules/@litcodex/lit-loop/dist/skill-loop/hook.js +0 -435
  188. package/node_modules/@litcodex/lit-loop/dist/skill-loop/ownership.d.ts +0 -6
  189. package/node_modules/@litcodex/lit-loop/dist/skill-loop/ownership.js +0 -145
  190. package/node_modules/@litcodex/lit-loop/dist/skill-loop/paths.d.ts +0 -18
  191. package/node_modules/@litcodex/lit-loop/dist/skill-loop/paths.js +0 -43
  192. package/node_modules/@litcodex/lit-loop/dist/skill-loop/review.d.ts +0 -28
  193. package/node_modules/@litcodex/lit-loop/dist/skill-loop/review.js +0 -702
  194. package/node_modules/@litcodex/lit-loop/dist/skill-loop/store.d.ts +0 -32
  195. package/node_modules/@litcodex/lit-loop/dist/skill-loop/store.js +0 -667
  196. package/node_modules/@litcodex/lit-loop/dist/skill-loop/transaction.d.ts +0 -26
  197. package/node_modules/@litcodex/lit-loop/dist/skill-loop/transaction.js +0 -524
  198. package/node_modules/@litcodex/lit-loop/dist/skill-loop/types.d.ts +0 -81
  199. package/node_modules/@litcodex/lit-loop/dist/skill-loop/types.js +0 -246
  200. package/node_modules/@litcodex/lit-loop/dist/skill-loop/usage.d.ts +0 -6
  201. package/node_modules/@litcodex/lit-loop/dist/skill-loop/usage.js +0 -119
  202. package/node_modules/@litcodex/lit-loop/dist/skill-loop-cli.d.ts +0 -8
  203. package/node_modules/@litcodex/lit-loop/dist/skill-loop-cli.js +0 -111
  204. package/node_modules/@litcodex/lit-loop/dist/skill-observer-cli.d.ts +0 -3
  205. package/node_modules/@litcodex/lit-loop/dist/skill-observer-cli.js +0 -116
  206. package/node_modules/@litcodex/lit-loop/dist/skill-observer-route.d.ts +0 -6
  207. package/node_modules/@litcodex/lit-loop/dist/skill-observer-route.js +0 -12
  208. package/node_modules/@litcodex/lit-loop/dist/skill-observer.d.ts +0 -18
  209. package/node_modules/@litcodex/lit-loop/dist/skill-observer.js +0 -946
  210. package/node_modules/@litcodex/lit-loop/skills/skill-observer/SKILL.md +0 -215
  211. package/node_modules/@litcodex/lit-loop/skills/skill-observer/references/review-contract.md +0 -77
@@ -1,145 +0,0 @@
1
- import { TextDecoder } from "node:util";
2
- import { readBlob } from "./store.js";
3
- import { SkillLoopError } from "./types.js";
4
- const utf8 = new TextDecoder("utf-8", { fatal: true });
5
- const MARKER_KEY = "litcodexAgentGenerated";
6
- const metadataEntry = /^metadata\s*:\s*$/u;
7
- const markerEntry = new RegExp(`^${MARKER_KEY}:\\s*(true|false)\\s*$`, "u");
8
- const exactMetadataKeys = new Set(["metadata"]);
9
- const exactMarkerKeys = new Set(["litcodexAgentGenerated"]);
10
- function mappingKey(line) {
11
- const indent = /^ */u.exec(line)?.[0].length ?? 0;
12
- const body = line.slice(indent);
13
- const colon = body.indexOf(":");
14
- if (colon < 0)
15
- return null;
16
- return { indent, key: body.slice(0, colon).trim() };
17
- }
18
- function hasUnsafeSemanticAlias(line, expectedIndent) {
19
- const parsed = mappingKey(line);
20
- if (parsed === null || (expectedIndent !== undefined && parsed.indent !== expectedIndent))
21
- return false;
22
- if (parsed.key.includes("\\"))
23
- return true;
24
- const normalized = parsed.key.normalize("NFKC");
25
- if (parsed.indent === 0 && normalized.toLocaleLowerCase("en-US").includes("metadata")) {
26
- return !exactMetadataKeys.has(parsed.key);
27
- }
28
- if (normalized.toLocaleLowerCase("en-US").includes("litcodexagentgenerated")) {
29
- return !exactMarkerKeys.has(parsed.key);
30
- }
31
- return false;
32
- }
33
- function hasUnsupportedYamlSyntax(line) {
34
- const body = line.trim();
35
- if (body === "" || body.startsWith("#"))
36
- return false;
37
- if (/^[?%{[]/u.test(body))
38
- return true;
39
- const parsed = mappingKey(line);
40
- if (parsed === null)
41
- return false;
42
- if (parsed.key === "<<" || /^[&*!{[]/u.test(parsed.key))
43
- return true;
44
- const colon = line.indexOf(":");
45
- const value = colon < 0 ? "" : line.slice(colon + 1).trimStart();
46
- return (/^(?:[!{[]|\*[^\s]+)/u.test(value) ||
47
- /(?:^|\s)&[A-Za-z0-9_-]+(?:\s|$)/u.test(value) ||
48
- /(?:^|\s)\*[A-Za-z0-9_-]+(?:\s|$)/u.test(value));
49
- }
50
- export function markerPresent(content) {
51
- if (!content.startsWith("---\n"))
52
- return false;
53
- const lines = content.split("\n");
54
- const end = lines.indexOf("---", 1);
55
- if (end < 0)
56
- return false;
57
- const frontmatter = lines.slice(1, end);
58
- if (frontmatter.some((line) => hasUnsupportedYamlSyntax(line) || hasUnsafeSemanticAlias(line)))
59
- return false;
60
- const metadataEntries = frontmatter
61
- .map((line, index) => ({ line, index }))
62
- .filter(({ line }) => /^metadata\s*:/u.test(line));
63
- if (metadataEntries.length !== 1 || !metadataEntry.test(metadataEntries[0]?.line ?? ""))
64
- return false;
65
- const metadata = metadataEntries[0]?.index;
66
- if (metadata === undefined)
67
- return false;
68
- let directIndent;
69
- let markerCount = 0;
70
- let markerIsTrue = false;
71
- for (let index = metadata + 1; index < frontmatter.length; index += 1) {
72
- const line = frontmatter[index] ?? "";
73
- if (line.trim() === "" || line.trimStart().startsWith("#"))
74
- continue;
75
- const indent = /^ */u.exec(line)?.[0].length ?? 0;
76
- if (indent === 0)
77
- break;
78
- directIndent ??= indent;
79
- if (indent === directIndent) {
80
- if (hasUnsafeSemanticAlias(line, directIndent))
81
- return false;
82
- const direct = line.slice(indent);
83
- if (mappingKey(line)?.key !== MARKER_KEY)
84
- continue;
85
- markerCount += 1;
86
- const marker = markerEntry.exec(direct);
87
- if (marker === null || marker[1] !== "true")
88
- return false;
89
- markerIsTrue = true;
90
- }
91
- }
92
- return markerCount === 1 && markerIsTrue;
93
- }
94
- export function stampMarker(content, skillId) {
95
- if (markerPresent(content))
96
- return content;
97
- if (!content.startsWith("---\n")) {
98
- return `---\nname: ${skillId}\ndescription: Agent-owned reusable skill.\nmetadata:\n litcodexAgentGenerated: true\n---\n\n${content}`;
99
- }
100
- const lines = content.split("\n");
101
- const end = lines.indexOf("---", 1);
102
- if (end < 0)
103
- throw new SkillLoopError("TARGET_MARKER_INVALID", "SKILL.md frontmatter is incomplete");
104
- const frontmatter = lines.slice(1, end);
105
- if (frontmatter.some((line) => hasUnsupportedYamlSyntax(line) || hasUnsafeSemanticAlias(line))) {
106
- throw new SkillLoopError("TARGET_MARKER_INVALID", "SKILL.md metadata contains a noncanonical YAML key");
107
- }
108
- const metadataEntries = frontmatter
109
- .map((line, index) => ({ line, index }))
110
- .filter(({ line }) => /^metadata\s*:/u.test(line));
111
- if (metadataEntries.length > 1 ||
112
- (metadataEntries[0] !== undefined && !metadataEntry.test(metadataEntries[0].line))) {
113
- throw new SkillLoopError("TARGET_MARKER_INVALID", "SKILL.md metadata must be a direct YAML mapping");
114
- }
115
- const metadata = metadataEntries[0]?.index;
116
- if (metadata === undefined)
117
- frontmatter.push("metadata:", " litcodexAgentGenerated: true");
118
- else {
119
- let indent = " ";
120
- for (let index = metadata + 1; index < frontmatter.length; index += 1) {
121
- const line = frontmatter[index] ?? "";
122
- if (line.trim() === "" || line.trimStart().startsWith("#"))
123
- continue;
124
- const current = /^ */u.exec(line)?.[0] ?? "";
125
- if (current.length === 0)
126
- break;
127
- indent = current;
128
- break;
129
- }
130
- frontmatter.splice(metadata + 1, 0, `${indent}litcodexAgentGenerated: true`);
131
- }
132
- return ["---", ...frontmatter, "---", ...lines.slice(end + 1)].join("\n");
133
- }
134
- export function decodeSkillItem(paths, item) {
135
- try {
136
- return utf8.decode(readBlob(paths, item));
137
- }
138
- catch {
139
- throw new SkillLoopError("TARGET_TEXT_INVALID", "the target skill file is not valid UTF-8");
140
- }
141
- }
142
- export function snapshotIsAgentOwned(paths, snapshot) {
143
- const skillFile = snapshot.find((item) => item.file === "SKILL.md");
144
- return skillFile !== undefined && markerPresent(decodeSkillItem(paths, skillFile));
145
- }
@@ -1,18 +0,0 @@
1
- export interface SkillLoopPaths {
2
- readonly workspaceRoot: string;
3
- readonly stateRoot: string;
4
- readonly proposalsDir: string;
5
- readonly ledgerPath: string;
6
- readonly blobsDir: string;
7
- readonly lockPath: string;
8
- readonly agentMutationLockPath: string;
9
- readonly transactionPath: string;
10
- readonly agentRoot: string;
11
- readonly usagePath: string;
12
- readonly archiveRoot: string;
13
- readonly curatorBackupsRoot: string;
14
- }
15
- export declare function agentSkillRoot(env?: NodeJS.ProcessEnv): string;
16
- export declare function skillLoopPaths(workspaceRoot: string, env?: NodeJS.ProcessEnv): SkillLoopPaths;
17
- export declare function isWithin(root: string, candidate: string): boolean;
18
- export declare function targetSkillDir(paths: SkillLoopPaths, skillId: string): string;
@@ -1,43 +0,0 @@
1
- import { isAbsolute, join, resolve, sep } from "node:path";
2
- import { SkillLoopError } from "./types.js";
3
- export function agentSkillRoot(env = process.env) {
4
- const home = env["HOME"]?.trim();
5
- if (!home || !isAbsolute(home)) {
6
- throw new SkillLoopError("HOME_INVALID", "the skill-loop HOME is unavailable");
7
- }
8
- return resolve(home, ".agents", "skills");
9
- }
10
- export function skillLoopPaths(workspaceRoot, env = process.env) {
11
- if (!isAbsolute(workspaceRoot)) {
12
- throw new SkillLoopError("WORKSPACE_ROOT_INVALID", "the skill-loop workspace root must be absolute");
13
- }
14
- const root = resolve(workspaceRoot);
15
- const stateRoot = join(root, ".litcodex");
16
- const agentRoot = agentSkillRoot(env);
17
- return {
18
- workspaceRoot: root,
19
- stateRoot,
20
- proposalsDir: join(stateRoot, "skill-proposals"),
21
- ledgerPath: join(stateRoot, "skill-ledger.jsonl"),
22
- blobsDir: join(stateRoot, "skill-ledger-blobs"),
23
- lockPath: join(stateRoot, "skill-loop.lock"),
24
- agentMutationLockPath: join(resolve(agentRoot, ".."), ".litcodex-skill-loop-mutation.lock"),
25
- transactionPath: join(stateRoot, "skill-transaction.json"),
26
- agentRoot,
27
- usagePath: join(agentRoot, ".litcodex-usage.json"),
28
- archiveRoot: join(agentRoot, ".litcodex-archive"),
29
- curatorBackupsRoot: join(agentRoot, ".litcodex-curator-backups"),
30
- };
31
- }
32
- export function isWithin(root, candidate) {
33
- const normalizedRoot = resolve(root);
34
- const normalizedCandidate = resolve(candidate);
35
- return normalizedCandidate === normalizedRoot || normalizedCandidate.startsWith(`${normalizedRoot}${sep}`);
36
- }
37
- export function targetSkillDir(paths, skillId) {
38
- const target = resolve(paths.agentRoot, skillId);
39
- if (!isWithin(paths.agentRoot, target) || target === paths.agentRoot) {
40
- throw new SkillLoopError("TARGET_NOT_AGENT_OWNED", "the proposal target is not agent-owned");
41
- }
42
- return target;
43
- }
@@ -1,28 +0,0 @@
1
- export interface ReviewOptions {
2
- readonly env?: NodeJS.ProcessEnv | undefined;
3
- readonly now?: () => Date;
4
- readonly spawn?: ReviewSpawn;
5
- /** Test-only race seam; production callers leave this unset. */
6
- readonly beforeRead?: ((path: string) => void) | undefined;
7
- }
8
- export interface ReviewSpawnOptions {
9
- readonly cwd: string;
10
- readonly env: NodeJS.ProcessEnv;
11
- readonly encoding: "utf8";
12
- readonly stdio: ["ignore", "pipe", "pipe"];
13
- readonly maxBuffer: number;
14
- readonly timeout: number;
15
- }
16
- export interface ReviewSpawnResult {
17
- readonly status: number | null;
18
- readonly stdout: string;
19
- readonly stderr: string;
20
- readonly error?: Error;
21
- }
22
- export type ReviewSpawn = (command: string, args: readonly string[], options: ReviewSpawnOptions) => ReviewSpawnResult;
23
- export declare function buildReviewPacket(workspaceRoot: string, options?: Pick<ReviewOptions, "env" | "beforeRead">): string;
24
- export declare function runCodexReview(workspaceRoot: string, options?: ReviewOptions): {
25
- readonly ok: true;
26
- readonly proposalIds: readonly string[];
27
- readonly noOp: boolean;
28
- };