@earntori/cli 0.2.18 → 0.2.20

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/index.js +21 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -56,7 +56,7 @@ function out(o, human) { console.log(json ? JSON.stringify(o, null, 2) : human);
56
56
  function die(msg) { console.error(json ? JSON.stringify({ error: msg }) : `\u2717 ${msg}`); process.exit(1); }
57
57
  const usd = (c) => `$${(c / 100).toFixed(2)}`;
58
58
  async function api(cfg, method, path, body) {
59
- const r = await fetch(`${cfg.base}${path}`, { method, headers: { Authorization: `Bearer ${cfg.token}`, "Content-Type": "application/json", "User-Agent": "@earntori/cli/0.2.10" }, body: body ? JSON.stringify(body) : undefined });
59
+ const r = await fetch(`${cfg.base}${path}`, { method, headers: { Authorization: `Bearer ${cfg.token}`, "Content-Type": "application/json", "User-Agent": userAgent() }, body: body ? JSON.stringify(body) : undefined });
60
60
  const t = await r.text();
61
61
  let j = null;
62
62
  try {
@@ -163,7 +163,7 @@ function writeJson(p, o) { mkdirSync(dirname(resolve(p)), { recursive: true });
163
163
  // `install` writes that harness's files and returns their paths. Add a harness = add a row.
164
164
  // Pinned package versions written into agent config (B1b). CLI version = this package's own;
165
165
  // MCP version is a constant: bump it in the same commit as a @earntori/mcp release.
166
- const TORI_MCP_VERSION = "0.1.9";
166
+ const TORI_MCP_VERSION = "0.1.12";
167
167
  function cliVersion(cliBin) {
168
168
  try {
169
169
  return JSON.parse(readFileSync(resolve(dirname(realpathSync(cliBin)), "..", "package.json"), "utf8")).version ?? "latest";
@@ -172,6 +172,13 @@ function cliVersion(cliBin) {
172
172
  return "latest";
173
173
  }
174
174
  }
175
+ /** Spec rev 97: the User-Agent carries this package's own version, read once per process. */
176
+ let uaCache;
177
+ function userAgent() {
178
+ if (!uaCache)
179
+ uaCache = `@earntori/cli/${cliVersion(resolve(process.argv[1] ?? ""))}`;
180
+ return uaCache;
181
+ }
175
182
  const withHarness = (mcp, id) => ({ ...mcp, env: { TORI_HARNESS: id } });
176
183
  function mergeMcpJson(file, mcp) { const j = readJson(file) ?? {}; j.mcpServers = { ...(j.mcpServers ?? {}), tori: mcp }; writeJson(file, j); return file; }
177
184
  function hookPresent(h, c) { return typeof h?.command === "string" && (/@earntori\/cli(@[^\s]+)? check/.test(h.command) || (c.local && h.command.includes(c.cliBin))); }
@@ -296,12 +303,18 @@ function repoIndex() { try {
296
303
  catch {
297
304
  return undefined;
298
305
  } }
299
- function envExample() { try {
300
- return existsSync(".env.example") ? readFileSync(".env.example", "utf8").slice(0, 20000) : undefined;
306
+ /** Spec rev 97, corrected by rev 99 (amends rev 86): `.env.example` is skipped when it matches an ignore
307
+ * pattern; otherwise it is sent as before (up to 20,000 characters). */
308
+ function envExample() {
309
+ try {
310
+ if (!existsSync(".env.example") || isIgnored(".env.example", ignorePatterns(process.cwd())))
311
+ return undefined;
312
+ return readFileSync(".env.example", "utf8").slice(0, 20000);
313
+ }
314
+ catch {
315
+ return undefined;
316
+ }
301
317
  }
302
- catch {
303
- return undefined;
304
- } }
305
318
  const CODE_EXT = /\.(ts|tsx|js|jsx|mjs|cjs|py|go|rb|php|java|kt|cs)$/i;
306
319
  function projectId() {
307
320
  try {
@@ -446,7 +459,7 @@ async function check() {
446
459
  try {
447
460
  const body0 = { files, project: projectId(), repo_index: repoIndex(), env_example: envExample() };
448
461
  dbg(`request: ${JSON.stringify(body0).length} bytes, index ${body0.repo_index?.length ?? 0} paths -> ${cfg.base}`);
449
- const res = await fetch(`${cfg.base}/api/v1/checks/run`, { method: "POST", headers: { Authorization: `Bearer ${cfg.token}`, "Content-Type": "application/json", "User-Agent": "@earntori/cli/check" }, body: JSON.stringify(body0) });
462
+ const res = await fetch(`${cfg.base}/api/v1/checks/run`, { method: "POST", headers: { Authorization: `Bearer ${cfg.token}`, "Content-Type": "application/json", "User-Agent": userAgent() }, body: JSON.stringify(body0) });
450
463
  dbg(`response: ${res.status}`);
451
464
  const t = await res.text();
452
465
  if (!res.ok)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earntori/cli",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "Tori CLI — holds your coding agent to a standard: checks before it calls a task done, each finding with its fix, on a signed record you can verify offline.",
5
5
  "license": "MIT",
6
6
  "type": "module",