commitshow 0.2.0 → 0.2.2

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.
@@ -27,7 +27,14 @@ export async function audit(args) {
27
27
  // already have the snapshot. Covers all full-audition projects.
28
28
  // --refresh / --force skips this entirely and goes straight to audit-preview
29
29
  // with force=true (counts against IP + URL + global rate limits).
30
- const project = force ? null : await findProjectByGithubUrl(target.github_url);
30
+ //
31
+ // We always look up `existing` (even on --force) so that we can capture the
32
+ // pre-refresh `last_analysis_at` baseline and poll for a *newer* snapshot.
33
+ // Without that baseline, polling sees the stale snapshot's timestamp as
34
+ // "ready" and returns it immediately.
35
+ const existing = await findProjectByGithubUrl(target.github_url);
36
+ const project = force ? null : existing;
37
+ const refreshBaseline = force ? (existing?.last_analysis_at ?? null) : null;
31
38
  if (project) {
32
39
  const [snapshot, standing] = await Promise.all([
33
40
  fetchLatestSnapshot(project.id),
@@ -128,7 +135,7 @@ export async function audit(args) {
128
135
  const pending = result;
129
136
  if (!asJson)
130
137
  console.log(c.dim(' This runs the full Claude audit · ~60-90 seconds. Hang tight.'));
131
- const waited = await waitForPreviewSnapshot(pending.project_id);
138
+ const waited = await waitForPreviewSnapshot(pending.project_id, refreshBaseline);
132
139
  if (!waited) {
133
140
  emitError(asJson, 'timeout', 'Preview audit is taking longer than expected. Try `commitshow status <repo>` in a minute.', target.github_url);
134
141
  return 1;
package/dist/lib/api.js CHANGED
@@ -77,20 +77,34 @@ export async function runPreviewAudit(githubUrl, liveUrl, opts = {}) {
77
77
  return body;
78
78
  return body;
79
79
  }
80
- /** Poll a preview job until the snapshot lands or we time out. */
81
- export async function waitForPreviewSnapshot(projectId, timeoutMs = 180_000, intervalMs = 4_000) {
80
+ /** Poll a preview job until the snapshot lands or we time out.
81
+ *
82
+ * `since` (ISO timestamp) is the baseline we wait past. For an INITIAL audit
83
+ * on a brand-new project, leave it undefined — any snapshot wins. For a
84
+ * REFRESH (force=true) on an existing project, pass the project's previous
85
+ * `last_analysis_at` so we keep polling until a *new* snapshot lands.
86
+ * Without this guard, a force-refresh against an already-analyzed project
87
+ * returns the stale snapshot immediately because `last_analysis_at` is
88
+ * already truthy. (Bug seen in 0.2.1 and earlier.) */
89
+ export async function waitForPreviewSnapshot(projectId, since, timeoutMs = 180_000, intervalMs = 4_000) {
90
+ const sinceMs = since ? new Date(since).getTime() : 0;
82
91
  const deadline = Date.now() + timeoutMs;
83
92
  while (Date.now() < deadline) {
84
93
  const project = await findProjectById(projectId);
85
94
  if (project && project.last_analysis_at) {
86
- const snapshot = await fetchLatestSnapshot(projectId);
87
- return {
88
- project,
89
- snapshot,
90
- standing: null,
91
- is_preview: project.status === 'preview',
92
- cache_hit: false,
93
- };
95
+ const lastMs = new Date(project.last_analysis_at).getTime();
96
+ // sinceMs === 0 → first ever audit, accept any snapshot.
97
+ // Otherwise require last_analysis_at to have advanced.
98
+ if (sinceMs === 0 || lastMs > sinceMs) {
99
+ const snapshot = await fetchLatestSnapshot(projectId);
100
+ return {
101
+ project,
102
+ snapshot,
103
+ standing: null,
104
+ is_preview: project.status === 'preview',
105
+ cache_hit: false,
106
+ };
107
+ }
94
108
  }
95
109
  await new Promise(r => setTimeout(r, intervalMs));
96
110
  }
@@ -117,7 +117,7 @@ export function renderAudit(view) {
117
117
  // computed and exposed in JSON as `walk_on_audit_normalized` for agents
118
118
  // that want a deterministic floor, but the user-facing big-digit uses
119
119
  // the calibrated total.
120
- const WALK_ON_AUDIT_MAX = 49;
120
+ const WALK_ON_AUDIT_MAX = 47;
121
121
  const isWalkOn = p.status === 'preview';
122
122
  const total = p.score_total ?? 0;
123
123
  // Header
@@ -323,7 +323,7 @@ export function toAgentShape(view) {
323
323
  // Walk-on context fields. The user-facing score is Claude's calibrated
324
324
  // total (score_total). `walk_on_audit_normalized` is the deterministic
325
325
  // pillar-only fallback (Brief slot excluded · base /45).
326
- const WALK_ON_AUDIT_MAX = 49;
326
+ const WALK_ON_AUDIT_MAX = 47;
327
327
  const isWalkOn = p.status === 'preview';
328
328
  const walkOnTotal = isWalkOn ? (p.score_total ?? 0) : null;
329
329
  const walkOnAuditNormalized = isWalkOn
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commitshow",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "commit.show CLI — audit any vibe-coded project from your terminal.",
5
5
  "type": "module",
6
6
  "bin": {