@rulemetric/cli 0.9.0 → 0.10.0

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 (194) hide show
  1. package/dist/base-command.js +1 -1
  2. package/dist/{chunk-R6JXE273.js → chunk-3A7RPMNN.js} +1 -1
  3. package/dist/{chunk-X3VL5H24.js → chunk-3IH22LYI.js} +1 -1
  4. package/dist/{chunk-CNOD6HWU.js → chunk-3VYV6ZYB.js} +1 -1
  5. package/dist/{chunk-3DGL2ZY3.js → chunk-4STKWINN.js} +1 -1
  6. package/dist/{chunk-CBUTNIJA.js → chunk-4T2FJLDA.js} +1 -1
  7. package/dist/{chunk-3AZV7ZPJ.js → chunk-553EGRRW.js} +1 -1
  8. package/dist/{chunk-EQHKCGSX.js → chunk-6SUN4NOY.js} +1 -1
  9. package/dist/{chunk-HYDGERWD.js → chunk-7BYMIHIB.js} +1 -1
  10. package/dist/{chunk-LLIHRQPH.js → chunk-7L4P7FCK.js} +1 -1
  11. package/dist/{chunk-7FZB65VH.js → chunk-7LXG3DDL.js} +1 -1
  12. package/dist/{chunk-KWNIKGAE.js → chunk-BN54LTXD.js} +1 -1
  13. package/dist/{chunk-X3RTCN6S.js → chunk-DAD4YBYC.js} +1 -1
  14. package/dist/{chunk-MO57LGGK.js → chunk-EOJ3LAP6.js} +1 -1
  15. package/dist/{chunk-QTZPLAYC.js → chunk-ERNDMEYG.js} +1 -1
  16. package/dist/{chunk-YFQ4FOAS.js → chunk-F5WE6JXK.js} +1 -1
  17. package/dist/{chunk-5EDINFHF.js → chunk-FH55JFUY.js} +1 -1
  18. package/dist/chunk-FK73GD2X.js +2 -0
  19. package/dist/{chunk-CDDICCY2.js → chunk-FORJT5H6.js} +1 -1
  20. package/dist/{chunk-RZTVYUX4.js → chunk-H6MN2AAF.js} +1 -1
  21. package/dist/{chunk-IVDTORX5.js → chunk-HKC224ZO.js} +1 -1
  22. package/dist/{chunk-2B7Y6JNB.js → chunk-MIOMKROL.js} +1 -1
  23. package/dist/{chunk-B3BHB26P.js → chunk-MODFTCZY.js} +1 -1
  24. package/dist/{chunk-PKLXZYBY.js → chunk-N7ML6X6Y.js} +1 -1
  25. package/dist/{chunk-SYTQDPPN.js → chunk-NDZVH5QW.js} +1 -1
  26. package/dist/{chunk-FWTYR36W.js → chunk-NTJKAIHS.js} +1 -1
  27. package/dist/{chunk-QAV4HW7D.js → chunk-OFC7HIBX.js} +1 -1
  28. package/dist/{chunk-K4B24SMJ.js → chunk-OFSUKSZ2.js} +1 -1
  29. package/dist/{chunk-UUZB4IKU.js → chunk-OI7MOALX.js} +1 -1
  30. package/dist/{chunk-NTKO4H2K.js → chunk-OPUI7CM2.js} +1 -1
  31. package/dist/chunk-PZNWH4VQ.js +7 -0
  32. package/dist/{chunk-6M74HH6Y.js → chunk-RSMLOYVJ.js} +1 -1
  33. package/dist/chunk-S7YDBO42.js +1 -0
  34. package/dist/{chunk-KHWG7ZG4.js → chunk-SE5SRPIB.js} +1 -1
  35. package/dist/{chunk-JPUH3V67.js → chunk-TCR7TSAJ.js} +1 -1
  36. package/dist/{chunk-DZ3FBQYD.js → chunk-UC377K7P.js} +1 -1
  37. package/dist/{chunk-GF76D2DU.js → chunk-UY5QYCTK.js} +1 -1
  38. package/dist/{chunk-XRTZU7IZ.js → chunk-V5MJ4ICC.js} +1 -1
  39. package/dist/chunk-VKVWEG5J.js +11 -0
  40. package/dist/chunk-VXM4PEED.js +46 -0
  41. package/dist/{chunk-C2275MFP.js → chunk-W2SG3KND.js} +1 -1
  42. package/dist/{chunk-E2NVNLFD.js → chunk-W65UX4FC.js} +1 -1
  43. package/dist/{chunk-SANYAPBK.js → chunk-WEBB76XA.js} +1 -1
  44. package/dist/{chunk-VA5DPQB4.js → chunk-WVJEBQYU.js} +1 -1
  45. package/dist/{chunk-S62MK372.js → chunk-X4N4MT2I.js} +1 -1
  46. package/dist/{chunk-BPP7AEFW.js → chunk-XILSJP4P.js} +1 -1
  47. package/dist/{chunk-VFYT3SC5.js → chunk-YVM2CHNV.js} +1 -1
  48. package/dist/{chunk-PQN2GAG4.js → chunk-YY53MMH7.js} +1 -1
  49. package/dist/{chunk-WKDXH7NO.js → chunk-ZJOYLBRU.js} +1 -1
  50. package/dist/commands/antigravity/backfill.js +1 -1
  51. package/dist/commands/auth/create-key.js +1 -1
  52. package/dist/commands/auth/login.js +1 -1
  53. package/dist/commands/auth/logout.js +1 -1
  54. package/dist/commands/auth/revoke-key.js +1 -1
  55. package/dist/commands/auth/signup.js +1 -1
  56. package/dist/commands/auth/status.js +1 -1
  57. package/dist/commands/capture/scope.js +1 -1
  58. package/dist/commands/catalog/index.js +1 -1
  59. package/dist/commands/catalog/recommend.js +1 -1
  60. package/dist/commands/convert.js +1 -1
  61. package/dist/commands/converters.js +1 -1
  62. package/dist/commands/crons/list.js +1 -1
  63. package/dist/commands/crons/run.js +1 -1
  64. package/dist/commands/dashboard.js +1 -1
  65. package/dist/commands/diagnostics.js +1 -1
  66. package/dist/commands/eval-targets/create.js +1 -1
  67. package/dist/commands/eval-targets/list.js +1 -1
  68. package/dist/commands/evals/agent.js +1 -1
  69. package/dist/commands/evals/auto-run.js +1 -1
  70. package/dist/commands/evals/benchmark.js +1 -1
  71. package/dist/commands/evals/compare.js +1 -1
  72. package/dist/commands/evals/create.js +1 -1
  73. package/dist/commands/evals/optimize-description.js +1 -1
  74. package/dist/commands/evals/optimize.js +1 -1
  75. package/dist/commands/evals/refine-cases.js +1 -1
  76. package/dist/commands/evals/run.js +1 -1
  77. package/dist/commands/evals/validate-judge.js +1 -1
  78. package/dist/commands/experiments/list.js +1 -1
  79. package/dist/commands/gateway/ensure.js +1 -1
  80. package/dist/commands/hooks/install.js +1 -1
  81. package/dist/commands/hooks/run.js +1 -1
  82. package/dist/commands/hooks/uninstall.js +1 -1
  83. package/dist/commands/import.js +1 -1
  84. package/dist/commands/instructions/create.js +1 -1
  85. package/dist/commands/instructions/dedupe.js +1 -0
  86. package/dist/commands/instructions/delete.js +1 -1
  87. package/dist/commands/instructions/fork.js +1 -1
  88. package/dist/commands/instructions/get.js +1 -1
  89. package/dist/commands/instructions/list.js +1 -1
  90. package/dist/commands/instructions/promote.js +1 -1
  91. package/dist/commands/instructions/pull.js +1 -1
  92. package/dist/commands/instructions/restore.js +1 -1
  93. package/dist/commands/instructions/retract.js +1 -1
  94. package/dist/commands/instructions/upstream.js +1 -1
  95. package/dist/commands/instructions/versions.js +1 -1
  96. package/dist/commands/launcher.js +1 -1
  97. package/dist/commands/local/down.js +1 -1
  98. package/dist/commands/local/up.js +1 -1
  99. package/dist/commands/org/current.js +1 -1
  100. package/dist/commands/org/list.js +1 -1
  101. package/dist/commands/org/switch.js +1 -1
  102. package/dist/commands/packs/add-instruction.js +1 -1
  103. package/dist/commands/packs/apply.js +1 -1
  104. package/dist/commands/packs/create.js +1 -1
  105. package/dist/commands/packs/fork.js +1 -1
  106. package/dist/commands/packs/get.js +1 -1
  107. package/dist/commands/packs/list.js +1 -1
  108. package/dist/commands/packs/remove-instruction.js +1 -1
  109. package/dist/commands/proxy/env.js +1 -1
  110. package/dist/commands/proxy/logs.js +1 -1
  111. package/dist/commands/proxy/restart.js +1 -1
  112. package/dist/commands/proxy/setup.js +1 -1
  113. package/dist/commands/proxy/start.js +1 -1
  114. package/dist/commands/proxy/status.js +1 -1
  115. package/dist/commands/proxy/stop.js +1 -1
  116. package/dist/commands/research/backfill.js +1 -1
  117. package/dist/commands/research/tail-transcript.js +1 -1
  118. package/dist/commands/service/install.js +1 -1
  119. package/dist/commands/service/status.js +1 -1
  120. package/dist/commands/service/uninstall.js +1 -1
  121. package/dist/commands/sessions/analyze.js +1 -1
  122. package/dist/commands/sessions/delete.js +1 -1
  123. package/dist/commands/sessions/end.js +1 -1
  124. package/dist/commands/sessions/import.js +1 -1
  125. package/dist/commands/sessions/list.js +1 -1
  126. package/dist/commands/sessions/start.js +1 -1
  127. package/dist/commands/setup.js +1 -1
  128. package/dist/commands/skills/export-approved.js +1 -1
  129. package/dist/commands/skills/install.js +1 -1
  130. package/dist/commands/skills/list.js +1 -1
  131. package/dist/commands/skills/publish.js +1 -1
  132. package/dist/commands/skills/search.js +1 -1
  133. package/dist/commands/skills/update.js +1 -1
  134. package/dist/commands/suggestions/accept.js +1 -1
  135. package/dist/commands/suggestions/auto.js +1 -1
  136. package/dist/commands/suggestions/dismiss.js +1 -1
  137. package/dist/commands/suggestions/list.js +1 -1
  138. package/dist/commands/suggestions/refresh.js +1 -1
  139. package/dist/commands/suggestions/undo.js +1 -1
  140. package/dist/dashboard/Dashboard.js +1 -1
  141. package/dist/dashboard/data.js +1 -1
  142. package/dist/dashboard/launcher/LauncherOverlay.js +1 -1
  143. package/dist/dashboard/launcher/api.js +1 -1
  144. package/dist/dashboard/launcher/useLaunchJobs.js +1 -1
  145. package/dist/lib/active-org-refresh.js +1 -1
  146. package/dist/lib/agent-loop.js +1 -1
  147. package/dist/lib/antigravity-transcript.js +1 -1
  148. package/dist/lib/api-client.js +1 -1
  149. package/dist/lib/auth.js +1 -1
  150. package/dist/lib/claude-md-blocks.js +1 -0
  151. package/dist/lib/codex-exec.js +1 -1
  152. package/dist/lib/ensure-api-key.js +1 -1
  153. package/dist/lib/ensure-fresh-token.js +1 -1
  154. package/dist/lib/eval-benchmark.js +1 -1
  155. package/dist/lib/eval-candidate-run.js +1 -1
  156. package/dist/lib/eval-case-generator.js +1 -1
  157. package/dist/lib/eval-conversation-handler.js +1 -1
  158. package/dist/lib/eval-grader.js +1 -1
  159. package/dist/lib/eval-resume.js +1 -1
  160. package/dist/lib/eval-run-batch.js +1 -1
  161. package/dist/lib/evolution-enrolment.js +1 -1
  162. package/dist/lib/handlers/cron-auto-accept-suggestions.js +1 -1
  163. package/dist/lib/handlers/cron-eval-autorun.js +1 -1
  164. package/dist/lib/handlers/cron-instruction-evolution.js +1 -1
  165. package/dist/lib/handlers/cron-instruction-training.js +1 -1
  166. package/dist/lib/handlers/cron-refresh-pricing.js +1 -1
  167. package/dist/lib/handlers/cron-suggest-instructions.js +1 -1
  168. package/dist/lib/handlers/distill-memories.js +1 -1
  169. package/dist/lib/handlers/process-changelog.js +1 -1
  170. package/dist/lib/handlers/process-conversation.js +1 -1
  171. package/dist/lib/handlers/process-eval.js +1 -1
  172. package/dist/lib/handlers/process-insights.js +1 -1
  173. package/dist/lib/handlers/process-judge-review.js +1 -1
  174. package/dist/lib/handlers/process-launch.js +1 -1
  175. package/dist/lib/handlers/process-memory-ab.js +1 -1
  176. package/dist/lib/handlers/process-run-cleanup.js +1 -1
  177. package/dist/lib/handlers/process-session-goal.js +1 -1
  178. package/dist/lib/instruction-proposer.js +1 -1
  179. package/dist/lib/judge-review-runner.js +1 -1
  180. package/dist/lib/llm-client.js +1 -1
  181. package/dist/lib/manual-tasks.js +1 -1
  182. package/dist/lib/research-client.js +1 -1
  183. package/dist/lib/retraction.js +1 -1
  184. package/dist/lib/reviewer-detect.js +1 -1
  185. package/dist/lib/setup-steps.js +1 -1
  186. package/dist/lib/suggestion-accept.js +1 -1
  187. package/dist/lib/telemetry.js +1 -1
  188. package/dist/lib/terminal-target-heartbeat.js +1 -1
  189. package/oclif.manifest.json +442 -386
  190. package/package.json +6 -6
  191. package/dist/chunk-3PUOJ6F2.js +0 -45
  192. package/dist/chunk-JZ5Z2BRO.js +0 -7
  193. package/dist/chunk-MMPZIZYZ.js +0 -10
  194. package/dist/chunk-QWPWY3SW.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulemetric/cli",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -80,9 +80,9 @@
