cortex-agents 2.3.1 → 4.0.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 (70) hide show
  1. package/.opencode/agents/{plan.md → architect.md} +104 -58
  2. package/.opencode/agents/audit.md +183 -0
  3. package/.opencode/agents/{fullstack.md → coder.md} +10 -54
  4. package/.opencode/agents/debug.md +76 -201
  5. package/.opencode/agents/devops.md +16 -123
  6. package/.opencode/agents/docs-writer.md +195 -0
  7. package/.opencode/agents/fix.md +207 -0
  8. package/.opencode/agents/implement.md +433 -0
  9. package/.opencode/agents/perf.md +151 -0
  10. package/.opencode/agents/refactor.md +163 -0
  11. package/.opencode/agents/security.md +20 -85
  12. package/.opencode/agents/testing.md +1 -151
  13. package/.opencode/skills/data-engineering/SKILL.md +221 -0
  14. package/.opencode/skills/monitoring-observability/SKILL.md +251 -0
  15. package/README.md +315 -224
  16. package/dist/cli.js +85 -17
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +60 -22
  19. package/dist/registry.d.ts +8 -3
  20. package/dist/registry.d.ts.map +1 -1
  21. package/dist/registry.js +16 -2
  22. package/dist/tools/branch.d.ts +2 -2
  23. package/dist/tools/cortex.d.ts +2 -2
  24. package/dist/tools/cortex.js +7 -7
  25. package/dist/tools/docs.d.ts +2 -2
  26. package/dist/tools/environment.d.ts +31 -0
  27. package/dist/tools/environment.d.ts.map +1 -0
  28. package/dist/tools/environment.js +93 -0
  29. package/dist/tools/github.d.ts +42 -0
  30. package/dist/tools/github.d.ts.map +1 -0
  31. package/dist/tools/github.js +200 -0
  32. package/dist/tools/plan.d.ts +28 -4
  33. package/dist/tools/plan.d.ts.map +1 -1
  34. package/dist/tools/plan.js +232 -4
  35. package/dist/tools/quality-gate.d.ts +28 -0
  36. package/dist/tools/quality-gate.d.ts.map +1 -0
  37. package/dist/tools/quality-gate.js +233 -0
  38. package/dist/tools/repl.d.ts +55 -0
  39. package/dist/tools/repl.d.ts.map +1 -0
  40. package/dist/tools/repl.js +291 -0
  41. package/dist/tools/task.d.ts +2 -0
  42. package/dist/tools/task.d.ts.map +1 -1
  43. package/dist/tools/task.js +25 -30
  44. package/dist/tools/worktree.d.ts +5 -32
  45. package/dist/tools/worktree.d.ts.map +1 -1
  46. package/dist/tools/worktree.js +75 -447
  47. package/dist/utils/change-scope.d.ts +33 -0
  48. package/dist/utils/change-scope.d.ts.map +1 -0
  49. package/dist/utils/change-scope.js +198 -0
  50. package/dist/utils/github.d.ts +104 -0
  51. package/dist/utils/github.d.ts.map +1 -0
  52. package/dist/utils/github.js +243 -0
  53. package/dist/utils/ide.d.ts +76 -0
  54. package/dist/utils/ide.d.ts.map +1 -0
  55. package/dist/utils/ide.js +307 -0
  56. package/dist/utils/plan-extract.d.ts +28 -0
  57. package/dist/utils/plan-extract.d.ts.map +1 -1
  58. package/dist/utils/plan-extract.js +90 -1
  59. package/dist/utils/repl.d.ts +145 -0
  60. package/dist/utils/repl.d.ts.map +1 -0
  61. package/dist/utils/repl.js +547 -0
  62. package/dist/utils/terminal.d.ts +53 -1
  63. package/dist/utils/terminal.d.ts.map +1 -1
  64. package/dist/utils/terminal.js +642 -5
  65. package/package.json +1 -1
  66. package/.opencode/agents/build.md +0 -294
  67. package/.opencode/agents/review.md +0 -314
  68. package/dist/plugin.d.ts +0 -1
  69. package/dist/plugin.d.ts.map +0 -1
  70. package/dist/plugin.js +0 -4
@@ -2,35 +2,12 @@ import { tool } from "@opencode-ai/plugin";
2
2
  import * as fs from "fs";
3
3
  import * as path from "path";
4
4
  import { detectWorktreeInfo } from "../utils/worktree-detect.js";
