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,25 @@
1
+ # Requested Supabase project: sdsdsd (bnaadeovgcqgbrnrfcef)
2
+ SUPABASE_URL=https://bnaadeovgcqgbrnrfcef.supabase.co
3
+ # Server-only secret. Retrieve it from Supabase project settings; never commit it.
4
+ SUPABASE_SERVICE_ROLE_KEY=
5
+
6
+ # GitHub webhook and GitHub App credentials
7
+ GITHUB_WEBHOOK_SECRET=
8
+ GITHUB_APP_ID=
9
+ # PEM may use literal newlines or escaped \n sequences.
10
+ GITHUB_APP_PRIVATE_KEY=
11
+
12
+ # Development-only alternative to GITHUB_APP_ID + GITHUB_APP_PRIVATE_KEY
13
+ # GITHUB_TOKEN=
14
+
15
+ # Indusagi review model
16
+ INDUSAGI_REVIEW_MODEL=anthropic/claude-sonnet-4-6
17
+ ANTHROPIC_API_KEY=
18
+ # OPENAI_API_KEY=
19
+ # GOOGLE_API_KEY=
20
+ # MISTRAL_API_KEY=
21
+
22
+ REVIEW_AGENT_HOST=0.0.0.0
23
+ REVIEW_AGENT_PORT=8787
24
+ REVIEW_AGENT_POLL_MS=2000
25
+ REVIEW_AGENT_JOBS_PER_TICK=5
package/README.md CHANGED
@@ -44,6 +44,25 @@ Requires **Node >= 20**. Authenticate with an API key — set `ANTHROPIC_API_KEY
44
44
  `indus --help` prints the full flag grammar (generated from one flag table);
45
45
  `indus --version` prints the version.
46
46
 
47
+ ## Project trust and private state
48
+
49
+ - Executable files under `<repo>/.indus/addons` are disabled by default. Review
50
+ them, then pass `--trust-project-addons` to approve the canonical workspace and
51
+ the current addon-tree SHA-256 digest. The owner-only trust record is reused
52
+ while that digest is unchanged; any addon edit invalidates it.
53
+ - Context files are discovered only inside the canonical `--cwd` workspace.
54
+ Imports that resolve outside it are ignored unless the exact file is listed by
55
+ `--allow-context-import <path>`. Symlinks and likely secret files such as
56
+ `.env`, private-key files, and credential files are never auto-imported.
57
+ - On POSIX, agent state/session directories are enforced as `0700` and
58
+ credentials, trust records, integration keys, and transcripts as `0600`.
59
+ Existing owned paths are tightened; symlink destinations and paths owned by a
60
+ different user are rejected. Sensitive replacements use same-directory atomic
61
+ writes. Sarvam API keys are no longer read from or written to project config.
62
+ - Windows does not implement POSIX mode bits. The same symlink/regular-file and
63
+ atomic-replacement checks apply, but this release does not install Windows
64
+ ACLs; use a private user profile with appropriately restricted ACLs.
65
+
47
66
  ## Architecture
48
67
 
49
68
  The binary is `src/entry.ts`. Boot resolves the invocation, prepares the
@@ -127,6 +146,17 @@ First connect may open a browser for Zoho OAuth. Tokens persist under
127
146
 
128
147
  See [`ZOHO_NATIVE_PLAN.md`](./ZOHO_NATIVE_PLAN.md) for architecture and precedence.
129
148
 
149
+ ## GitHub review agent
150
+
151
+ This package also includes `indusagi-review`, a durable GitHub pull-request
152
+ review worker powered by the Indusagi conductor and backed by Supabase. It
153
+ validates signed webhooks, reads repository context through read-only GitHub
154
+ tools, posts inline review findings and a check run, and persists retryable
155
+ jobs without Prisma.
156
+
157
+ See [REVIEW_AGENT.md](./REVIEW_AGENT.md) for GitHub App permissions, Supabase
158
+ schema, environment variables, deployment, and security details.
159
+
130
160
  ## Sarvam AI (native MCP)
131
161
 
132
162
  Indian-language STT / TTS / translate / vision tools via local
@@ -0,0 +1,137 @@
1
+ # Indusagi GitHub Review Agent
2
+
3
+ A Supabase-backed GitHub pull-request reviewer powered by the same Indusagi framework Agent and `SessionConductor` as the terminal coding agent.
4
+
5
+ ## What it does
6
+
7
+ 1. Receives signed GitHub `pull_request` webhooks.
8
+ 2. Atomically deduplicates deliveries and persists durable jobs in Supabase.
9
+ 3. Claims work with PostgreSQL `FOR UPDATE SKIP LOCKED`.
10
+ 4. Exchanges GitHub App credentials for a short-lived installation token.
11
+ 5. Reads PR metadata, every changed-file page, and the unified diff.
12
+ 6. Runs the Indusagi conductor with read-only `github_read_file` and `github_search_code` tools.
13
+ 7. Validates structured findings against actual changed diff lines.
14
+ 8. Posts a formal GitHub review with inline comments; falls back to one sticky timeline comment if GitHub rejects line coordinates.
15
+ 9. Publishes a GitHub check run, stores the result in Supabase, and reconciles failed check updates.
16
+
17
+ The service never checks out or executes pull-request code.
18
+
19
+ ## Supabase
20
+
21
+ This repository is configured to default to the requested project:
22
+
23
+ - Project: `sdsdsd`
24
+ - Project ref: `bnaadeovgcqgbrnrfcef`
25
+ - URL: `https://bnaadeovgcqgbrnrfcef.supabase.co`
26
+
27
+ Migrations:
28
+
29
+ ```text
30
+ supabase/migrations/20260827031803_indusagi_review_agent.sql
31
+ supabase/migrations/20260827035747_atomic_webhook_enqueue.sql
32
+ supabase/migrations/20260827040104_check_run_reconciliation.sql
33
+ supabase/migrations/20260827041049_owned_job_leases.sql
34
+ supabase/migrations/20260827042500_static_token_webhooks.sql
35
+ ```
36
+
37
+ They create RLS-enabled `indusagi_review_deliveries` and `indusagi_review_jobs`
38
+ tables plus atomic webhook-enqueue, ownership-safe renewable job leases,
39
+ periodic stale-recovery, and check-run reconciliation support. No anonymous or authenticated policies are created;
40
+ the backend must use the service-role/secret key.
41
+
42
+ Never commit the service-role key. The publishable/anon key is intentionally not used because the webhook worker requires privileged server-side writes.
43
+
44
+ ## GitHub App setup
45
+
46
+ Create a GitHub App with:
47
+
48
+ ### Repository permissions
49
+
50
+ - Contents: Read
51
+ - Metadata: Read
52
+ - Pull requests: Read and write
53
+ - Issues: Read and write (sticky fallback)
54
+ - Checks: Read and write
55
+
56
+ ### Events
57
+
58
+ Subscribe to `Pull request`. Point the webhook URL to:
59
+
60
+ ```text
61
+ https://YOUR_HOST/webhooks/github
62
+ ```
63
+
64
+ Set a strong webhook secret and configure the same value as `GITHUB_WEBHOOK_SECRET`.
65
+
66
+ The service processes `opened`, `reopened`, `synchronize`, and `ready_for_review`. Drafts are ignored until ready.
67
+
68
+ ## Configuration
69
+
70
+ Copy `.env.review.example` into your deployment secret manager. Required production values:
71
+
72
+ ```text
73
+ SUPABASE_SERVICE_ROLE_KEY
74
+ GITHUB_WEBHOOK_SECRET
75
+ GITHUB_APP_ID
76
+ GITHUB_APP_PRIVATE_KEY
77
+ ANTHROPIC_API_KEY
78
+ ```
79
+
80
+ `GITHUB_TOKEN` is a development-only alternative to GitHub App credentials.
81
+ In this mode, ordinary repository webhooks without an `installation` field are
82
+ accepted and stored with installation ID `0`; the static token provider ignores
83
+ that sentinel value.
84
+
85
+ The private key may contain literal newlines or escaped `\n` sequences.
86
+
87
+ ## Build and run
88
+
89
+ ```bash
90
+ npm install
91
+ npm test
92
+ npm run typecheck
93
+ npm run build
94
+ npm run review:server
95
+ ```
96
+
97
+ The server exposes:
98
+
99
+ - `GET /healthz`
100
+ - `POST /webhooks/github`
101
+
102
+ Default port: `8787`.
103
+
104
+ ## Model
105
+
106
+ Default:
107
+
108
+ ```text
109
+ anthropic/claude-sonnet-4-6
110
+ ```
111
+
112
+ Override with `INDUSAGI_REVIEW_MODEL=provider/model`. Configure the matching provider API key. The review is executed through `createSessionConductor`, with high thinking and only two read-only GitHub tools.
113
+
114
+ ## Security properties
115
+
116
+ - Webhook signatures are mandatory and compared in constant time.
117
+ - GitHub delivery IDs are deduplicated in Supabase.
118
+ - Pull-request content is explicitly marked untrusted in the system and user prompts.
119
+ - No bash, write, edit, process, or local repository tools are exposed.
120
+ - Findings below 0.80 confidence are discarded.
121
+ - Findings not mapped to changed diff lines are discarded.
122
+ - The current PR head SHA is checked immediately before review generation.
123
+ - GitHub App installation tokens are short-lived.
124
+ - GitHub reviews and checks use deterministic markers/external IDs so retries
125
+ reuse already-visible side effects instead of posting duplicates.
126
+ - GitHub and Supabase requests have 30-second deadlines; model reviews have a
127
+ 10-minute deadline and abort the Indusagi conductor when exceeded.
128
+ - Supabase tables have RLS enabled and no client policies.
129
+
130
+ ## Production notes
131
+
132
+ Run at least one always-on worker process. Multiple instances are safe: the
133
+ database claim function serializes each claim with `SKIP LOCKED`, issues a
134
+ unique five-minute lease token, and every running-job mutation verifies that
135
+ token. Workers renew leases every minute. Expired leases are recovered every
136
+ minute without requiring a restart. Failed jobs use bounded exponential
137
+ backoff and stop after three attempts.