threadctx 0.3.0 → 0.4.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.
Files changed (2) hide show
  1. package/dist/threadctx.mjs +53 -9
  2. package/package.json +11 -3
@@ -10852,6 +10852,7 @@ var LICENSE_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
10852
10852
  MCowBQYDK2VwAyEAjxD7a4Ug5yVw5+Ra8bY1IZVLobxeiCS9dtrVwekYjqw=
10853
10853
  -----END PUBLIC KEY-----
10854
10854
  `;
10855
+ var LICENSE_PLANS = ["audit", "team", "business", "agency"];
10855
10856
  var PREFIX = "tctx1";
10856
10857
  function verifyLicense(key, opts = {}) {
10857
10858
  const parts = key.trim().split(".");
@@ -10866,11 +10867,18 @@ function verifyLicense(key, opts = {}) {
10866
10867
  } catch {
10867
10868
  return { ok: false, reason: "malformed" };
10868
10869
  }
10869
- if (claims.v !== 1 || typeof claims.exp !== "number" || typeof claims.org !== "string" || !["audit", "team", "business"].includes(claims.plan))
10870
+ if (claims.v !== 1 || typeof claims.exp !== "number" || typeof claims.org !== "string" || !LICENSE_PLANS.includes(claims.plan))
10871
+ return { ok: false, reason: "unsupported" };
10872
+ if (claims.agentRepoLimit !== void 0 && (!Number.isInteger(claims.agentRepoLimit) || claims.agentRepoLimit < 1))
10873
+ return { ok: false, reason: "unsupported" };
10874
+ if (claims.orgs !== void 0 && (!Array.isArray(claims.orgs) || claims.orgs.some((o) => typeof o !== "string")))
10870
10875
  return { ok: false, reason: "unsupported" };
10871
10876
  if (claims.exp * 1e3 < (opts.now ?? /* @__PURE__ */ new Date()).getTime())
10872
10877
  return { ok: false, reason: "expired" };
10873
- if (opts.org && claims.org !== "*" && claims.org !== opts.org.trim().toLowerCase())
10878
+ const want = opts.org?.trim().toLowerCase();
10879
+ if (want && claims.orgs?.length && !claims.orgs.includes(want))
10880
+ return { ok: false, reason: "wrong-org" };
10881
+ if (want && !claims.orgs?.length && claims.org !== "*" && claims.org !== want)
10874
10882
  return { ok: false, reason: "wrong-org" };
10875
10883
  return { ok: true, claims };
10876
10884
  }
@@ -14576,7 +14584,7 @@ var S002 = {
14576
14584
  report({
14577
14585
  path: first.artifact.path,
14578
14586
  line: 1,
14579
- message: hasAgents ? `${tools.length} tools have their own context files (${names}), and ${isolatedNames.join(" and ")} ${isolatedNames.length === 1 ? "does" : "do"} not read AGENTS.md. Their copies will drift.` : `${tools.length} tools have their own context files (${names}) with no shared source. Their copies will drift.`,
14587
+ message: hasAgents ? `${tools.length} tools have their own context files (${names}), and ${isolatedNames.join(" and ")} ${isolatedNames.length === 1 ? "does" : "do"} not read AGENTS.md. Their copies can drift apart.` : `${tools.length} tools have their own context files (${names}) with no shared source. Their copies can drift apart.`,
14580
14588
  evidence: isolated.map((t) => t.files.map((f) => f.artifact.path).join(", ")).join("; "),
14581
14589
  fingerprintKey: names,
14582
14590
  fix: hasAgents && isolated.some((t) => t.tool === "claude-code") && ctx.catalog.get("CLAUDE.md") ? { kind: "suggested", description: "Import AGENTS.md from CLAUDE.md so Claude Code reads the shared instructions.", edits: [{ path: "CLAUDE.md", startLine: 1, endLine: 0, replacement: "@AGENTS.md\n" }] } : void 0
@@ -14731,7 +14739,7 @@ function applySuppressions(findings, inline, config, now, diagnostics) {
14731
14739
  }
14732
14740
 
14733
14741
  // ../rules/dist/version.js
14734
- var ENGINE_VERSION = "0.3.0";
14742
+ var ENGINE_VERSION = "0.4.1";
14735
14743
  var REGISTRY_VERSION = "2026.10.1";
14736
14744
 
14737
14745
  // ../rules/dist/engine.js
@@ -15498,6 +15506,10 @@ function renderText(result, opts) {
15498
15506
  if (tools.length) {
15499
15507
  out.push(p.dim(`Always-loaded context (estimated tokens): ${tools.map((t) => `${t.label.split(" (")[0]} \u2248${t.alwaysTokenEstimate.toLocaleString("en-US")}`).join(" \xB7 ")}`));
15500
15508
  }
15509
+ if (opts.next?.length) {
15510
+ const width = Math.max(...opts.next.map(([cmd]) => cmd.length));
15511
+ out.push("", p.bold("Next"), ...opts.next.map(([cmd, why]) => ` ${p.cyan(cmd.padEnd(width))} ${p.dim(why)}`));
15512
+ }
15501
15513
  for (const d of result.diagnostics) {
15502
15514
  const tag = d.level === "error" ? p.red("error") : d.level === "warning" ? p.yellow("note") : p.dim("note");
15503
15515
  out.push(`${tag} ${d.path ? `${d.path}${d.line ? `:${d.line}` : ""}: ` : ""}${d.message}`);
@@ -15536,6 +15548,10 @@ function renderMarkdown(result, opts = {}) {
15536
15548
  out.push(`- ${t.label}: \u2248${t.alwaysTokenEstimate.toLocaleString("en-US")} tokens across ${t.layers} file${t.layers === 1 ? "" : "s"}`);
15537
15549
  out.push("", "</details>");
15538
15550
  }
15551
+ if (opts.orgAuditOwner !== void 0) {
15552
+ const owner = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/.test(opts.orgAuditOwner) ? opts.orgAuditOwner : "<your-org>";
15553
+ out.push("", `See every repository in your organisation: \`npx threadctx audit --org ${owner}\` (free summary).`);
15554
+ }
15539
15555
  out.push("", `<sub>[threadctx](https://threadctx.dev) ${result.engine.version}${opts.footerUrl ? ` \xB7 [history and badge](${opts.footerUrl})` : ""} \xB7 [how grades work](https://threadctx.dev/methodology)</sub>`);