5
- import { findPlanContent, extractPlanSections, buildPrBodyFromPlan, } from "../utils/plan-extract.js";
6
- import { git, gh, which } from "../utils/shell.js";
5
+ import { findPlanContent, extractPlanSections, extractIssueRefs, buildPrBodyFromPlan, } from "../utils/plan-extract.js";
6
+ import { git, gh } from "../utils/shell.js";
7
+ import { checkGhAvailability } from "../utils/github.js";
7
8
  const PROTECTED_BRANCHES = ["main", "master", "develop", "production", "staging"];
8
9
  const DOCS_DIR = "docs";
9
10
  // ─── Helpers ─────────────────────────────────────────────────────────────────
10
- /**
11
- * Check if `gh` CLI is installed and authenticated.
12
- */
13
- async function checkGhCli(cwd) {
14
- // Check if gh exists
15
- const ghPath = await which("gh");
16
- if (!ghPath) {
17
- return {
18
- ok: false,
19
- error: "GitHub CLI (gh) is not installed. Install it from https://cli.github.com/ and run `gh auth login`.",
20
- };
21
- }
22
- // Check if authenticated
23
- try {
24
- await gh(cwd, "auth", "status");
25
- }
26
- catch {
27
- return {
28
- ok: false,
29
- error: "GitHub CLI is not authenticated. Run `gh auth login` to authenticate.",
30
- };
31
- }
32
- return { ok: true };
33
- }
34
11
  /**
35
12
  * Check if a remote named "origin" is configured.
36
13
  */
