lake-gate 0.2.0 → 0.2.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/action.yml CHANGED
@@ -6,7 +6,7 @@ branding:
6
6
  color: green
7
7
  inputs:
8
8
  token:
9
- description: GitHub token with statuses:write and issues:write (the default GITHUB_TOKEN works).
9
+ description: GitHub token with statuses:write and pull-requests:write (the default GITHUB_TOKEN works).
10
10
  required: false
11
11
  default: ${{ github.token }}
12
12
  comment:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lake-gate",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Version-bound team plan approval for AI coding agents: review UI, Claude Code hook, MCP server, GitHub Action. No backend, no telemetry.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -49,7 +49,7 @@ export async function main(argv = process.argv.slice(2), io = { out: (s) => proc
49
49
  }
50
50
  case 'plan': {
51
51
  const { plan, estimate } = exportPlan(root, readInput(args.find((a) => !a.startsWith('--') && a !== flag(args, '--id'))), { id: flag(args, '--id'), source: 'cli' });
52
- io.out(`Saved .lake/plans/${plan.id}.md version ${plan.short} ${estimate.complexity} est. ${range(estimate.usd)}`);
52
+ io.out(`Saved .lake/plans/${plan.id}.md version ${plan.short} ${estimate.complexity} est. ${range(estimate.declared ? estimate.plannedUsd : estimate.usd)}${estimate.model ? ` on ${estimate.model.name}` : ""}`);
53
53
  io.out(`Approve on the PR with: /lake approve ${plan.id}@${plan.short}`);
54
54
  return 0;
55
55
  }
package/src/github.js CHANGED
@@ -164,7 +164,12 @@ export async function publish(gh, ev, { comment = true } = {}) {
164
164
  await gh.req('POST', `/statuses/${ev.pr.head.sha}`, { state: ev.state, context: STATUS_CONTEXT, description: ev.description.slice(0, 140) });
165
165
  if (!comment || (!ev.results.length && ev.state === 'success' && !/Warning/.test(ev.description))) return;
166
166
  const body = renderSummary(ev);
167
- const existing = (await gh.all(`/issues/${ev.pr.number}/comments`)).find((c) => c.user.type === 'Bot' && String(c.body).startsWith(MARKER));
168
- if (existing) { if (existing.body !== body) await gh.req('PATCH', `/issues/comments/${existing.id}`, { body }); }
169
- else await gh.req('POST', `/issues/${ev.pr.number}/comments`, { body });
167
+ try {
168
+ const existing = (await gh.all(`/issues/${ev.pr.number}/comments`)).find((c) => c.user.type === 'Bot' && String(c.body).startsWith(MARKER));
169
+ if (existing) { if (existing.body !== body) await gh.req('PATCH', `/issues/comments/${existing.id}`, { body }); }
170
+ else await gh.req('POST', `/issues/${ev.pr.number}/comments`, { body });
171
+ } catch (e) {
172
+ // The status check above is what matters. A missing summary comment shouldn't fail the gate.
173
+ console.log(`::warning::lake-gate couldn't post the summary comment (${String(e.message).slice(0, 120)}). Give the workflow "pull-requests: write" (see templates/lake-gate.yml).`);
174
+ }
170
175
  }
package/src/hook.js CHANGED
@@ -30,7 +30,7 @@ export function handleClaudePreToolUse(input, env = process.env) {
30
30
  const { plan, estimate } = exportPlan(root, ti.plan, { source: 'claude-code', sessionId: input.session_id });
31
31
  const st = localStatus(root, plan, config);
32
32
  const gateNote = st.state === 'approved' || st.state === 'auto-approved' ? `Already ${st.state}` : 'Implementation is gated until a teammate approves this version';
33
- return out(null, null, { systemMessage: `Lake: plan saved to .lake/plans/${plan.id}.md (version ${plan.short}, ${estimate.complexity} complexity, est. ${range(estimate.usd)}). ${gateNote}.` });
33
+ return out(null, null, { systemMessage: `Lake: plan saved to .lake/plans/${plan.id}.md (version ${plan.short}, ${estimate.complexity} complexity, est. ${range(estimate.declared ? estimate.plannedUsd : estimate.usd)}${estimate.model ? ` on ${estimate.model.name}` : ""}). ${gateNote}.` });
34
34
  }
35
35
 
36
36
  if (config.localGate === 'off' || !config.gatedTools.includes(tool)) return null;