80
80
  "postgres": "^3.4.0",
81
81
  "react": "^19.0.0",
82
82
  "zod": "^3.24.0",
83
- "@rulemetric/hooks": "0.9.0",
84
- "@rulemetric/skills-registry": "0.9.0",
85
- "@rulemetric/proxy": "0.9.0"
83
+ "@rulemetric/hooks": "0.10.0",
84
+ "@rulemetric/skills-registry": "0.10.0",
85
+ "@rulemetric/proxy": "0.10.0"
86
86
  },
87
87
  "//deps": "Worker (`evals agent`) runtime deps: the @opentelemetry/* set, @sentry/node, and postgres are STATIC top-level imports loaded at worker startup (via bundled @rulemetric/{telemetry,db}) — they MUST be runtime deps or a clean `npm i -g` crashes with ModuleLoadError. `better-sqlite3` is optionalDependencies (below): it's a native module, lazy `require()`'d inside a try/catch (packages/session providers cursor/opencode) so a missing binary degrades gracefully — making it a hard dep would break `npm i -g` on platforms without prebuilt binaries. `resend` stays a devDep: lazy `await import('resend')` guarded by RESEND_API_KEY, which end-user workers never set (provider falls back to noop). Classification verified via import-graph scan of dist/commands/evals/agent.js + per-importer static/lazy check.",