15540
15556
  return `${out.join("\n")}
15541
15557
  `;
@@ -16152,7 +16168,7 @@ function planFixes(fs, findings, kinds = ["safe"]) {
16152
16168
  }
16153
16169
 
16154
16170
  // src/init.ts
16155
- var ACTION_PIN = { sha: "0c480a0bede1629f6156e04ae0d047b171ddc1f2", tag: "v1.2.1" };
16171
+ var ACTION_PIN = { sha: "22e0830658b62f2ca8b8d41f7e4d9477d6942e62", tag: "v1.4.0" };
16156
16172
  var CHECKOUT_PIN = { sha: "3d3c42e5aac5ba805825da76410c181273ba90b1", tag: "v7.0.1" };
16157
16173
  var WORKFLOW_PATH = ".github/workflows/agent-context.yml";
16158
16174
  function workflowYaml() {
@@ -16485,7 +16501,9 @@ function findLicense(arg, io) {
16485
16501
  }
16486
16502
  function describeLicense(claims) {
16487
16503
  const days = Math.max(0, Math.ceil((claims.exp * 1e3 - Date.now()) / 864e5));
16488
- return `${claims.plan} licence for ${claims.org === "*" ? "any organisation" : claims.org}, ${days} day${days === 1 ? "" : "s"} left (id ${claims.id})`;
16504
+ const who = claims.orgs?.length ? claims.orgs.join(", ") : claims.org === "*" ? "any organisation" : claims.org;
16505
+ const limit = claims.agentRepoLimit ? `, up to ${claims.agentRepoLimit} agent repositories` : "";
16506
+ return `${claims.plan} licence for ${who}${limit}, ${days} day${days === 1 ? "" : "s"} left (id ${claims.id})`;
16489
16507
  }
16490
16508
  async function runAudit(o, io) {
16491
16509
  if (!ORG.test(o.org)) throw new AuditUsageError(`'${o.org}' is not a valid GitHub organisation or user name`);
@@ -16548,6 +16566,15 @@ async function runAudit(o, io) {
16548
16566
  summary.trend = fleetTrend(previous, summary);
16549
16567
  }
16550
16568
  const evidence = evidencePack(summary, repos);
16569
+ const agentRepos = summary.repos.withContext;
16570
+ if (claims?.agentRepoLimit && agentRepos > claims.agentRepoLimit) {
16571
+ io.stderr(`
16572
+ This organisation has ${agentRepos} agent repositories; your ${claims.plan} licence covers up to ${claims.agentRepoLimit}.
16573
+ Showing the free summary. Upgrade for the full report: https://threadctx.dev/pricing?org=${encodeURIComponent(o.org)}&repos=${agentRepos}
16574
+
16575
+ `);
16576
+ claims = void 0;
16577
+ }
16551
16578
  const files = [];
16552
16579
  if (claims) {
16553
16580
  const dir = resolve3(io.cwd, o.outDir ?? `threadctx-audit-${o.org}`);
@@ -16702,7 +16729,7 @@ async function main(argv, io) {
16702
16729
  return 2;
16703
16730
  }
16704
16731
  io.stderr(`threadctx: unexpected error: ${e.stack ?? e}
16705
- Please report this at https://github.com/threadctx-dev/ctx/issues
16732
+ Please report it at https://github.com/threadctx-dev/threadctx-cli/issues
16706
16733
  `);
16707
16734
  return 2;
16708
16735
  }
@@ -16809,7 +16836,7 @@ async function cmdScan(pathArg, v, io, color) {
16809
16836
  view = repo;
16810
16837
  result = doScan(repo, v, io);
16811
16838
  }
16812
- const out = format === "json" ? renderJson(result) : format === "sarif" ? renderSarif(result) : format === "md" ? renderMarkdown(result) : renderText(result, { color: v.output ? false : color, verbose: Boolean(v.verbose) });
16839
+ const out = format === "json" ? renderJson(result) : format === "sarif" ? renderSarif(result) : format === "md" ? renderMarkdown(result) : renderText(result, { color: v.output ? false : color, verbose: Boolean(v.verbose), next: !v.output && !remoteLabel ? nextSteps(result, v, io) : void 0 });
16813
16840
  if (v.output) {
16814
16841
  const dest = resolve4(io.cwd, v.output);
16815
16842
  mkdirSync3(dirname2(dest), { recursive: true });
@@ -16854,7 +16881,8 @@ function cmdCompare(baseFile, headFile, v, io) {
16854
16881
  if (format === "json") out = `${JSON.stringify({ base: c.base, head: c.head, added: c.added, fixed: c.fixed, existing: c.existing }, null, 2)}
16855
16882
  `;
16856
16883
  else if (format === "md") {
16857
- const md = renderMarkdown(head, { baseline: { grade: base.grade, score: base.score }, newFingerprints: new Set(c.added.map((f) => f.fingerprint)) });
16884
+ const owner = io.env.GITHUB_REPOSITORY_OWNER ?? io.env.GITHUB_REPOSITORY?.split("/")[0] ?? "";
16885
+ const md = renderMarkdown(head, { baseline: { grade: base.grade, score: base.score }, newFingerprints: new Set(c.added.map((f) => f.fingerprint)), orgAuditOwner: owner });
16858
16886
  out = c.fixed.length ? md.replace("\n<sub>", `
16859
16887
  \u2705 **${c.fixed.length} fixed** by this change.
16860
16888
 
@@ -17146,6 +17174,22 @@ function cmdPackValidate(file, io) {
17146
17174
  `);
17147
17175
  return 0;
17148
17176
  }
17177
+ function nextSteps(result, v, io) {
17178
+ if (!io.isTTY || io.env.CI || io.env.THREADCTX_NO_UPSELL || io.env.THREADCTX_NO_HINTS) return void 0;
17179
+ const open = result.findings.filter((f) => !f.suppressed);
17180
+ const out = [];
17181
+ const hidden = v.verbose ? [] : open.filter((f) => f.severity === "info");
17182
+ if (hidden.length) {
17183
+ const byRule = /* @__PURE__ */ new Map();
17184
+ for (const f of hidden) byRule.set(f.ruleId, (byRule.get(f.ruleId) ?? 0) + 1);
17185
+ const top = [...byRule].sort((a, b) => b[1] - a[1]).slice(0, 2).map(([id, n2]) => `${RULES.find((r) => r.id === id)?.title ?? id}${n2 > 1 ? ` (${n2})` : ""}`);
17186
+ out.push(["threadctx scan --verbose", `${hidden.length} hidden info finding${hidden.length === 1 ? "" : "s"}: ${top.join("; ")}`]);
17187
+ }
17188
+ if (result.tools.some((t) => t.layers > 0)) out.push(["threadctx explain <file>", "which files each agent loads for that file, in order, with token estimates"]);
17189
+ const fixable = open.filter((f) => f.fix?.kind === "safe").length;
17190
+ if (fixable) out.push(["threadctx fix --pr", `${fixable} safe fix${fixable === 1 ? "" : "es"} in one pull request`]);
17191
+ return out.length ? out : void 0;
17192
+ }
17149
17193
  var UPGRADE_URL = "https://threadctx.dev/pricing";
17150
17194
  function maybeUpgradeLine(result, io, remote) {
17151
17195
  if (!UPGRADE_URL || !io.isTTY || io.env.CI || io.env.THREADCTX_NO_UPSELL) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "threadctx",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "mcpName": "io.github.threadctx-dev/threadctx",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -20,6 +20,14 @@
20
20
  },
21
21
  "description": "Your coding agents' instructions are stale and copied across tools. See what each agent is told, grade it, and fix it. Zero dependencies.",
22
22
  "homepage": "https://threadctx.dev",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/threadctx-dev/threadctx-cli.git",
26
+ "directory": "packages/cli"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/threadctx-dev/threadctx-cli/issues"
30
+ },
23
31
  "keywords": [
24
32
  "agents",
25
33
  "ai",
@@ -40,10 +48,10 @@
40
48
  "dependencies": {},
41
49
  "devDependencies": {
42
50
  "diff": "^9.0.0",
43
- "@threadctx/adapters": "0.1.0",
44
- "@threadctx/discovery": "0.1.0",
45
51
  "@threadctx/core": "0.1.0",
52
+ "@threadctx/adapters": "0.1.0",
46
53
  "@threadctx/rules": "0.1.0",
54
+ "@threadctx/discovery": "0.1.0",
47
55
  "@threadctx/report": "0.1.0"
48
56
  },
49
57
  "scripts": {