@synaplink/orqlaude 0.3.0

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 (66) hide show
  1. package/.mcp.json.template +8 -0
  2. package/README.md +239 -0
  3. package/dist/__tests__/hallucination.test.d.ts +1 -0
  4. package/dist/__tests__/hallucination.test.js +65 -0
  5. package/dist/__tests__/hallucination.test.js.map +1 -0
  6. package/dist/__tests__/state.test.d.ts +1 -0
  7. package/dist/__tests__/state.test.js +124 -0
  8. package/dist/__tests__/state.test.js.map +1 -0
  9. package/dist/cli.d.ts +2 -0
  10. package/dist/cli.js +322 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/lib/audit.d.ts +38 -0
  13. package/dist/lib/audit.js +108 -0
  14. package/dist/lib/audit.js.map +1 -0
  15. package/dist/lib/budgeting.d.ts +37 -0
  16. package/dist/lib/budgeting.js +67 -0
  17. package/dist/lib/budgeting.js.map +1 -0
  18. package/dist/lib/hallucination.d.ts +46 -0
  19. package/dist/lib/hallucination.js +154 -0
  20. package/dist/lib/hallucination.js.map +1 -0
  21. package/dist/lib/jsonl_tail.d.ts +40 -0
  22. package/dist/lib/jsonl_tail.js +126 -0
  23. package/dist/lib/jsonl_tail.js.map +1 -0
  24. package/dist/lib/pricing.d.ts +24 -0
  25. package/dist/lib/pricing.js +43 -0
  26. package/dist/lib/pricing.js.map +1 -0
  27. package/dist/lib/state.d.ts +118 -0
  28. package/dist/lib/state.js +138 -0
  29. package/dist/lib/state.js.map +1 -0
  30. package/dist/server.d.ts +2 -0
  31. package/dist/server.js +34 -0
  32. package/dist/server.js.map +1 -0
  33. package/dist/telegram/api.d.ts +45 -0
  34. package/dist/telegram/api.js +59 -0
  35. package/dist/telegram/api.js.map +1 -0
  36. package/dist/telegram/bot.d.ts +11 -0
  37. package/dist/telegram/bot.js +73 -0
  38. package/dist/telegram/bot.js.map +1 -0
  39. package/dist/telegram/commands.d.ts +22 -0
  40. package/dist/telegram/commands.js +217 -0
  41. package/dist/telegram/commands.js.map +1 -0
  42. package/dist/telegram/config.d.ts +30 -0
  43. package/dist/telegram/config.js +37 -0
  44. package/dist/telegram/config.js.map +1 -0
  45. package/dist/telegram/notifier.d.ts +14 -0
  46. package/dist/telegram/notifier.js +136 -0
  47. package/dist/telegram/notifier.js.map +1 -0
  48. package/dist/tools/broker.d.ts +15 -0
  49. package/dist/tools/broker.js +245 -0
  50. package/dist/tools/broker.js.map +1 -0
  51. package/dist/tools/dispatch.d.ts +14 -0
  52. package/dist/tools/dispatch.js +231 -0
  53. package/dist/tools/dispatch.js.map +1 -0
  54. package/dist/tools/lifecycle.d.ts +18 -0
  55. package/dist/tools/lifecycle.js +124 -0
  56. package/dist/tools/lifecycle.js.map +1 -0
  57. package/dist/tools/ping.d.ts +2 -0
  58. package/dist/tools/ping.js +26 -0
  59. package/dist/tools/ping.js.map +1 -0
  60. package/dist/tools/planning.d.ts +4 -0
  61. package/dist/tools/planning.js +160 -0
  62. package/dist/tools/planning.js.map +1 -0
  63. package/dist/tools/review.d.ts +18 -0
  64. package/dist/tools/review.js +93 -0
  65. package/dist/tools/review.js.map +1 -0
  66. package/package.json +56 -0