package/src/mcp.js CHANGED
@@ -35,7 +35,7 @@ export const TOOLS = [
35
35
  inputSchema: S({ plan_markdown: str('Full revised plan in markdown'), plan_id: str('Plan id (defaults to the active plan)'),
36
36
  thread_id: str('Accept this reviewer suggestion thread'), suggestion_id: str('Apply this Lake suggestion, e.g. models-2-4, cap-12, drop-5'), model: str('Run the whole plan on this model, e.g. sonnet'),
37
37
  addressed_threads: { type: 'array', items: { type: 'string' }, description: 'Thread ids this revision addresses (marked resolved)' },
38
- note: str('What changed, for reviewers'), push: { type: 'boolean', description: 'Commit only the plan file and push' } }), annotations: { openWorldHint: true } },
38
+ note: str('What changed, for reviewers'), push: { type: 'boolean', description: 'Commit only the plan file and push (default on when applying a suggestion)' } }), annotations: { openWorldHint: true } },
39
39
  { name: 'lake_review', description: 'As a reviewer, act on a plan PR: approve, request_changes, comment (optionally on lines), reply (in a thread) or suggest (a structured change the author accepts in one click: suggestion_id or model). approve and request_changes post as the human GitHub account on this machine: ONLY use them when the user explicitly said so in this conversation, and pass the exact version they saw.',
40
40
  inputSchema: S({ action: { type: 'string', enum: ['approve', 'request_changes', 'comment', 'reply', 'suggest'] }, plan_id: str('Plan id'), version: str('8-character version (approve / request_changes)'),
41
41
  text: str('Comment, reply, or verdict note (required for request_changes)'), line: { type: 'number', description: 'First plan line to anchor a comment' }, end_line: { type: 'number' },
@@ -227,7 +227,7 @@ export async function callTool(ctx, name, a = {}) {
227
227
  return `Commented on ${id} v${model.short}, line ${s}${e > s ? `–${e}` : ''}.`;
228
228
  }
229
229
  case '_approve': case '_changes': {
230
- const id = a.plan_id;
230
+ const id = resolveId(ctx, a.plan_id);
231
231
  const { number, model } = await prModel(ctx, id);
232
232
  if (!model) throw new Error(`No open PR with plan ${id}.`);
233
233
  const v = String(a.version || '').toLowerCase();
@@ -243,7 +243,7 @@ export async function callTool(ctx, name, a = {}) {
243
243
  return `Plan ${id} v${plan.short}\n` + formatCost(est, cfg, undefined, est.exposure > (cfg.budget?.approverAbove ?? Infinity) ? { required: true, exposure: est.exposure, threshold: cfg.budget.approverAbove, approvers: (cfg.budget.approvers || []).map((x) => String(x).replace(/^@/, '')), satisfied: false } : null);
244
244
  }
245
245
  case '_suggest': {
246
- const { number, model, config } = await prModel(ctx, a.plan_id);
246
+ const { number, model, config } = await prModel(ctx, resolveId(ctx, a.plan_id));
247
247
  if (!model) throw new Error(`No open PR with plan ${a.plan_id}.`);
248
248
  const s = patchFor(a, model.estimate, config);
249
249
  await actions.suggest(ctx.github(), number, { planId: model.id, version: model.digest, title: s.title, patch: s.patch, saving: s.saving, text: a.comment, via });
@@ -262,10 +262,11 @@ export async function callTool(ctx, name, a = {}) {
262
262
  } else s = patchFor(a, estimatePlan(plan.body, cfg), cfg);
263
263
  const next = applyPatch(stripEstimate(plan.body).replace(/\s+$/, '') + '\n', s.patch);
264
264
  const { plan: np, estimate } = exportPlan(ctx.root, next, { id, source: 'mcp' });
265
+ const push = a.push ?? true; // one click: apply, commit only the plan file, push
265
266
  let note = '';
266
- if (a.push) note = '\n' + pushPlan(ctx, id, `Plan ${id}: ${s.title || describePatch(s.patch, cfg)} (v${np.short})`);
267
+ if (push) note = '\n' + pushPlan(ctx, id, `Plan ${id}: ${s.title || describePatch(s.patch, cfg)} (v${np.short})`);
267
268
  if (a.thread_id && number) await ctx.github().req('POST', `/issues/${number}/comments`, { body: acceptBody({ planId: id, thread: a.thread_id, title: s.title, newVersion: np.digest, via }) });
268
- return `Applied "${s.title}" to ${id}: new version v${np.short}, ${range(estimate.declared ? estimate.plannedUsd : estimate.usd)}.${note}${a.push ? '' : ' Push the plan file so reviewers see it.'} Earlier approvals no longer apply.`;
269
+ return `Applied "${s.title}" to ${id}: new version v${np.short}, ${range(estimate.declared ? estimate.plannedUsd : estimate.usd)}.${note}${push ? '' : ' Push the plan file so reviewers see it.'} Earlier approvals no longer apply.`;
269
270
  }
270
271
  default: throw new Error(`Unknown tool ${name}`);
271
272
  }
@@ -11,7 +11,7 @@ on:
11
11
  types: [created, edited, deleted]
12
12
  permissions:
13
13
  contents: read
14
- pull-requests: read
14
+ pull-requests: write # to post and update the summary comment
15
15
  issues: write
16
16
  statuses: write
17
17
  concurrency: