indusagi-coding-agent 0.2.12 → 0.2.14

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 (81) hide show
  1. package/.env.review.example +25 -0
  2. package/README.md +30 -0
  3. package/REVIEW_AGENT.md +137 -0
  4. package/dist/entry.js +1861 -979
  5. package/dist/guardrails.js +212 -36
  6. package/dist/index.js +2829 -1057
  7. package/dist/review-agent.js +4461 -0
  8. package/dist/review-server.js +4633 -0
  9. package/package.json +24 -7
  10. package/src/boot/auth-vault.ts +4 -5
  11. package/src/boot/contract.ts +1 -1
  12. package/src/boot/runners/addon-wiring.ts +111 -3
  13. package/src/boot/runners/benchmark-integrity.ts +107 -0
  14. package/src/boot/runners/repl-runner.ts +2 -1
  15. package/src/boot/runners/session.ts +26 -12
  16. package/src/boot/server-token.ts +20 -11
  17. package/src/boot/stages.ts +3 -6
  18. package/src/briefing/context-docs.ts +144 -12
  19. package/src/channels/oneshot.ts +6 -0
  20. package/src/conductor/catalog/catalog.ts +3 -1
  21. package/src/conductor/conductor.ts +77 -17
  22. package/src/conductor/contract.ts +9 -7
  23. package/src/conductor/index.ts +1 -1
  24. package/src/conductor/transcript-store/store.ts +4 -8
  25. package/src/console/auth-status.ts +9 -4
  26. package/src/console/components/AgentsView.ts +2 -2
  27. package/src/console/components/BackgroundAgents.ts +15 -2
  28. package/src/console/components/Banner.ts +20 -9
  29. package/src/console/components/Composer.ts +57 -82
  30. package/src/console/components/ScrollViewport.ts +46 -0
  31. package/src/console/components/TerminalConsole.ts +165 -162
  32. package/src/console/components/WorkingIndicator.ts +6 -5
  33. package/src/console/components/banner-sweep.ts +5 -1
  34. package/src/console/components/welcome.ts +3 -3
  35. package/src/console/contract.ts +10 -5
  36. package/src/console/index.ts +7 -7
  37. package/src/console/input/complete.ts +2 -2
  38. package/src/console/input/dir-reader.ts +3 -1
  39. package/src/console/input/graphemes.ts +22 -0
  40. package/src/console/input/keymap.ts +6 -4
  41. package/src/console/mount.ts +45 -3
  42. package/src/console/overlays/auth.ts +28 -8
  43. package/src/console/overlays/boards.ts +13 -40
  44. package/src/console/overlays/host.ts +10 -0
  45. package/src/console/overlays/pickers.ts +35 -30
  46. package/src/console/reducer.ts +12 -5
  47. package/src/console/slash/builtins.ts +4 -3
  48. package/src/console/slash/commands/integrations.ts +13 -14
  49. package/src/console/slash/commands/transcript.ts +3 -8
  50. package/src/console/slash/commands/workbench.ts +4 -4
  51. package/src/console/test-support.ts +48 -0
  52. package/src/index.ts +1 -0
  53. package/src/integrations/sarvam/config.ts +15 -13
  54. package/src/kit/external-editor.ts +17 -1
  55. package/src/kit/run-shell.ts +31 -0
  56. package/src/launch/catalog.ts +4 -2
  57. package/src/launch/contract.ts +1 -0
  58. package/src/launch/invocation/flags.ts +13 -1
  59. package/src/launch/invocation/read.ts +4 -3
  60. package/src/launch/login.ts +23 -10
  61. package/src/launch/oauth.ts +3 -0
  62. package/src/models.ts +166 -0
  63. package/src/review-agent/config.ts +75 -0
  64. package/src/review-agent/contract.ts +59 -0
  65. package/src/review-agent/github.ts +242 -0
  66. package/src/review-agent/index.ts +8 -0
  67. package/src/review-agent/prompt.ts +132 -0
  68. package/src/review-agent/reviewer.ts +118 -0
  69. package/src/review-agent/server.ts +221 -0
  70. package/src/review-agent/service.ts +165 -0
  71. package/src/review-agent/supabase.ts +209 -0
  72. package/src/review-agent/webhook.ts +76 -0
  73. package/src/security/private-state.ts +122 -0
  74. package/src/window-budget/summarize/condense.ts +4 -1
  75. package/src/workspace/brand.ts +1 -1
  76. package/src/workspace/locator.ts +2 -2
  77. package/supabase/migrations/20260827031803_indusagi_review_agent.sql +109 -0
  78. package/supabase/migrations/20260827035747_atomic_webhook_enqueue.sql +75 -0
  79. package/supabase/migrations/20260827040104_check_run_reconciliation.sql +8 -0
  80. package/supabase/migrations/20260827041049_owned_job_leases.sql +80 -0
  81. package/supabase/migrations/20260827042500_static_token_webhooks.sql +75 -0
