@ainyc/canonry 4.8.0 → 4.10.1

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.
package/assets/index.html CHANGED
@@ -12,8 +12,8 @@
12
12
  <link rel="icon" type="image/png" sizes="32x32" href="./favicon-32.png" />
13
13
  <link rel="apple-touch-icon" href="./apple-touch-icon.png" />
14
14
  <title>Canonry</title>
15
- <script type="module" crossorigin src="./assets/index-C2ZxtVjD.js"></script>
16
- <link rel="stylesheet" crossorigin href="./assets/index-DAS6pOry.css">
15
+ <script type="module" crossorigin src="./assets/index-BdAFw2Gy.js"></script>
16
+ <link rel="stylesheet" crossorigin href="./assets/index-CGXCbiM_.css">
17
17
  </head>
18
18
  <body>
19
19
  <div id="root"></div>
@@ -12,7 +12,7 @@ import {
12
12
  queryGenerateRequestSchema,
13
13
  runTriggerRequestSchema,
14
14
  scheduleUpsertRequestSchema
15
- } from "./chunk-IJEP6LB4.js";
15
+ } from "./chunk-GPJ3GLOE.js";
16
16
 
17
17
  // src/config.ts
18
18
  import fs from "fs";
@@ -2042,6 +2042,73 @@ function reportConfidenceLabel(confidence) {
2042
2042
  }
2043
2043
  }
2044
2044
 
2045
+ // ../contracts/src/report-dedup.ts
2046
+ var REPORT_INTENT_STOPWORDS = /* @__PURE__ */ new Set([
2047
+ "a",
2048
+ "an",
2049
+ "and",
2050
+ "for",
2051
+ "from",
2052
+ "in",
2053
+ "near",
2054
+ "of",
2055
+ "on",
2056
+ "or",
2057
+ "the",
2058
+ "to"
2059
+ ]);
2060
+ function tokenizeReportIntent(value) {
2061
+ return value.toLowerCase().match(/[a-z0-9]+/g) ?? [];
2062
+ }
2063
+ function normalizeReportIntentToken(token) {
2064
+ if (token.length > 4 && token.endsWith("ies")) return `${token.slice(0, -3)}y`;
2065
+ if (token.length > 4 && token.endsWith("s") && !token.endsWith("ss")) return token.slice(0, -1);
2066
+ return token;
2067
+ }
2068
+ function reportIntentModifiers(report) {
2069
+ const location = report.meta.location;
2070
+ if (!location) return /* @__PURE__ */ new Set();
2071
+ return new Set(
2072
+ [location.label, location.city, location.region, location.country].flatMap(tokenizeReportIntent).map(normalizeReportIntentToken).filter(Boolean)
2073
+ );
2074
+ }
2075
+ function reportIntentKey(value, modifiers) {
2076
+ const tokens = tokenizeReportIntent(value).map(normalizeReportIntentToken).filter(Boolean).filter((token) => !REPORT_INTENT_STOPWORDS.has(token)).filter((token) => !modifiers.has(token));
2077
+ return [...new Set(tokens)].sort().join(" ");
2078
+ }
2079
+ function extractActionQuery(action) {
2080
+ return action.title.match(/"([^"]+)"/)?.[1] ?? action.successMetric.match(/"([^"]+)"/)?.[1] ?? action.title;
2081
+ }
2082
+ function dedupeReportActions(report, actions) {
2083
+ const modifiers = reportIntentModifiers(report);
2084
+ if (actions.length <= 1 || modifiers.size === 0) return [...actions];
2085
+ const seen = /* @__PURE__ */ new Set();
2086
+ const result = [];
2087
+ for (const action of actions) {
2088
+ if (action.category !== "content") {
2089
+ result.push(action);
2090
+ continue;
2091
+ }
2092
+ const key = reportIntentKey(extractActionQuery(action), modifiers);
2093
+ if (!key || seen.has(key)) continue;
2094
+ seen.add(key);
2095
+ result.push(action);
2096
+ }
2097
+ return result;
2098
+ }
2099
+ function dedupeReportOpportunities(report) {
2100
+ const modifiers = reportIntentModifiers(report);
2101
+ const opportunities = report.contentOpportunities;
2102
+ if (opportunities.length <= 1 || modifiers.size === 0) return opportunities;
2103
+ const seen = /* @__PURE__ */ new Set();
2104
+ return opportunities.filter((opportunity) => {
2105
+ const key = reportIntentKey(opportunity.query, modifiers);
2106
+ if (!key || seen.has(key)) return false;
2107
+ seen.add(key);
2108
+ return true;
2109
+ });
2110
+ }
2111
+
2045
2112
  // ../contracts/src/skills.ts
2046
2113
  import { z as z19 } from "zod";
2047
2114
  var codingAgentSchema = z19.enum(["claude", "codex"]);
@@ -2134,6 +2201,8 @@ export {
2134
2201
  reportHorizonLabel,
2135
2202
  reportActionCategoryLabel,
2136
2203
  reportConfidenceLabel,
2204
+ dedupeReportActions,
2205
+ dedupeReportOpportunities,
2137
2206
  CodingAgents,
2138
2207
  skillsClientSchema,
2139
2208
  SkillsClients