@canonry/canonry 7.51.5 → 7.52.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 (141) hide show
  1. package/assets/agent-workspace/skills/canonry/references/canonry-cli.md +8 -0
  2. package/assets/assets/{AccessControls-B5TqDgeq.js → AccessControls-CteIuEGI.js} +1 -1
  3. package/assets/assets/{AuditHistoryPanel-DgxiizOW.js → AuditHistoryPanel-DqJGiLsf.js} +1 -1
  4. package/assets/assets/{BacklinksPage-Ay6pdphx.js → BacklinksPage-DotWEPQt.js} +1 -1
  5. package/assets/assets/{HistoryPage-B11eFH21.js → HistoryPage-aOd198dT.js} +1 -1
  6. package/assets/assets/MeasurementPropertyPage-CuaKVK8x.js +4 -0
  7. package/assets/assets/{ProjectPage-DoY0hftd.js → ProjectPage-O9oufMgi.js} +4 -4
  8. package/assets/assets/{RunsPage-BPBmuQAS.js → RunsPage-DIXMrc-N.js} +1 -1
  9. package/assets/assets/{SettingsPage-ClKnP8xy.js → SettingsPage-BuGb6AGa.js} +1 -1
  10. package/assets/assets/SiteHealthSection-CweaKjCo.js +2 -0
  11. package/assets/assets/TrafficPage-B7MaQalp.js +40 -0
  12. package/assets/assets/{TrafficSourceDetailPage-DQu0YNt2.js → TrafficSourceDetailPage-BPtjnF9s.js} +1 -1
  13. package/assets/assets/{card-DYMyvhB9.js → card-DoV-8Txo.js} +1 -1
  14. package/assets/assets/{extract-error-message-BRM1I_3L.js → extract-error-message-DKQJJlZ-.js} +1 -1
  15. package/assets/assets/{format-helpers-DrkFERj3.js → format-helpers-BWnMmkiO.js} +1 -1
  16. package/assets/assets/index-Z63c4PeO.js +39 -0
  17. package/assets/assets/{query-client-gRFnU4VF.js → query-client-vB35tVTz.js} +1 -1
  18. package/assets/assets/{react-query-lH82FULK.js → react-query-BI0567qs.js} +1 -1
  19. package/assets/assets/{react-sigma_core.esm.min-D09H4byP.js → react-sigma_core.esm.min-hGyOC4V_.js} +1 -1
  20. package/assets/assets/{service-Cx0HSnE9.js → service-c4YvpVKX.js} +1 -1
  21. package/assets/index.html +6 -6
  22. package/dist/ads-MREK2AGL.js +544 -0
  23. package/dist/agent-4RUZ3MC4.js +70 -0
  24. package/dist/agent-ask-YLTYBEYH.js +139 -0
  25. package/dist/agent-conversations-QA6IKDGR.js +52 -0
  26. package/dist/agent-memory-MEQAJOB3.js +92 -0
  27. package/dist/agent-providers-AXYPDJHL.js +55 -0
  28. package/dist/agent-transcript-SMNQNYCD.js +77 -0
  29. package/dist/analytics-4OR64IGV.js +240 -0
  30. package/dist/apply-CQXCFXAH.js +175 -0
  31. package/dist/backfill-TMXCNVOB.js +41 -0
  32. package/dist/backlinks-6KFAQGYV.js +303 -0
  33. package/dist/bing-HFCACTAC.js +418 -0
  34. package/dist/bootstrap-SQVQXOJC.js +326 -0
  35. package/dist/cdp-IACL7EXU.js +162 -0
  36. package/dist/chunk-4MJYGB56.js +124 -0
  37. package/dist/chunk-5N6245R7.js +1160 -0
  38. package/dist/chunk-6BPZHNDC.js +617 -0
  39. package/dist/chunk-6GO5VVAC.js +15 -0
  40. package/dist/chunk-7244X3K6.js +609 -0
  41. package/dist/chunk-7XE2IRBG.js +204 -0
  42. package/dist/chunk-AOJU5LKX.js +8 -0
  43. package/dist/chunk-AWCWIQAU.js +2686 -0
  44. package/dist/{chunk-JBZZEIM2.js → chunk-BBOHY2DQ.js} +2 -13
  45. package/dist/{chunk-AZFPA7JV.js → chunk-BU3VAG5J.js} +6 -4
  46. package/dist/{chunk-4YCGZGA3.js → chunk-BYOK6Z4F.js} +2 -2
  47. package/dist/chunk-DSNSD5J3.js +971 -0
  48. package/dist/chunk-EGIZNSDA.js +94 -0
  49. package/dist/chunk-ELCLGWUT.js +83 -0
  50. package/dist/chunk-FC4XND45.js +38 -0
  51. package/dist/chunk-GNKOBKPW.js +58 -0
  52. package/dist/chunk-HEGXGCGL.js +524 -0
  53. package/dist/chunk-I6KNMZ77.js +232 -0
  54. package/dist/{chunk-HLVEB5TB.js → chunk-IIOEAJTV.js} +7 -5
  55. package/dist/chunk-ILDT4LPB.js +1273 -0
  56. package/dist/chunk-JY3RLZGB.js +30 -0
  57. package/dist/{chunk-PLYJX67A.js → chunk-K5I45PZI.js} +8084 -13939
  58. package/dist/chunk-KXAOMTXN.js +1034 -0
  59. package/dist/chunk-LK2BG6EX.js +145 -0
  60. package/dist/chunk-MJNUSPO4.js +15 -0
  61. package/dist/chunk-MKAC7HKH.js +9178 -0
  62. package/dist/chunk-MLKGABMK.js +9 -0
  63. package/dist/{chunk-SFMWHPMX.js → chunk-O4RMPA6H.js} +13765 -13737
  64. package/dist/chunk-O77IBNVO.js +8264 -0
  65. package/dist/chunk-OFL4PTYU.js +644 -0
  66. package/dist/chunk-QLPLENDT.js +133 -0
  67. package/dist/chunk-R2J4SNKF.js +78 -0
  68. package/dist/{chunk-KEATAHXH.js → chunk-RVUCY4ZV.js} +358 -581
  69. package/dist/chunk-SNFBJKAW.js +530 -0
  70. package/dist/chunk-TALC5DX5.js +420 -0
  71. package/dist/chunk-TSENU4GG.js +18 -0
  72. package/dist/{chunk-HAHXPJQ5.js → chunk-V5D4XNWV.js} +16 -1684
  73. package/dist/chunk-VJWDBFSL.js +69 -0
  74. package/dist/chunk-XEBKF4N5.js +8 -0
  75. package/dist/chunk-Y4GK7GCV.js +15376 -0
  76. package/dist/{chunk-A3WSAAQS.js → chunk-YSEC6TIB.js} +7917 -33199
  77. package/dist/chunk-Z7IUAJOF.js +13 -0
  78. package/dist/citations-NSBBWRZ4.js +106 -0
  79. package/dist/{cli-catalog-MO6Z2CIZ.js → cli-catalog-OFWJMNMD.js} +5 -3
  80. package/dist/cli-commands-WVBL337U.js +19 -0
  81. package/dist/cli.js +35 -29
  82. package/dist/competitor-V4OHORBC.js +561 -0
  83. package/dist/content-RUXRI5IC.js +257 -0
  84. package/dist/dashboard-JXB2YAQJ.js +71 -0
  85. package/dist/demo-55ZNUOXU.js +75 -0
  86. package/dist/{demo-server-GIWDJGJX.js → demo-server-XO7PHM4I.js} +22 -9
  87. package/dist/discover-JJQ564HS.js +372 -0
  88. package/dist/discover-eval-KLEKZ6U4.js +282 -0
  89. package/dist/doctor-JAMQZCMZ.js +152 -0
  90. package/dist/evidence-YRSB7GFE.js +57 -0
  91. package/dist/export-cmd-MHML4OYU.js +49 -0
  92. package/dist/ga-LSXPE2MN.js +911 -0
  93. package/dist/gbp-RMKMLOC7.js +370 -0
  94. package/dist/google-JQ4T6JTQ.js +946 -0
  95. package/dist/google-marketing-J6SEODYC.js +403 -0
  96. package/dist/health-cmd-MV2JM2C3.js +64 -0
  97. package/dist/history-SRRH7A2E.js +90 -0
  98. package/dist/index.d.ts +43 -4
  99. package/dist/index.js +29 -6
  100. package/dist/init-ZJZFUERV.js +432 -0
  101. package/dist/insights-PMMGNWZH.js +63 -0
  102. package/dist/intelligence-service-KCSU6ZUJ.js +15 -0
  103. package/dist/keys-TS7NZANS.js +116 -0
  104. package/dist/keyword-VNCKDUGC.js +164 -0
  105. package/dist/logs-VH3WOTZJ.js +30 -0
  106. package/dist/mcp-DG2RROB3.js +14 -0
  107. package/dist/mcp.js +14 -5
  108. package/dist/measurement-plan-4T35TUGG.js +42 -0
  109. package/dist/notify-BWHUSKL7.js +125 -0
  110. package/dist/organic-evidence-QX4SXXJP.js +53 -0
  111. package/dist/overview-7IHUTKUV.js +213 -0
  112. package/dist/project-JXLSWDE2.js +460 -0
  113. package/dist/query-S75EL25H.js +211 -0
  114. package/dist/research-KFTV3IP4.js +200 -0
  115. package/dist/results-export-GTKVBU34.js +27 -0
  116. package/dist/run-26HDIRHF.js +31 -0
  117. package/dist/schedule-N6G4SVHQ.js +177 -0
  118. package/dist/search-MI32EPYM.js +42 -0
  119. package/dist/serve-XLGE42AG.js +598 -0
  120. package/dist/session-W5DXWIYM.js +47 -0
  121. package/dist/settings-T7WI2UVE.js +107 -0
  122. package/dist/skills-F3WPKPTK.js +33 -0
  123. package/dist/snapshot-PD3EAVEX.js +538 -0
  124. package/dist/src-XDUXMJC3.js +316 -0
  125. package/dist/status-PUH7JFZ4.js +126 -0
  126. package/dist/support-ARF4HER7.js +24 -0
  127. package/dist/technical-aeo-AUFWWJIP.js +625 -0
  128. package/dist/telemetry-XBYT7G2K.js +118 -0
  129. package/dist/tools-GVHIRWSN.js +41 -0
  130. package/dist/traffic-B3HW2ZWG.js +1295 -0
  131. package/dist/users-M5HNQZYI.js +170 -0
  132. package/dist/visibility-stats-Y7GJKMHN.js +241 -0
  133. package/dist/wordpress-GCIURYPN.js +600 -0
  134. package/package.json +1 -1
  135. package/assets/assets/MeasurementPropertyPage-1UYI7mzP.js +0 -4
  136. package/assets/assets/SiteHealthSection-PWjKMmEn.js +0 -2
  137. package/assets/assets/TrafficPage-DkfGiJXR.js +0 -40
  138. package/assets/assets/index-CG1Jox52.js +0 -39
  139. package/dist/chunk-4QQYYRHV.js +0 -23082
  140. package/dist/cli-commands-FOJR3HHU.js +0 -15
  141. package/dist/intelligence-service-XQCNWAPL.js +0 -9