@@ -117,9 +94,13 @@ export const finalize = tool({
117
94
  .boolean()
118
95
  .optional()
119
96
  .describe("Create as draft PR (default: false)"),
97
+ issueRefs: tool.schema
98
+ .array(tool.schema.number())
99
+ .optional()
100
+ .describe("GitHub issue numbers to link in PR body (adds 'Closes #N' for each)"),
120
101
  },
121
102
  async execute(args, context) {
122
- const { commitMessage, prTitle, prBody: customPrBody, baseBranch: customBaseBranch, planFilename, draft = false, } = args;
103
+ const { commitMessage, prTitle, prBody: customPrBody, baseBranch: customBaseBranch, planFilename, draft = false, issueRefs: explicitIssueRefs, } = args;
123
104
  const cwd = context.worktree;
124
105
  const output = [];
125
106
  const warnings = [];
@@ -162,9 +143,12 @@ Create a feature/bugfix branch first with branch_create or worktree_create.`;
162
143
  output.push(`Worktree detected (main tree: ${wtInfo.mainWorktreePath})`);
163
144
  }
164
145
  // ── 4. Check prerequisites ────────────────────────────────
165
- const ghCheck = await checkGhCli(cwd);
166
- if (!ghCheck.ok) {
167
- return `✗ ${ghCheck.error}`;
146
+ const ghStatus = await checkGhAvailability(cwd);
147
+ if (!ghStatus.installed) {
148
+ return "✗ GitHub CLI (gh) is not installed. Install it from https://cli.github.com/ and run `gh auth login`.";
149
+ }
150
+ if (!ghStatus.authenticated) {
151
+ return "✗ GitHub CLI is not authenticated. Run `gh auth login` to authenticate.";
168
152
  }
169
153
  const remoteCheck = await checkRemote(cwd);
170
154
  if (!remoteCheck.ok) {
@@ -218,6 +202,7 @@ All previous steps succeeded (changes committed). Try pushing manually:
218
202
  }
219
203
  // ── 9. Build PR body ──────────────────────────────────────
220
204
  let prBodyContent = customPrBody || "";
205
+ let issueRefs = explicitIssueRefs ?? [];
221
206
  if (!prBodyContent) {
222
207
  // Try to build from plan
223
208
  const plan = findPlanContent(cwd, planFilename, branchName);
@@ -225,6 +210,10 @@ All previous steps succeeded (changes committed). Try pushing manually:
225
210
  const sections = extractPlanSections(plan.content, plan.filename);
226
211
  prBodyContent = buildPrBodyFromPlan(sections);
227
212
  output.push(`PR body generated from plan: ${plan.filename}`);
213
+ // Extract issue refs from plan frontmatter if not explicitly provided
214
+ if (issueRefs.length === 0) {
215
+ issueRefs = extractIssueRefs(plan.content);
216
+ }
228
217
  }
229
218
  else {
230
219
  // Fall back to commit log
@@ -237,6 +226,12 @@ All previous steps succeeded (changes committed). Try pushing manually:
237
226
  }
238
227
  }
239
228
  }
229
+ // Append issue closing references to PR body
230
+ if (issueRefs.length > 0) {
231
+ const closingRefs = issueRefs.map((n) => `Closes #${n}`).join("\n");
232
+ prBodyContent += `\n\n## Linked Issues\n\n${closingRefs}`;
233
+ output.push(`Linked issues: ${issueRefs.map((n) => `#${n}`).join(", ")}`);
234
+ }
240
235
  // ── 10. Create PR via gh ──────────────────────────────────
241
236
  const finalPrTitle = prTitle || commitMessage;
242
237
  let prUrl = "";
@@ -1,6 +1,5 @@
1
1
  import type { PluginInput } from "@opencode-ai/plugin";
2
2
  type Client = PluginInput["client"];
3
- type Shell = PluginInput["$"];
4
3
  /**
5
4
  * Factory function that creates the worktree_create tool with access
6
5
  * to the OpenCode client for toast notifications.
@@ -10,18 +9,20 @@ export declare function createCreate(client: Client): {
10
9
  args: {
11
10
  name: import("zod").ZodString;
12
11
  type: import("zod").ZodEnum<{
12
+ refactor: "refactor";
13
13
  feature: "feature";
14
14
  bugfix: "bugfix";
15
15
  hotfix: "hotfix";
16
- refactor: "refactor";
17
16
  spike: "spike";
18
17
  docs: "docs";
19
18
  test: "test";
20
19
  }>;
20
+ fromBranch: import("zod").ZodOptional<import("zod").ZodString>;
21
21
  };
22
22
  execute(args: {
23
23
  name: string;
24
- type: "feature" | "bugfix" | "hotfix" | "refactor" | "spike" | "docs" | "test";
24
+ type: "refactor" | "feature" | "bugfix" | "hotfix" | "spike" | "docs" | "test";
25
+ fromBranch?: string | undefined;
25
26
  }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
26
27
  };
27
28
  export declare const list: {
@@ -31,7 +32,7 @@ export declare const list: {
31
32
  };
32
33
  /**
33
34
  * Factory function that creates the worktree_remove tool with access
34
- * to the OpenCode client for toast notifications and PTY cleanup.
35
+ * to the OpenCode client for toast notifications.
35
36
  */
36
37
  export declare function createRemove(client: Client): {
37
38
  description: string;
@@ -53,33 +54,5 @@ export declare const open: {
53
54
  name: string;
54
55
  }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
55
56
  };
56
- /**
57
- * Factory function that creates the worktree_launch tool with access
58
- * to the OpenCode client (for PTY and toast) and shell.
59
- *
60
- * This uses a closure to capture `client` and `shell` since ToolContext
61
- * does not provide access to the OpenCode client API.
62
- */
63
- export declare function createLaunch(client: Client, shell: Shell): {
64
- description: string;
65
- args: {
66
- name: import("zod").ZodString;
67
- mode: import("zod").ZodEnum<{
68
- terminal: "terminal";
69
- pty: "pty";
70
- background: "background";
71
- }>;
72
- plan: import("zod").ZodOptional<import("zod").ZodString>;
73
- agent: import("zod").ZodOptional<import("zod").ZodString>;
74
- prompt: import("zod").ZodOptional<import("zod").ZodString>;
75
- };
76
- execute(args: {
77
- name: string;
78
- mode: "terminal" | "pty" | "background";
79
- plan?: string | undefined;
80
- agent?: string | undefined;
81
- prompt?: string | undefined;
82
- }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
83
- };
84
57
  export {};
85
58
  //# sourceMappingURL=worktree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/tools/worktree.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAiBvD,KAAK,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AACpC,KAAK,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;AAE9B;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;EAuF1C;AAED,eAAO,MAAM,IAAI;;;;CAiCf,CAAC;AAEH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;EAkI1C;AAED,eAAO,MAAM,IAAI;;;;;;;;CAgDf,CAAC;AAkUH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;;;;;;;;;;;;;;;;;;;;EAsIxD"}
1
+ {"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../src/tools/worktree.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQvD,KAAK,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AAEpC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;EA0H1C;AAED,eAAO,MAAM,IAAI;;;;CAiCf,CAAC;AAEH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;EA0F1C;AAED,eAAO,MAAM,IAAI;;;;;;;;CAgDf,CAAC"}