@@ -0,0 +1,18 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { StateStore } from "../lib/state.js";
3
+ import type { AuditLog } from "../lib/audit.js";
4
+ /**
5
+ * review_prs — spawn a review fleet against the PRs produced by an
6
+ * already-completed plan.
7
+ *
8
+ * The implementation creates a NEW plan whose tasks correspond 1:1 with the
9
+ * source plan's tasks-with-PR-URLs. Each new task's prompt instructs the
10
+ * reviewer agent to fetch the PR via `gh pr view`, inspect the diff, run any
11
+ * applicable tests, and post findings via post_note (with `pr_url` set to the
12
+ * source PR so the original collect() picks them up).
13
+ *
14
+ * The review plan is automatically approved (skipping the AskUserQuestion
15
+ * step) because the user already approved the parent fleet. If they want a
16
+ * confirmation per review, they can set `auto_approve: false`.
17
+ */
18
+ export declare function registerReview(server: McpServer, store: StateStore, audit: AuditLog): void;
@@ -0,0 +1,93 @@
1
+ import { z } from "zod";
2
+ import { newPlan, findPlan } from "../lib/state.js";
3
+ import { estimateAgent } from "../lib/budgeting.js";
4
+ /**
5
+ * review_prs — spawn a review fleet against the PRs produced by an
6
+ * already-completed plan.
7
+ *
8
+ * The implementation creates a NEW plan whose tasks correspond 1:1 with the
9
+ * source plan's tasks-with-PR-URLs. Each new task's prompt instructs the
10
+ * reviewer agent to fetch the PR via `gh pr view`, inspect the diff, run any
11
+ * applicable tests, and post findings via post_note (with `pr_url` set to the
12
+ * source PR so the original collect() picks them up).
13
+ *
14
+ * The review plan is automatically approved (skipping the AskUserQuestion
15
+ * step) because the user already approved the parent fleet. If they want a
16
+ * confirmation per review, they can set `auto_approve: false`.
17
+ */
18
+ export function registerReview(server, store, audit) {
19
+ server.tool("review_prs", "Spawn a reviewer agent for each PR produced by a completed plan. Creates a NEW plan (the 'review plan') whose tasks dispatch via the normal next_task/spawn_task loop. Auto-approved by default — pass `auto_approve: false` to require a fresh user approval. Source plan's review_plan_id is updated so you can trace the relationship.", {
20
+ plan_id: z.string().describe("Plan id of the COMPLETED fleet whose PRs should be reviewed."),
21
+ auto_approve: z.boolean().default(true).describe("Skip the user approval gate. The parent fleet already had an approval; this is asking 'do you want a separate prompt for reviewing your own PRs?' Default false-equivalent is to do request_approval/confirm manually."),
22
+ budget_cap_tokens: z.number().int().positive().default(300_000).describe("Token budget for the review fleet."),
23
+ }, audit.wrap("review_prs", async ({ plan_id, auto_approve, budget_cap_tokens }) => {
24
+ const result = await store.update((state) => {
25
+ const source = findPlan(state, plan_id);
26
+ const prTasks = source.tasks.filter((t) => t.prUrl);
27
+ if (prTasks.length === 0) {
28
+ return { created: false, note: "No PRs to review yet. Agents must call post_note with a pr_url first." };
29
+ }
30
+ const reviewTasks = prTasks.map((t) => ({
31
+ title: `Review: ${truncate(t.title, 50)}`,
32
+ prompt: buildReviewPrompt(t.prUrl, t.title, source.rootTask),
33
+ tldr: `Review the PR opened for "${t.title}".`,
34
+ scope: [t.prUrl],
35
+ }));
36
+ const reviewPlan = newPlan(`Review of PRs from plan ${plan_id}`, budget_cap_tokens, reviewTasks);
37
+ const est = estimateAgent(source.modelForEstimate ?? "claude-sonnet-4-6", source.effortMultiplier ?? 0.6);
38
+ reviewPlan.estimatedTokens = est.tokens.totalEffective * reviewPlan.tasks.length;
39
+ reviewPlan.estimatedCostUsd = est.costUsd * reviewPlan.tasks.length;
40
+ reviewPlan.estimatedDurationSec = 60 * 3; // reviewers are typically shorter than implementers
41
+ reviewPlan.modelForEstimate = source.modelForEstimate;
42
+ reviewPlan.effortMultiplier = 0.6;
43
+ if (auto_approve) {
44
+ reviewPlan.status = "approved";
45
+ reviewPlan.approvedAt = Date.now();
46
+ }
47
+ state.plans[reviewPlan.id] = reviewPlan;
48
+ source.reviewPlanId = reviewPlan.id;
49
+ return {
50
+ created: true,
51
+ review_plan_id: reviewPlan.id,
52
+ source_plan_id: plan_id,
53
+ task_count: reviewPlan.tasks.length,
54
+ status: reviewPlan.status,
55
+ estimated_tokens: reviewPlan.estimatedTokens,
56
+ next_step: auto_approve
57
+ ? "Loop next_task → spawn_task for each reviewer just like the parent fleet. Reviewers will post their findings as notes."
58
+ : "Call request_approval on the review plan to get a user prompt, then confirm.",
59
+ };
60
+ });
61
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
62
+ }, ({ plan_id }) => ({ planId: plan_id })));
63
+ }
64
+ function buildReviewPrompt(prUrl, originalTitle, rootTask) {
65
+ return `Review the pull request: ${prUrl}
66
+
67
+ Context: this PR was produced by an orqlaude fleet member working on the task "${originalTitle}", part of the larger effort: "${rootTask}".
68
+
69
+ Your job:
70
+ 1. Fetch the PR locally: \`gh pr checkout <number>\` or \`gh pr view ${prUrl} --json files,title,body\`.
71
+ 2. Read the diff. Walk every changed file. Don't trust the description; verify against the code.
72
+ 3. Check for:
73
+ - Bugs (off-by-one, null handling, race conditions, error swallowing)
74
+ - Missed tests (any new logic without coverage?)
75
+ - Design issues (does the change fit the surrounding code's idioms?)
76
+ - Security concerns (input validation, secret handling, injection vectors)
77
+ - Documentation gaps
78
+ 4. Run the project's test suite if there is one (\`npm test\`, \`pytest\`, etc.). Report failures.
79
+ 5. Post your findings via \`mcp__orqlaude__post_note\` with:
80
+ - \`session_id\`: your session id (self-register first via checkin with the task_id below).
81
+ - \`text\`: a concise review. Bullet points. Severity-tagged: [BLOCKER], [CONCERN], [NIT].
82
+ - \`pr_url\`: ${prUrl} (so the orchestrator attaches it to your task)
83
+ 6. If you find a [BLOCKER], also leave a GitHub review comment via \`gh pr review <pr> -c -b "..."\` so the human sees it inline.
84
+
85
+ Be specific. "Looks good" is not a review. If you have nothing to say, say "No issues found — read N files, all match the surrounding style and have test coverage."
86
+ `;
87
+ }
88
+ function truncate(s, n) {
89
+ if (s.length <= n)
90
+ return s;
91
+ return s.slice(0, n - 1) + "…";
92
+ }
93
+ //# sourceMappingURL=review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.js","sourceRoot":"","sources":["../../src/tools/review.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAc,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;;;;;;;;;;;GAaG;AAEH,MAAM,UAAU,cAAc,CAAC,MAAiB,EAAE,KAAiB,EAAE,KAAe;IAClF,MAAM,CAAC,IAAI,CACT,YAAY,EACZ,2UAA2U,EAC3U;QACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8DAA8D,CAAC;QAC5F,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,wNAAwN,CAAC;QAC1Q,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,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AAE,OAAO,EAAE,CAAC,CACvC,CACF,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa,EAAE,aAAqB,EAAE,QAAgB;IAC/E,OAAO,4BAA4B,KAAK;;iFAEuC,aAAa,kCAAkC,QAAQ;;;uEAGjE,KAAK;;;;;;;;;;;;mBAYzD,KAAK;;;;CAIvB,CAAC;AACF,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IACpC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC5B,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;AACjC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@synaplink/orqlaude",
3
+ "version": "0.3.0",
4
+ "description": "Multi-agent orchestrator for Claude Code. One primary session decomposes a complex task, gets a single budget approval, then dispatches N parallel agents via the Desktop app's native spawn_task. Tracks cost/status via JSONL tails; brokers messages between agents; detects hallucination; manages PRs.",
5
+ "type": "module",
6
+ "bin": {
7
+ "orqlaude": "./dist/cli.js"
8
+ },
9
+ "main": "./dist/server.js",
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ ".mcp.json.template"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc && chmod +x dist/cli.js dist/server.js",
17
+ "dev": "tsc --watch",
18
+ "start": "node dist/server.js",
19
+ "typecheck": "tsc --noEmit",
20
+ "test": "tsc && chmod +x dist/cli.js dist/server.js && node --test dist/__tests__/*.test.js",
21
+ "prepublishOnly": "npm run build"
22
+ },
23
+ "keywords": [
24
+ "claude",
25
+ "claude-code",
26
+ "mcp",
27
+ "orchestrator",
28
+ "multi-agent",
29
+ "agents",
30
+ "anthropic"
31
+ ],
32
+ "author": "SynapLink",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/SynapLink/orqlaude.git"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/SynapLink/orqlaude/issues"
40
+ },
41
+ "homepage": "https://github.com/SynapLink/orqlaude#readme",
42
+ "dependencies": {
43
+ "@modelcontextprotocol/sdk": "^1.0.4",
44
+ "zod": "^3.23.8"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^22.7.5",
48
+ "typescript": "^5.6.3"
49
+ },
50
+ "engines": {
51
+ "node": ">=22"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ }
56
+ }