@@ -0,0 +1,420 @@
1
+ import {
2
+ PACKAGE_VERSION
3
+ } from "./chunk-AOJU5LKX.js";
4
+ import {
5
+ CliError,
6
+ isMachineFormat
7
+ } from "./chunk-HGMYEDAQ.js";
8
+ import {
9
+ CodingAgents,
10
+ SKILL_MANIFEST_FILENAME,
11
+ SkillsClients,
12
+ agentPluginClientLabel,
13
+ classifySkillFile,
14
+ coerceSkillManifest,
15
+ formatCanonryPluginUpdateHint,
16
+ formatCanonryPluginVersionMismatch,
17
+ skillsClientSchema
18
+ } from "./chunk-O4RMPA6H.js";
19
+
20
+ // src/commands/skills.ts
21
+ import crypto from "crypto";
22
+ import fs from "fs";
23
+ import os from "os";
24
+ import path from "path";
25
+ import { fileURLToPath } from "url";
26
+ var BUNDLED_SKILL_NAMES = ["canonry", "aero"];
27
+ function resolveBundledSkillsRoot(pkgDir) {
28
+ const here = pkgDir ?? path.dirname(fileURLToPath(import.meta.url));
29
+ const candidates = [
30
+ path.join(here, "../assets/agent-workspace/skills"),
31
+ path.join(here, "../../assets/agent-workspace/skills"),
32
+ path.join(here, "../../../../skills")
33
+ ];
34
+ for (const candidate of candidates) {
35
+ if (BUNDLED_SKILL_NAMES.every((name) => fs.existsSync(path.join(candidate, name, "SKILL.md")))) {
36
+ return candidate;
37
+ }
38
+ }
39
+ throw new CliError({
40
+ code: "INTERNAL_ERROR",
41
+ message: `Bundled skills not found. Searched:
42
+ ${candidates.join("\n ")}`,
43
+ exitCode: 2
44
+ });
45
+ }
46
+ function parseDescription(content) {
47
+ const fmMatch = /^---\n([\s\S]*?)\n---/.exec(content);
48
+ if (!fmMatch) return "";
49
+ const descMatch = /^description:\s*(\S.*)$/m.exec(fmMatch[1]);
50
+ if (!descMatch) return "";
51
+ return descMatch[1].replace(/^["']|["']$/g, "").trim();
52
+ }
53
+ function getBundledSkills(pkgDir) {
54
+ const root = resolveBundledSkillsRoot(pkgDir);
55
+ return BUNDLED_SKILL_NAMES.map((name) => {
56
+ const skillDir = path.join(root, name);
57
+ const skillFile = path.join(skillDir, "SKILL.md");
58
+ const content = fs.readFileSync(skillFile, "utf-8");
59
+ return { name, description: parseDescription(content), bundledPath: skillDir };
60
+ });
61
+ }
62
+ function walkRelative(dir, prefix = "") {
63
+ const out = [];
64
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
65
+ const rel = prefix ? path.join(prefix, entry.name) : entry.name;
66
+ const full = path.join(dir, entry.name);
67
+ if (entry.isDirectory()) {
68
+ out.push(...walkRelative(full, rel));
69
+ } else if (entry.isFile()) {
70
+ out.push(rel);
71
+ }
72
+ }
73
+ return out.sort();
74
+ }
75
+ function sha256File(filePath) {
76
+ return crypto.createHash("sha256").update(fs.readFileSync(filePath)).digest("hex");
77
+ }
78
+ function readSkillManifest(skillDir) {
79
+ try {
80
+ return coerceSkillManifest(JSON.parse(fs.readFileSync(path.join(skillDir, SKILL_MANIFEST_FILENAME), "utf-8")));
81
+ } catch {
82
+ return null;
83
+ }
84
+ }
85
+ function writeSkillManifest(skillDir, manifest) {
86
+ fs.writeFileSync(path.join(skillDir, SKILL_MANIFEST_FILENAME), `${JSON.stringify(manifest, null, 2)}
87
+ `, "utf-8");
88
+ }
89
+ function reconcileSkillTree(srcDir, destDir, manifest, force) {
90
+ const result = { added: [], updated: [], unchanged: [], conflicts: [], bundledHashes: /* @__PURE__ */ new Map() };
91
+ for (const rel of walkRelative(srcDir)) {
92
+ const srcPath = path.join(srcDir, rel);
93
+ const destPath = path.join(destDir, rel);
94
+ const bundledHash = sha256File(srcPath);
95
+ result.bundledHashes.set(rel, bundledHash);
96
+ const installedHash = fs.existsSync(destPath) ? sha256File(destPath) : void 0;
97
+ const state = classifySkillFile({ bundledHash, installedHash, manifestHash: manifest?.files[rel] });
98
+ switch (state) {
99
+ case "missing":
100
+ fs.mkdirSync(path.dirname(destPath), { recursive: true });
101
+ fs.copyFileSync(srcPath, destPath);
102
+ result.added.push(rel);
103
+ break;
104
+ case "unchanged":
105
+ result.unchanged.push(rel);
106
+ break;
107
+ case "stale":
108
+ fs.copyFileSync(srcPath, destPath);
109
+ result.updated.push(rel);
110
+ break;
111
+ case "edited":
112
+ if (force) {
113
+ fs.copyFileSync(srcPath, destPath);
114
+ result.updated.push(rel);
115
+ } else {
116
+ result.conflicts.push(rel);
117
+ }
118
+ break;
119
+ }
120
+ }
121
+ return result;
122
+ }
123
+ function buildManifest(skillName, recon, prior) {
124
+ const conflicts = new Set(recon.conflicts);
125
+ const files = {};
126
+ for (const [rel, bundledHash] of recon.bundledHashes) {
127
+ files[rel] = conflicts.has(rel) ? prior?.files[rel] ?? bundledHash : bundledHash;
128
+ }
129
+ return { skill: skillName, version: PACKAGE_VERSION, files };
130
+ }
131
+ function describeChanges(recon) {
132
+ const parts = [];
133
+ if (recon.added.length > 0) parts.push(`${recon.added.length} added`);
134
+ if (recon.updated.length > 0) parts.push(`${recon.updated.length} refreshed`);
135
+ return parts.length > 0 ? parts.join(", ") : "no changes";
136
+ }
137
+ function buildClaudeMessage(name, status, recon) {
138
+ const rel = `.claude/skills/${name}`;
139
+ let message = status === "installed" ? `Installed ${rel}` : status === "updated" ? `Updated ${rel} (${describeChanges(recon)})` : `Already installed: ${rel}`;
140
+ if (recon.conflicts.length > 0) {
141
+ message += ` \u2014 ${recon.conflicts.length} file(s) differ from the bundle (local edits kept; pass --force to overwrite)`;
142
+ }
143
+ return message;
144
+ }
145
+ function installClaudeSkill(skill, targetDir, force) {
146
+ const targetPath = path.join(targetDir, ".claude", "skills", skill.name);
147
+ const existedBefore = fs.existsSync(path.join(targetPath, "SKILL.md"));
148
+ const priorManifest = readSkillManifest(targetPath);
149
+ fs.mkdirSync(targetPath, { recursive: true });
150
+ const recon = reconcileSkillTree(skill.bundledPath, targetPath, priorManifest, force);
151
+ writeSkillManifest(targetPath, buildManifest(skill.name, recon, priorManifest));
152
+ const changed = recon.added.length + recon.updated.length;
153
+ const status = !existedBefore ? "installed" : changed > 0 ? "updated" : "already-installed";
154
+ return {
155
+ skill: skill.name,
156
+ client: CodingAgents.claude,
157
+ targetPath,
158
+ status,
159
+ message: buildClaudeMessage(skill.name, status, recon),
160
+ added: recon.added,
161
+ updated: recon.updated,
162
+ unchanged: recon.unchanged,
163
+ conflicts: recon.conflicts
164
+ };
165
+ }
166
+ function installCodexSymlink(skill, targetDir, force) {
167
+ const codexPath = path.join(targetDir, ".codex", "skills", skill.name);
168
+ const claudePath = path.join(targetDir, ".claude", "skills", skill.name);
169
+ const linkTarget = path.relative(path.dirname(codexPath), claudePath);
170
+ fs.mkdirSync(path.dirname(codexPath), { recursive: true });
171
+ let stat;
172
+ try {
173
+ stat = fs.lstatSync(codexPath);
174
+ } catch {
175
+ stat = void 0;
176
+ }
177
+ if (stat?.isSymbolicLink()) {
178
+ const existing = fs.readlinkSync(codexPath);
179
+ if (existing === linkTarget) {
180
+ return {
181
+ skill: skill.name,
182
+ client: CodingAgents.codex,
183
+ targetPath: codexPath,
184
+ status: "already-linked",
185
+ message: `Already linked: .codex/skills/${skill.name}`
186
+ };
187
+ }
188
+ if (!force) {
189
+ throw new CliError({
190
+ code: "VALIDATION_ERROR",
191
+ message: `.codex/skills/${skill.name} is a symlink pointing elsewhere (${existing}). Pass --force to relink.`,
192
+ details: { skill: skill.name, targetPath: codexPath, existingTarget: existing },
193
+ exitCode: 1
194
+ });
195
+ }
196
+ fs.unlinkSync(codexPath);
197
+ fs.symlinkSync(linkTarget, codexPath);
198
+ return {
199
+ skill: skill.name,
200
+ client: CodingAgents.codex,
201
+ targetPath: codexPath,
202
+ status: "relinked",
203
+ message: `Relinked .codex/skills/${skill.name} \u2192 ${linkTarget}`
204
+ };
205
+ }
206
+ if (stat) {
207
+ if (!force) {
208
+ throw new CliError({
209
+ code: "VALIDATION_ERROR",
210
+ message: `.codex/skills/${skill.name} exists but is not a symlink. Pass --force to replace.`,
211
+ details: { skill: skill.name, targetPath: codexPath },
212
+ exitCode: 1
213
+ });
214
+ }
215
+ fs.rmSync(codexPath, { recursive: true, force: true });
216
+ }
217
+ fs.symlinkSync(linkTarget, codexPath);
218
+ return {
219
+ skill: skill.name,
220
+ client: CodingAgents.codex,
221
+ targetPath: codexPath,
222
+ status: stat ? "relinked" : "linked",
223
+ message: stat ? `Replaced and linked .codex/skills/${skill.name} \u2192 ${linkTarget}` : `Linked .codex/skills/${skill.name} \u2192 ${linkTarget}`
224
+ };
225
+ }
226
+ function buildSummaryMessage(results) {
227
+ const counts = {};
228
+ for (const r of results) counts[r.status] = (counts[r.status] ?? 0) + 1;
229
+ const parts = Object.entries(counts).map(([status, n]) => `${n} ${status}`);
230
+ let message = `Skills install summary: ${parts.join(", ")}.`;
231
+ const totalConflicts = results.reduce((sum, r) => sum + (r.conflicts?.length ?? 0), 0);
232
+ if (totalConflicts > 0) {
233
+ message += ` ${totalConflicts} file(s) differ from the bundle and were kept \u2014 pass --force to overwrite local edits.`;
234
+ }
235
+ return message;
236
+ }
237
+ function getBundledSkillSnapshots(pkgDir) {
238
+ return getBundledSkills(pkgDir).map((skill) => {
239
+ const files = {};
240
+ for (const rel of walkRelative(skill.bundledPath)) {
241
+ files[rel] = sha256File(path.join(skill.bundledPath, rel));
242
+ }
243
+ return {
244
+ name: skill.name,
245
+ version: PACKAGE_VERSION,
246
+ files,
247
+ description: readBundledSkillDescription(skill.bundledPath)
248
+ };
249
+ });
250
+ }
251
+ function readBundledSkillDescription(skillDir) {
252
+ let raw;
253
+ try {
254
+ raw = fs.readFileSync(path.join(skillDir, "SKILL.md"), "utf-8");
255
+ } catch {
256
+ return void 0;
257
+ }
258
+ const parts = raw.split("---");
259
+ if (parts.length < 3) return void 0;
260
+ const lines = (parts[1] ?? "").split("\n");
261
+ const collected = [];
262
+ let inside = false;
263
+ for (const line of lines) {
264
+ const isTopLevelKey = /^[a-z][\w-]*:/i.test(line);
265
+ if (inside && isTopLevelKey) break;
266
+ if (isTopLevelKey && line.startsWith("description:")) {
267
+ inside = true;
268
+ collected.push(line.slice("description:".length).trim());
269
+ continue;
270
+ }
271
+ if (inside) collected.push(line.trim());
272
+ }
273
+ if (!inside) return void 0;
274
+ const value = collected.join(" ").trim();
275
+ const unquoted = value.length >= 2 && value.startsWith('"') && value.endsWith('"') ? value.slice(1, -1) : value;
276
+ return unquoted.length > 0 ? unquoted : void 0;
277
+ }
278
+ async function installSkills(opts = {}) {
279
+ const targetDir = opts.user ? os.homedir() : path.resolve(opts.dir ?? process.cwd());
280
+ const client = opts.client ?? SkillsClients.all;
281
+ const force = opts.force ?? false;
282
+ const allSkills = getBundledSkills();
283
+ const requestedNames = opts.skills && opts.skills.length > 0 ? opts.skills : allSkills.map((s) => s.name);
284
+ const knownNames = new Set(allSkills.map((s) => s.name));
285
+ const unknown = requestedNames.filter((n) => !knownNames.has(n));
286
+ if (unknown.length > 0) {
287
+ throw new CliError({
288
+ code: "VALIDATION_ERROR",
289
+ message: `Unknown skill(s): ${unknown.join(", ")}. Available: ${[...knownNames].join(", ")}`,
290
+ details: { unknownSkills: unknown, availableSkills: [...knownNames] },
291
+ exitCode: 1
292
+ });
293
+ }
294
+ const skillsToInstall = allSkills.filter((s) => requestedNames.includes(s.name));
295
+ fs.mkdirSync(targetDir, { recursive: true });
296
+ const results = [];
297
+ for (const skill of skillsToInstall) {
298
+ results.push(installClaudeSkill(skill, targetDir, force));
299
+ if (client !== SkillsClients.claude) {
300
+ results.push(installCodexSymlink(skill, targetDir, force));
301
+ }
302
+ }
303
+ return {
304
+ targetDir,
305
+ results,
306
+ message: buildSummaryMessage(results)
307
+ };
308
+ }
309
+ async function listSkills(opts = {}) {
310
+ const skills = getBundledSkills();
311
+ if (isMachineFormat(opts.format)) {
312
+ console.log(JSON.stringify({
313
+ skills: skills.map((s) => ({
314
+ name: s.name,
315
+ description: s.description,
316
+ claudePath: `.claude/skills/${s.name}`,
317
+ codexPath: `.codex/skills/${s.name}`
318
+ }))
319
+ }, null, 2));
320
+ return;
321
+ }
322
+ console.log("Bundled canonry skills:\n");
323
+ for (const skill of skills) {
324
+ console.log(` ${skill.name}`);
325
+ if (skill.description) console.log(` ${skill.description}`);
326
+ console.log(` Claude: .claude/skills/${skill.name}/`);
327
+ console.log(` Codex: .codex/skills/${skill.name} (symlink \u2192 ../../.claude/skills/${skill.name})`);
328
+ console.log();
329
+ }
330
+ }
331
+ function emitInstallSummary(summary, format) {
332
+ if (isMachineFormat(format)) {
333
+ console.log(JSON.stringify(summary, null, 2));
334
+ return;
335
+ }
336
+ for (const r of summary.results) console.log(r.message);
337
+ console.log(`
338
+ Target: ${summary.targetDir}`);
339
+ console.log(summary.message);
340
+ }
341
+ function shouldPrintServeSkillsNudge(nudge, updateAvailable) {
342
+ if (!nudge) return false;
343
+ if (nudge.source === "plugin" && updateAvailable) return false;
344
+ return true;
345
+ }
346
+ function getMissingUserSkillsNudge(home, agentPlugin) {
347
+ if (!home) return null;
348
+ const skillsBase = path.join(home, ".claude", "skills");
349
+ const installed = [];
350
+ const missing = [];
351
+ for (const name of BUNDLED_SKILL_NAMES) {
352
+ const skillFile = path.join(skillsBase, name, "SKILL.md");
353
+ if (existsSafe(skillFile)) installed.push(name);
354
+ else missing.push(name);
355
+ }
356
+ if (agentPlugin && agentPlugin.configuredClients.length > 0) {
357
+ const unverifiedClients = agentPlugin.configuredClients.filter((client) => !agentPlugin.verifiedClients.includes(client));
358
+ const mismatchedClients = agentPlugin.verifiedClients.filter((client) => agentPlugin.verifiedClientVersions?.[client] !== PACKAGE_VERSION);
359
+ if (unverifiedClients.length === 0 && mismatchedClients.length === 0) return null;
360
+ const displayClients = (clients) => clients.map((client) => agentPluginClientLabel(client)).join(" + ");
361
+ const problems = [];
362
+ if (unverifiedClients.length > 0) {
363
+ problems.push(`The Canonry plugin is enabled for ${displayClients(unverifiedClients)}, but its cached manifest and skill assets could not be verified.`);
364
+ }
365
+ if (mismatchedClients.length > 0) {
366
+ problems.push(`${formatCanonryPluginVersionMismatch({
367
+ mismatchedClients,
368
+ verifiedClientVersions: agentPlugin.verifiedClientVersions,
369
+ runningVersion: PACKAGE_VERSION
370
+ })}.`);
371
+ }
372
+ const hintClients = [.../* @__PURE__ */ new Set([...unverifiedClients, ...mismatchedClients])];
373
+ return {
374
+ message: `Tip: ${problems.join(" ")} ${formatCanonryPluginUpdateHint(hintClients)}`,
375
+ source: "plugin",
376
+ missing,
377
+ installed
378
+ };
379
+ }
380
+ if (missing.length === 0) return null;
381
+ const fix = missing.length === BUNDLED_SKILL_NAMES.length ? "canonry skills install --user" : `canonry skills install ${missing.join(" ")} --user`;
382
+ return {
383
+ message: `Tip: ${missing.join(" + ")} skill${missing.length === 1 ? "" : "s"} not installed in ~/.claude/skills/. Run \`${fix}\` so Claude/Codex sessions on this host auto-load the canonry reference docs.`,
384
+ source: "legacy-skills",
385
+ missing,
386
+ installed
387
+ };
388
+ }
389
+ function existsSafe(p) {
390
+ try {
391
+ return fs.existsSync(p);
392
+ } catch {
393
+ return false;
394
+ }
395
+ }
396
+ function parseSkillsClient(value) {
397
+ if (!value) return SkillsClients.all;
398
+ const parsed = skillsClientSchema.safeParse(value);
399
+ if (parsed.success) return parsed.data;
400
+ const allowed = skillsClientSchema.options;
401
+ throw new CliError({
402
+ code: "VALIDATION_ERROR",
403
+ message: `Invalid --client value "${value}". Must be one of: ${allowed.join(", ")}`,
404
+ details: { flag: "client", value, allowed },
405
+ exitCode: 1
406
+ });
407
+ }
408
+
409
+ export {
410
+ BUNDLED_SKILL_NAMES,
411
+ resolveBundledSkillsRoot,
412
+ getBundledSkills,
413
+ getBundledSkillSnapshots,
414
+ installSkills,
415
+ listSkills,
416
+ emitInstallSummary,
417
+ shouldPrintServeSkillsNudge,
418
+ getMissingUserSkillsNudge,
419
+ parseSkillsClient
420
+ };
@@ -0,0 +1,18 @@
1
+ // src/serve-endpoint.ts
2
+ function resolveServePort(envPort, configPort) {
3
+ const trimmed = envPort?.trim();
4
+ if (trimmed) return parseInt(trimmed, 10);
5
+ return configPort ?? 4100;
6
+ }
7
+ function isLoopbackBindHost(host) {
8
+ if (host == null || host === "") return true;
9
+ const normalized = host.trim().toLowerCase().replace(/^\[|\]$/g, "");
10
+ if (normalized === "localhost" || normalized === "::1") return true;
11
+ if (/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(normalized)) return true;
12
+ return false;
13
+ }
14
+
15
+ export {
16
+ resolveServePort,
17
+ isLoopbackBindHost
18
+ };