88
88
  "optionalDependencies": {
@@ -101,11 +101,11 @@
101
101
  "typescript": "^5.9.0",
102
102
  "vitest": "^3.2.0",
103
103
  "@rulemetric/api": "0.0.1",
104
- "@rulemetric/db": "0.0.1",
105
104
  "@rulemetric/core": "0.0.1",
106
- "@rulemetric/effectiveness": "0.0.1",
105
+ "@rulemetric/db": "0.0.1",
107
106
  "@rulemetric/email": "0.0.1",
108
107
  "@rulemetric/session": "0.2.1",
108
+ "@rulemetric/effectiveness": "0.0.1",
109
109
  "@rulemetric/telemetry": "0.0.1",
110
110
  "@rulemetric/typescript-config": "0.0.0"
111
111
  },
@@ -1,45 +0,0 @@
1
- import{a as o}from"./chunk-ZLLER3HP.js";function I(e){if(!e||typeof e!="object")return e;let r=e,n=r.project_areas;if(n!==void 0&&!Array.isArray(n)){let t=n&&typeof n=="object"?n.areas:void 0;r.project_areas=Array.isArray(t)?t:void 0}return e}o(I,"normalizeRecommendations");import{z as l}from"zod";var x=["org","team","project","personal"],_=l.object({name:l.string().min(1),description:l.string().min(1),type:l.literal("instruction").default("instruction"),scope:l.enum(x),version:l.string().min(1),tags:l.array(l.string()).optional(),compatibility:l.array(l.string()).optional(),slots:l.record(l.string(),l.string()).optional(),metadata:l.record(l.string(),l.unknown()).optional()});import{z as p}from"zod";var C=p.object({name:p.string().min(1),description:p.string().min(1),type:p.literal("prompt"),version:p.string().min(1),tags:p.array(p.string()).optional(),variables:p.array(p.string()).optional(),metadata:p.record(p.string(),p.unknown()).optional()});function h(e,r){let n=r.map(t=>`- ID: ${t.id}
2
- Name: ${t.name}
3
- Description: ${t.description}
4
- Tags: ${t.tags.join(", ")}
5
- Preview: ${t.contentPreview}`).join(`
6
-
7
- `);return`You are an expert at matching AI coding instructions to software projects.
8
-
9
- ## Project
10
- - Name: ${e.name}
11
- - Description: ${e.description??"No description"}
12
- - Languages: ${e.languages.join(", ")||"Unknown"}
13
- - Topics: ${e.topics.join(", ")||"None"}
14
- - Dependencies: ${e.dependencies.join(", ")||"None"}
15
-
16
- ## Available Instructions
17
-
18
- ${n}
19
-
20
- ## Task
21
-
22
- Analyze the project and recommend which instructions would be most useful. Consider:
23
- 1. Language and framework alignment
24
- 2. Project purpose and what standards/practices would help
25
- 3. Security, testing, and quality needs based on the project type
26
-
27
- Return your response as JSON in this exact format:
28
- {
29
- "recommendations": [
30
- { "instructionId": "<id>", "score": <0.0-1.0>, "reason": "<one sentence explanation>" }
31
- ]
32
- }
33
-
34
- Only include instructions with a relevance score >= 0.5. Order by score descending. Return valid JSON only, no markdown fences.`}o(h,"buildRecommendationPrompt");var R=32e3,O={name:"x".repeat(64),description:"x".repeat(256),languages:["TypeScript","Python","Go"],topics:["x".repeat(32)],dependencies:["x".repeat(32)]};function T(e,r={}){if(e.length===0)return[];let n=r.charBudget??R,t=h(O,[]).length,s=[],i=[],u=0;for(let d of e){let m=L(d);i.length>0&&t+u+m>n&&(s.push(i),i=[],u=0),i.push(d),u+=m}return i.length>0&&s.push(i),s}o(T,"batchCandidatesForPrompt");function L(e){return`- ID: ${e.id}
35
- Name: ${e.name}
36
- Description: ${e.description}
37
- Tags: ${e.tags.join(", ")}
38
- Preview: ${e.contentPreview}`.length+2}o(L,"renderedSize");var b=["Added","Changed","Fixed","Removed","Deprecated","Security"],j=/^##\s+\[([^\]]+)\](?:\s*[-–]\s*(\d{4}-\d{2}-\d{2}))?\s*$/,A=/^###\s+(.+?)\s*$/,N=/^[-*]\s+(.*\S)\s*$/,E=/^ {2,}(\S.*)$/;function F(e){let r=e.split(/\r?\n/),n=[],t=null,s=null,i=null;for(let u of r){let d=u.match(j);if(d){t&&n.push(t);let c=d[1].trim();t={version:c,date:d[2]??null,unreleased:c.toLowerCase()==="unreleased",sections:{}},s=null,i=null;continue}if(!t)continue;let m=u.match(A);if(m){let c=m[1].trim();b.includes(c)?(s=c,t.sections[s]||(t.sections[s]=[]),i=t.sections[s]):(s=null,i=null);continue}if(!s||!i)continue;let f=u.match(N);if(f){i.push(f[1]);continue}let g=u.match(E);if(g&&i.length>0){i[i.length-1]+=" "+g[1].trim();continue}}return t&&n.push(t),{entries:n}}o(F,"parseChangelog");function D(e){return e.entries.filter(r=>r.unreleased?!1:Object.values(r.sections).some(n=>n&&n.length>0))}o(D,"announceableEntries");function w(e){let r=/^(#{1,6})\s+/.exec(e);return r?r[1].length:0}o(w,"headingLevel");function M(e){return e.replace(/^#{1,6}\s+/,"").replace(/[`*_~]/g,"").trim().toLowerCase()}o(M,"normaliseHeading");function $(e,r){let n=M(r);if(n.length===0)return{content:e,removed:!1,removedText:null,reason:"not-found"};let t=e.split(`
39
- `),s=[];for(let c=0;c<t.length;c+=1)w(t[c])>0&&M(t[c])===n&&s.push(c);if(s.length===0)return{content:e,removed:!1,removedText:null,reason:"not-found"};if(s.length>1)return{content:e,removed:!1,removedText:null,reason:"ambiguous"};let i=s[0],u=w(t[i]),d=t.length;for(let c=i+1;c<t.length;c+=1){let v=w(t[c]);if(v>0&&v<=u){d=c;break}}let m=t.slice(i,d).join(`
40
- `),f=[...t.slice(0,i),...t.slice(d)];return f.join("").trim().length===0?{content:e,removed:!1,removedText:null,reason:"would-empty-file"}:{content:f.join(`
41
- `).replace(/\n{3,}/g,`
42
-
43
- `),removed:!0,removedText:m}}o($,"removeMarkdownSection");function G(e,r){let n=r.trim();if(n.length===0)return{content:e,removed:!1,removedText:null,reason:"not-found"};let t=e.indexOf(n);if(t===-1)return{content:e,removed:!1,removedText:null,reason:"not-found"};if(e.indexOf(n,t+1)!==-1)return{content:e,removed:!1,removedText:null,reason:"ambiguous"};let s=(e.slice(0,t)+e.slice(t+n.length)).replace(/\n{3,}/g,`
44
-
45
- `);return s.trim().length===0?{content:e,removed:!1,removedText:null,reason:"would-empty-file"}:{content:s,removed:!0,removedText:n}}o(G,"removeExactBlock");var k=["HTTPS_PROXY","HTTP_PROXY","NODE_EXTRA_CA_CERTS"];function U(e,r){if(!e||typeof e!="object")return{value:e,removed:!1,removedDescriptions:[],reason:"not-found"};let n=structuredClone(e);if(!n.hooks)return{value:n,removed:!1,removedDescriptions:[],reason:"not-found"};let t=[];for(let[s,i]of Object.entries(n.hooks)){if(!Array.isArray(i))continue;let u=i.filter(d=>{let m=(d.hooks??[]).some(f=>typeof f.command=="string"&&f.command.includes(r));return m&&t.push(`${s}: ${d.matcher??"*"} \u2192 ${(d.hooks??[]).map(f=>f.command).join(", ")}`),!m});u.length===0?delete n.hooks[s]:n.hooks[s]=u}return Object.keys(n.hooks).length===0&&delete n.hooks,{value:n,removed:t.length>0,removedDescriptions:t,...t.length===0?{reason:"not-found"}:{}}}o(U,"removeHookByCommand");function H(e,r){if(!e||typeof e!="object")return{value:e,removed:!1,removedDescriptions:[],reason:"not-found"};let n=structuredClone(e);return!n.mcpServers||!(r in n.mcpServers)?{value:n,removed:!1,removedDescriptions:[],reason:"not-found"}:(delete n.mcpServers[r],Object.keys(n.mcpServers).length===0&&delete n.mcpServers,{value:n,removed:!0,removedDescriptions:[`mcpServers.${r}`]})}o(H,"removeMcpServer");function y(e){if(!e||typeof e!="object")return[];let r=e.env;return r?k.filter(n=>n in r):[]}o(y,"protectedEnvKeysPresent");function z(e,r){let n=y(e),t=new Set(y(r));return n.filter(s=>!t.has(s))}o(z,"lostProtectedEnvKeys");function B(e,r){let n=`HTTP ${e}`;if(!r||typeof r!="object")return{message:n};let t=r,s=typeof t.error=="string"&&t.error?t.error:t.error?JSON.stringify(t.error):n,i=typeof t.code=="string"&&t.code?t.code:void 0;return i?{message:s,code:i}:{message:s}}o(B,"parseApiError");import Me from"gray-matter";import{z as S}from"zod";var Ie=S.object({type:S.enum(["instruction","prompt"])});export{I as a,h as b,T as c,F as d,D as e,$ as f,G as g,U as h,H as i,z as j,B as k};
@@ -1,7 +0,0 @@
1
- import{a as e}from"./chunk-ZLLER3HP.js";import*as i from"node:fs";import*as u from"node:path";import*as R from"node:os";function m(){return process.env.RULEMETRIC_CONFIG_DIR||u.join(R.homedir(),".config","rulemetric")}e(m,"getConfigDir");var l;function F(){if(l!==void 0)return l;try{let n=u.join(m(),"env");if(!i.existsSync(n))return l={};let s=i.readFileSync(n,"utf-8"),E=e(h=>s.match(new RegExp(`^${h}=(.+)$`,"m"))?.[1]?.trim(),"read");return l={apiKey:E("RULEMETRIC_API_KEY"),accessToken:E("RULEMETRIC_ACCESS_TOKEN"),apiUrl:E("RULEMETRIC_API_URL"),strictLocal:E("RULEMETRIC_STRICT_LOCAL")},l}catch{return l={}}}e(F,"loadEnvFileAuth");function L(){l=void 0}e(L,"__resetEnvFileAuthCache");function S(n=m()){let s=u.join(n,"auth.json");function E(o){i.mkdirSync(n,{recursive:!0,mode:448}),i.writeFileSync(s,JSON.stringify(o,null,2),{encoding:"utf-8",mode:384})}e(E,"saveToken");function h(){try{let o=i.readFileSync(s,"utf-8"),t=JSON.parse(o);return t&&typeof t=="object"&&"accessToken"in t&&"expiresAt"in t&&"email"in t&&typeof t.accessToken=="string"&&typeof t.expiresAt=="string"?t:null}catch{return null}}e(h,"loadToken");function _(){try{i.unlinkSync(s)}catch{}}e(_,"clearToken");function g(){let o=h();if(!o)return!1;let t=new Date(o.expiresAt).getTime();return Number.isNaN(t)?!1:Date.now()<t}e(g,"isAuthenticated");function y(o=0){let t=h();if(!t?.refreshToken)return!1;let r=new Date(t.expiresAt).getTime();return Number.isNaN(r)?!0:Date.now()>=r-o}e(y,"isRefreshable");function k(o,t){i.mkdirSync(n,{recursive:!0,mode:448});let r=u.join(n,"env"),c="",p="";try{let v=i.readFileSync(r,"utf-8"),T=v.match(/^RULEMETRIC_API_KEY=(.+)$/m);T&&(c=T[1]);let d=v.match(/^RULEMETRIC_API_URL=(.+)$/m);d&&(p=d[1])}catch{}let f=[`RULEMETRIC_ACCESS_TOKEN=${o}`];c&&f.push(`RULEMETRIC_API_KEY=${c}`);let A=t||p||"https://rulemetric.com";f.push(`RULEMETRIC_API_URL=${A}`),i.writeFileSync(r,f.join(`
2
- `)+`
3
- `,{encoding:"utf-8",mode:384})}e(k,"saveEnvFile");function C(o,t){i.mkdirSync(n,{recursive:!0,mode:448});let r=u.join(n,"env"),c="",p="";try{let v=i.readFileSync(r,"utf-8"),T=v.match(/^RULEMETRIC_ACCESS_TOKEN=(.+)$/m);T&&(c=T[1]);let d=v.match(/^RULEMETRIC_API_URL=(.+)$/m);d&&(p=d[1])}catch{}let f=[`RULEMETRIC_API_KEY=${o}`];c&&f.push(`RULEMETRIC_ACCESS_TOKEN=${c}`);let A=t||p||"https://rulemetric.com";A&&f.push(`RULEMETRIC_API_URL=${A}`),i.writeFileSync(r,f.join(`
4
- `)+`
5
- `,{encoding:"utf-8",mode:384})}e(C,"saveApiKeyToEnv");function I(){let o=u.join(n,"env");try{i.unlinkSync(o)}catch{}}e(I,"clearEnvFile");function x(){let o=u.join(n,"env");try{let t=i.readFileSync(o,"utf-8"),r=t.split(`
6
- `).filter(c=>!c.startsWith("RULEMETRIC_API_KEY=")).join(`
7
- `);r!==t&&i.writeFileSync(o,r,{encoding:"utf-8",mode:384})}catch{}}return e(x,"removeApiKeyFromEnvFile"),{saveToken:E,loadToken:h,clearToken:_,isAuthenticated:g,isRefreshable:y,saveEnvFile:k,saveApiKeyToEnv:C,clearEnvFile:I,removeApiKeyFromEnvFile:x,configDir:n,authFile:s}}e(S,"createAuthStore");function a(){return S()}e(a,"getStore");function U(n){a().saveToken(n)}e(U,"saveToken");function K(){return a().loadToken()}e(K,"loadToken");function M(){a().clearToken()}e(M,"clearToken");function P(){if(process.env.RULEMETRIC_API_KEY||a().isAuthenticated())return!0;let n=F();return!!(n.apiKey||n.accessToken)}e(P,"isAuthenticated");function N(n,s){a().saveEnvFile(n,s)}e(N,"saveEnvFile");function j(n,s){a().saveApiKeyToEnv(n,s)}e(j,"saveApiKey");function $(){a().clearEnvFile()}e($,"clearEnvFile");function w(){a().removeApiKeyFromEnvFile()}e(w,"removeApiKeyFromEnv");function O(){return m()}e(O,"getDefaultConfigDir");var b=m();export{F as a,L as b,S as c,U as d,K as e,M as f,P as g,N as h,j as i,$ as j,w as k,O as l,b as m};
@@ -1,10 +0,0 @@
1
- import{e as m,f as l,i as p}from"./chunk-QAV4HW7D.js";import{a as c}from"./chunk-ZLLER3HP.js";import*as s from"node:fs";import*as g from"node:path";function y(e,t,n){let i=g.join(e,"CLAUDE.md"),r=`<!-- rulemetric:start ${t} -->`,a=`<!-- rulemetric:end ${t} -->`,o=s.existsSync(i)?s.readFileSync(i,"utf8"):"";if(o.includes(r))return!1;let u=`${o.length>0&&!o.endsWith(`
2
- `)?`
3
-
4
- `:o.length>0?`
5
- `:""}
6
- ${r}
7
- ${n}
8
- ${a}
9
- `;return s.writeFileSync(i,o+u,"utf8"),!0}c(y,"appendToCLAUDEmd");function A(e,t){let n=g.join(e,"CLAUDE.md");if(!s.existsSync(n))return!1;let i=`<!-- rulemetric:start ${t} -->`,r=`<!-- rulemetric:end ${t} -->`,a=s.readFileSync(n,"utf8"),o=a.indexOf(i);if(o===-1)return!1;let d=a.indexOf(r,o);if(d===-1)return!1;let u=a.slice(0,o),h=a.slice(d+r.length),I=(u.replace(/\n+$/,"")+`
10
- `+h.replace(/^\n+/,"")).replace(/^\n+/,"");return s.writeFileSync(n,I,"utf8"),!0}c(A,"removeFromCLAUDEmd");function $(e){return m(`/api/instruction-suggestions/${encodeURIComponent(e)}`)}c($,"fetchSuggestion");async function f(e,t,n,i){await l(`/api/instruction-suggestions/${encodeURIComponent(e)}/events`,{eventType:"accepted",projectPath:t,instructionId:n,actor:i})}c(f,"logAccepted");async function b(e){let t=e.suggestion??await $(e.suggestionId);if(t.kind==="remove")return x(e,t);if(t.kind==="trim")return w(e,t);let n=t.instructionId;t.instructionScope==="public"&&(n=(await l(`/api/instructions/${encodeURIComponent(t.instructionId)}/promote-from-public`,{targetScope:"personal"})).instructionId);let i=await m(`/api/instructions/${encodeURIComponent(n)}`),r=y(e.dir,n,i.content);return await f(e.suggestionId,e.projectPath,n,e.actor),{action:r?"added":"already-present",instructionId:n,name:i.name,fileModified:r,messages:r?[`Accepted: added ${i.name} to CLAUDE.md. It will be active starting in your next session.`]:[`Already present: ${i.name} is already in CLAUDE.md (block id: ${n}).`]}}c(b,"acceptSuggestion");async function w(e,t){let n=t.estimatedTokens?` It currently costs roughly ${t.estimatedTokens} tokens per session (estimated).`:"";return await f(e.suggestionId,e.projectPath,t.instructionId,e.actor),{action:"acknowledged",instructionId:t.instructionId,name:t.name,fileModified:!1,messages:[`Noted: ${t.name} is measured neutral, not harmful.${n}`,"Nothing was changed \u2014 trimming is a judgement call about which parts carry the value,","and the measurement only found the absence of a detectable effect, not which half to cut.",` View it: rulemetric instructions get ${t.instructionId}`," Then edit CLAUDE.md (or the instruction) and let the next measurement cycle re-check it.","This suggestion will stop re-surfacing."]}}c(w,"acknowledgeTrim");async function x(e,t){let n=A(e.dir,t.instructionId);await p(`/api/instructions/${encodeURIComponent(t.instructionId)}`);let i=t.estimatedTokens?` Frees roughly ${t.estimatedTokens} tokens of context per session (estimated).`:"",r=n?[`Retired: removed ${t.name} from CLAUDE.md and archived it.${i}`]:[`Archived ${t.name}.${i}`,"CLAUDE.md was not modified \u2014 no rulemetric-managed block for this instruction was found in this directory. If you added it by hand, remove it yourself."];return r.push("Undo with: rulemetric instructions restore "+t.instructionId),await f(e.suggestionId,e.projectPath,t.instructionId,e.actor),{action:n?"retired":"archived-only",instructionId:t.instructionId,name:t.name,fileModified:n,messages:r}}c(x,"acceptRemoval");export{y as a,A as b,$ as c,b as d};
@@ -1 +0,0 @@
1
- import{d as g}from"./chunk-MMPZIZYZ.js";import{e as p}from"./chunk-QAV4HW7D.js";import{a as d}from"./chunk-ZLLER3HP.js";import{existsSync as f,statSync as $}from"node:fs";async function A(l,m){let n=d(t=>m?.logger?.info?.(t)??console.log(t),"log"),{projectPath:s}=l,o=`[cron_auto_accept_suggestions] ${s}`;if(!s)return{skipped:"no-project-path"};if(!f(s)||!$(s).isDirectory())return n(`${o}: project directory no longer exists on this machine \u2014 skipping`),{skipped:"project-path-missing"};let e=await p(`/api/instruction-suggestions/auto-acceptable?projectPath=${encodeURIComponent(s)}`);if(!e.consent.allowed)return n(`${o}: ${e.consent.reason??"no consent"} (${e.consent.source})`),{skipped:"no-consent",reason:e.consent.reason};for(let t of e.refused)n(`${o}: refused "${t.name}" \u2014 ${t.reason}`);if(e.eligible.length===0)return n(`${o}: nothing to adopt`+(e.budget?` (${e.budget.used}/${e.budget.max} used in ${e.budget.windowDays}d)`:"")),{skipped:"nothing-eligible",refused:e.refused.length,adopted:0};let i=0,a=0,c=0,u=[];for(let t of e.eligible)try{let r=await g({suggestionId:t.id,dir:s,projectPath:s,actor:"auto"});r.action==="added"?(i+=1,u.push(r.name),n(`${o}: adopted "${r.name}" (score ${t.score.toFixed(2)})`)):(a+=1,n(`${o}: "${r.name}" was already in CLAUDE.md`))}catch(r){c+=1,n(`${o}: failed to adopt "${t.name}" \u2014 ${r instanceof Error?r.message:String(r)}`)}return n(`${o}: ${i} adopted, ${a} already present, ${c} failed, ${e.refused.length} refused. Undo any of them with \`rulemetric suggestions undo <instruction-id>\`.`),{adopted:i,alreadyPresent:a,failed:c,refused:e.refused.length,names:u}}d(A,"cronAutoAcceptSuggestions");export{A as a};