@archme/cli 0.5.1 → 0.5.3

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/cli.js +46 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -9964,6 +9964,23 @@ var init_classifyOutcome = __esm({
9964
9964
  }
9965
9965
  });
9966
9966
 
9967
+ // src/daemon/heartbeatHealth.ts
9968
+ function classifyHeartbeat(error, row) {
9969
+ if (error) return { kind: "error", message: error.message ?? "unknown error" };
9970
+ if (row == null) {
9971
+ return {
9972
+ kind: "disowned",
9973
+ message: "lease is no longer held by this worker (reaped or re-claimed) \u2014 this run will not count"
9974
+ };
9975
+ }
9976
+ return { kind: "ok" };
9977
+ }
9978
+ var init_heartbeatHealth = __esm({
9979
+ "src/daemon/heartbeatHealth.ts"() {
9980
+ "use strict";
9981
+ }
9982
+ });
9983
+
9967
9984
  // node_modules/balanced-match/dist/esm/index.js
9968
9985
  var balanced, maybeMatch, range;
9969
9986
  var init_esm = __esm({
@@ -13050,6 +13067,18 @@ async function outlineSource(source, file) {
13050
13067
  data: { file, symbols: [] }
13051
13068
  });
13052
13069
  }
13070
+ const bytes = Buffer.byteLength(source, "utf8");
13071
+ if (bytes >= MAX_PARSE_BYTES) {
13072
+ return envelope({
13073
+ tool: "file",
13074
+ tier: 0,
13075
+ confidence: 0.2,
13076
+ data: { file, symbols: [] },
13077
+ warnings: [
13078
+ `${file} is too large to parse (${bytes} bytes >= ${MAX_PARSE_BYTES}); file-tier only`
13079
+ ]
13080
+ });
13081
+ }
13053
13082
  try {
13054
13083
  const symbols = await extractSymbols(lang, source);
13055
13084
  return envelope({
@@ -13092,12 +13121,14 @@ async function runOutline(file) {
13092
13121
  }
13093
13122
  return outlineSource(source, file);
13094
13123
  }
13124
+ var MAX_PARSE_BYTES;
13095
13125
  var init_outline = __esm({
13096
13126
  "src/analyze/commands/outline.ts"() {
13097
13127
  "use strict";
13098
13128
  init_lang_detect();
13099
13129
  init_symbols();
13100
13130
  init_output2();
13131
+ MAX_PARSE_BYTES = 1e6;
13101
13132
  }
13102
13133
  });
13103
13134
 
@@ -14115,7 +14146,7 @@ async function cmdDiff(args) {
14115
14146
  );
14116
14147
  return 0;
14117
14148
  }
14118
- async function augmentChangesWithSymbolsAtSha(changes, after, cwd) {
14149
+ async function augmentChangesWithSymbolsAtSha(changes, after, cwd, onFile) {
14119
14150
  const warnings = [];
14120
14151
  for (const change of changes) {
14121
14152
  if (change.status === "deleted") continue;
@@ -14127,6 +14158,7 @@ async function augmentChangesWithSymbolsAtSha(changes, after, cwd) {
14127
14158
  maxBuffer: 1e7
14128
14159
  });
14129
14160
  if (result.exitCode === 0) {
14161
+ onFile?.(change.path, Buffer.byteLength(result.stdout, "utf8"));
14130
14162
  try {
14131
14163
  const outline = await outlineSource(result.stdout, change.path);
14132
14164
  symbols = outline.data.symbols;
@@ -14136,6 +14168,7 @@ async function augmentChangesWithSymbolsAtSha(changes, after, cwd) {
14136
14168
  }
14137
14169
  if (!symbols) {
14138
14170
  try {
14171
+ onFile?.(change.path, null);
14139
14172
  const outline = await runOutline(resolve(cwd, change.path));
14140
14173
  symbols = outline.data.symbols;
14141
14174
  if (after) {
@@ -16141,7 +16174,7 @@ async function rpcClaim(ctx, deviceId) {
16141
16174
  }
16142
16175
  async function rpcHeartbeat(ctx, jobId, deviceId) {
16143
16176
  if (!deviceId) return;
16144
- const { error } = await withAuthRetry(
16177
+ const { data, error } = await withAuthRetry(
16145
16178
  `[${jobId}] heartbeat`,
16146
16179
  () => ctx.supabase.rpc("heartbeat_archme_job", {
16147
16180
  p_job_id: jobId,
@@ -16151,7 +16184,8 @@ async function rpcHeartbeat(ctx, jobId, deviceId) {
16151
16184
  }),
16152
16185
  ctx.reLogin
16153
16186
  );
16154
- if (error) console.error(`[${jobId}] heartbeat error:`, error.message);
16187
+ const verdict = classifyHeartbeat(error, data);
16188
+ if (verdict.kind !== "ok") console.error(`[${jobId}] heartbeat ${verdict.kind}: ${verdict.message}`);
16155
16189
  }
16156
16190
  async function rpcComplete(ctx, jobId, deviceId, summary2, kind, changed, metrics, logs, advanceMarker = true, affected) {
16157
16191
  const extra = {
@@ -16591,7 +16625,13 @@ async function runJob(ctx, job, claimDeviceId) {
16591
16625
  const changedSymbolsByFile = /* @__PURE__ */ new Map();
16592
16626
  try {
16593
16627
  const { changes } = await runDiff(diff.range, repoDir);
16594
- await augmentChangesWithSymbolsAtSha(changes, diff.after, repoDir);
16628
+ logPhase(job.id, "seed_start", { files: changes.length });
16629
+ await augmentChangesWithSymbolsAtSha(
16630
+ changes,
16631
+ diff.after,
16632
+ repoDir,
16633
+ (path7, bytes2) => log(`parse ${path7}${bytes2 == null ? "" : ` bytes=${bytes2}`}`)
16634
+ );
16595
16635
  for (const change of changes) {
16596
16636
  if (change.status === "deleted") continue;
16597
16637
  const ann = change;
@@ -16607,6 +16647,7 @@ async function runJob(ctx, job, claimDeviceId) {
16607
16647
  const affected = resolveAffected(seedArch, diff.changedFiles, changedSymbolsByFile);
16608
16648
  affectedForComplete = affected;
16609
16649
  const symbolsInFile = async (file) => {
16650
+ log(`parse ${file} (removed-symbol scan)`);
16610
16651
  const outline = await runOutline(join18(worktreeDir, file));
16611
16652
  if (outline.tier !== 2) return null;
16612
16653
  return outline.data.symbols.map((s) => s.name);
@@ -17196,6 +17237,7 @@ var init_run = __esm({
17196
17237
  init_model_pin();
17197
17238
  init_digest();
17198
17239
  init_classifyOutcome();
17240
+ init_heartbeatHealth();
17199
17241
  init_affected();
17200
17242
  init_scanPrompts();
17201
17243
  init_storyGranularity();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archme/cli",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Map your codebase into a living architecture diagram: run `archme init` in a repo to scan it, `archme daemon start` to keep it current on every commit.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",