@@ -0,0 +1,80 @@
1
+ alter table public.indusagi_review_jobs
2
+ add column if not exists lease_token uuid,
3
+ add column if not exists lease_expires_at timestamptz;
4
+
5
+ create index if not exists indusagi_review_jobs_lease_expiry_idx
6
+ on public.indusagi_review_jobs (lease_expires_at)
7
+ where status = 'running';
8
+
9
+ create or replace function public.claim_indusagi_review_job(p_worker_id text)
10
+ returns setof public.indusagi_review_jobs
11
+ language plpgsql
12
+ security definer
13
+ set search_path = public
14
+ as $$
15
+ declare
16
+ claimed public.indusagi_review_jobs;
17
+ begin
18
+ if nullif(trim(p_worker_id), '') is null then
19
+ raise exception 'worker id is required';
20
+ end if;
21
+
22
+ select * into claimed
23
+ from public.indusagi_review_jobs
24
+ where status = 'pending' and available_at <= now()
25
+ order by created_at
26
+ for update skip locked
27
+ limit 1;
28
+
29
+ if claimed.id is null then
30
+ return;
31
+ end if;
32
+
33
+ update public.indusagi_review_jobs
34
+ set status = 'running',
35
+ attempts = attempts + 1,
36
+ worker_id = p_worker_id,
37
+ lease_token = gen_random_uuid(),
38
+ claimed_at = now(),
39
+ lease_expires_at = now() + interval '5 minutes',
40
+ updated_at = now()
41
+ where id = claimed.id
42
+ returning * into claimed;
43
+
44
+ return next claimed;
45
+ end;
46
+ $$;
47
+
48
+ create or replace function public.recover_stale_indusagi_review_jobs(p_stale_minutes integer default 15)
49
+ returns integer
50
+ language plpgsql
51
+ security definer
52
+ set search_path = public
53
+ as $$
54
+ declare
55
+ recovered integer;
56
+ begin
57
+ update public.indusagi_review_jobs
58
+ set status = case when attempts < max_attempts then 'pending' else 'failed' end,
59
+ available_at = now(),
60
+ worker_id = null,
61
+ lease_token = null,
62
+ claimed_at = null,
63
+ lease_expires_at = null,
64
+ error = coalesce(error, 'worker lease expired'),
65
+ completed_at = case when attempts >= max_attempts then now() else completed_at end,
66
+ updated_at = now()
67
+ where status = 'running'
68
+ and coalesce(
69
+ lease_expires_at,
70
+ claimed_at + make_interval(mins => greatest(1, p_stale_minutes))
71
+ ) < now();
72
+ get diagnostics recovered = row_count;
73
+ return recovered;
74
+ end;
75
+ $$;
76
+
77
+ revoke all on function public.claim_indusagi_review_job(text) from public, anon, authenticated;
78
+ revoke all on function public.recover_stale_indusagi_review_jobs(integer) from public, anon, authenticated;
79
+ grant execute on function public.claim_indusagi_review_job(text) to service_role;
80
+ grant execute on function public.recover_stale_indusagi_review_jobs(integer) to service_role;
@@ -0,0 +1,75 @@
1
+ create or replace function public.enqueue_indusagi_review_job(
2
+ p_delivery_id text,
3
+ p_event_name text,
4
+ p_installation_id bigint,
5
+ p_repository text,
6
+ p_owner text,
7
+ p_repo text,
8
+ p_pr_number integer,
9
+ p_head_sha text,
10
+ p_title text
11
+ )
12
+ returns table(job_id uuid, duplicate boolean)
13
+ language plpgsql
14
+ security definer
15
+ set search_path = public
16
+ as $$
17
+ declare
18
+ queued_id uuid;
19
+ inserted_delivery integer;
20
+ begin
21
+ if nullif(trim(p_delivery_id), '') is null
22
+ or nullif(trim(p_event_name), '') is null
23
+ or p_installation_id < 0
24
+ or nullif(trim(p_repository), '') is null
25
+ or nullif(trim(p_owner), '') is null
26
+ or nullif(trim(p_repo), '') is null
27
+ or p_pr_number <= 0
28
+ or nullif(trim(p_head_sha), '') is null
29
+ or nullif(trim(p_title), '') is null then
30
+ raise exception 'invalid review webhook job';
31
+ end if;
32
+
33
+ insert into public.indusagi_review_deliveries(delivery_id, event_name)
34
+ values (p_delivery_id, p_event_name)
35
+ on conflict (delivery_id) do nothing;
36
+ get diagnostics inserted_delivery = row_count;
37
+
38
+ if inserted_delivery = 0 then
39
+ return query select null::uuid, true;
40
+ return;
41
+ end if;
42
+
43
+ insert into public.indusagi_review_jobs(
44
+ delivery_id,
45
+ installation_id,
46
+ repository,
47
+ owner,
48
+ repo,
49
+ pr_number,
50
+ head_sha,
51
+ title
52
+ ) values (
53
+ p_delivery_id,
54
+ p_installation_id,
55
+ p_repository,
56
+ p_owner,
57
+ p_repo,
58
+ p_pr_number,
59
+ p_head_sha,
60
+ p_title
61
+ )
62
+ on conflict (repository, pr_number, head_sha) do update
63
+ set installation_id = excluded.installation_id,
64
+ title = excluded.title,
65
+ updated_at = now()
66
+ returning id into queued_id;
67
+
68
+ return query select queued_id, false;
69
+ end;
70
+ $$;
71
+
72
+ revoke all on function public.enqueue_indusagi_review_job(text, text, bigint, text, text, text, integer, text, text)
73
+ from public, anon, authenticated;
74
+ grant execute on function public.enqueue_indusagi_review_job(text, text, bigint, text, text, text, integer, text, text)
75
+ to service_role;