opencode-swarm-plugin 0.12.26 → 0.12.27

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.
@@ -0,0 +1,31 @@
1
+ name: opencode
2
+
3
+ on:
4
+ issue_comment:
5
+ types: [created]
6
+ pull_request_review_comment:
7
+ types: [created]
8
+
9
+ jobs:
10
+ opencode:
11
+ if: |
12
+ contains(github.event.comment.body, ' /oc') ||
13
+ startsWith(github.event.comment.body, '/oc') ||
14
+ contains(github.event.comment.body, ' /opencode') ||
15
+ startsWith(github.event.comment.body, '/opencode')
16
+ runs-on: ubuntu-latest
17
+ permissions:
18
+ id-token: write
19
+ contents: read
20
+ pull-requests: read
21
+ issues: read
22
+ steps:
23
+ - name: Checkout repository
24
+ uses: actions/checkout@v4
25
+
26
+ - name: Run opencode
27
+ uses: sst/opencode/github@latest
28
+ env:
29
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
30
+ with:
31
+ model: anthropic/claude-sonnet-4-5
package/bin/swarm.ts CHANGED
@@ -1072,6 +1072,79 @@ async function setup() {
1072
1072
  }
1073
1073
  }
1074
1074
 
1075
+ // Offer to update AGENTS.md with skill awareness
1076
+ const agentsPath = join(configDir, "AGENTS.md");
1077
+ if (existsSync(agentsPath)) {
1078
+ const updateAgents = await p.confirm({
1079
+ message: "Update AGENTS.md with skill awareness?",
1080
+ initialValue: true,
1081
+ });
1082
+
1083
+ if (!p.isCancel(updateAgents) && updateAgents) {
1084
+ const s = p.spinner();
1085
+ s.start("Updating AGENTS.md...");
1086
+
1087
+ const agentsPrompt = `You are updating the user's AGENTS.md file to add skill awareness.
1088
+
1089
+ ## Task
1090
+ Read ${agentsPath} and add a Skills section if one doesn't exist. If a skills section exists, update it.
1091
+
1092
+ ## What to Add
1093
+
1094
+ 1. **Tool Preferences** - If there's a tool_preferences or similar section, add skills tools:
1095
+ - skills_list - discover available skills
1096
+ - skills_use - load skill for context injection
1097
+ - skills_read - read full skill content
1098
+
1099
+ 2. **Skills Section** - Add this (adapt style to match the file):
1100
+
1101
+ ### Skills (Knowledge Injection)
1102
+
1103
+ Skills are reusable knowledge packages. Load them on-demand for specialized tasks.
1104
+
1105
+ **When to Use:**
1106
+ - Before unfamiliar work - check if a skill exists
1107
+ - When you need domain-specific patterns
1108
+ - For complex workflows that benefit from guidance
1109
+
1110
+ **Usage:**
1111
+ \`\`\`
1112
+ skills_list() # See available skills
1113
+ skills_use(name="debugging") # Load a skill
1114
+ skills_use(name="code-review", context="reviewing auth") # With context
1115
+ \`\`\`
1116
+
1117
+ **Bundled Skills:** agent-patterns, cli-builder, code-review, debugging, learning-systems, mcp-tool-authoring, resilience-patterns, skill-creator, swarm-coordination, tacit-knowledge-extraction, testing-strategies, zod-validation
1118
+
1119
+ ## Rules
1120
+ - Preserve existing content and style
1121
+ - Don't duplicate - update if skills section exists
1122
+ - Keep tone consistent
1123
+ - Place near tool preferences or as logical new section
1124
+
1125
+ Edit the file now.`;
1126
+
1127
+ try {
1128
+ const result = Bun.spawnSync(["opencode", "run", agentsPrompt], {
1129
+ stdout: "pipe",
1130
+ stderr: "pipe",
1131
+ timeout: 120000,
1132
+ });
1133
+
1134
+ if (result.exitCode === 0) {
1135
+ s.stop("AGENTS.md updated");
1136
+ p.log.success("Added skill awareness to AGENTS.md");
1137
+ } else {
1138
+ s.stop("Could not update AGENTS.md");
1139
+ p.log.warn("You can manually add skills section later");
1140
+ }
1141
+ } catch {
1142
+ s.stop("Could not update AGENTS.md");
1143
+ p.log.warn("You can manually add skills section later");
1144
+ }
1145
+ }
1146
+ }
1147
+
1075
1148
  p.note(
1076
1149
  'cd your-project\nbd init\nopencode\n/swarm "your task"\n\nSkills: Use skills_list to see available skills',
1077
1150
  "Next steps",
@@ -1351,6 +1424,7 @@ ${cyan("Commands:")}
1351
1424
  swarm doctor Health check - shows status of all dependencies
1352
1425
  swarm init Initialize beads in current project
1353
1426
  swarm config Show paths to generated config files
1427
+ swarm agents Update AGENTS.md with skill awareness
1354
1428
  swarm update Update to latest version
1355
1429
  swarm version Show version and banner
1356
1430
  swarm tool Execute a tool (for plugin wrapper)
@@ -1525,6 +1599,131 @@ async function listTools() {
1525
1599
  );
1526
1600
  }
1527
1601
 
1602
+ // ============================================================================
1603
+ // Agents Command - Update AGENTS.md with skill awareness
1604
+ // ============================================================================
1605
+
1606
+ async function agents() {
1607
+ const home = process.env.HOME || process.env.USERPROFILE || "~";
1608
+ const agentsPath = join(home, ".config", "opencode", "AGENTS.md");
1609
+
1610
+ p.intro(yellow(BANNER));
1611
+
1612
+ // Check if AGENTS.md exists
1613
+ if (!existsSync(agentsPath)) {
1614
+ p.log.warn("No AGENTS.md found at " + agentsPath);
1615
+ p.log.message(
1616
+ dim("Create one first, then run this command to add skill awareness"),
1617
+ );
1618
+ p.outro("Aborted");
1619
+ return;
1620
+ }
1621
+
1622
+ // Check if opencode is available
1623
+ const opencode = await checkCommand("opencode", ["--version"]);
1624
+ if (!opencode.available) {
1625
+ p.log.error("OpenCode not found");
1626
+ p.log.message(dim("Install: npm install -g opencode"));
1627
+ p.outro("Aborted");
1628
+ return;
1629
+ }
1630
+
1631
+ const confirm = await p.confirm({
1632
+ message: "Update AGENTS.md with skill awareness?",
1633
+ initialValue: true,
1634
+ });
1635
+
1636
+ if (p.isCancel(confirm) || !confirm) {
1637
+ p.outro("Aborted");
1638
+ return;
1639
+ }
1640
+
1641
+ const s = p.spinner();
1642
+ s.start("Updating AGENTS.md with skill awareness...");
1643
+
1644
+ const prompt = `You are updating the user's AGENTS.md file to add skill awareness.
1645
+
1646
+ ## Task
1647
+ Read ~/.config/opencode/AGENTS.md and add a Skills section if one doesn't exist.
1648
+
1649
+ ## What to Add
1650
+ Add a section about using skills. Include:
1651
+
1652
+ 1. **Tool Preferences Update** - Add skills_* tools to the tool priority list:
1653
+ - skills_list - discover available skills
1654
+ - skills_use - load skill for context injection
1655
+ - skills_read - read full skill content
1656
+
1657
+ 2. **Skills Section** - Add this section (adapt to match the file's style):
1658
+
1659
+ ### Skills (Knowledge Injection)
1660
+
1661
+ Skills are reusable knowledge packages. Load them on-demand for specialized tasks.
1662
+
1663
+ **When to Use Skills:**
1664
+ - Before starting unfamiliar work - check if a skill exists
1665
+ - When you need domain-specific patterns
1666
+ - For complex workflows that benefit from guidance
1667
+
1668
+ **Available Skills** (run \`skills_list()\` to see current list):
1669
+ - agent-patterns: AI agent design patterns
1670
+ - cli-builder: TypeScript CLI patterns
1671
+ - code-review: Review checklists
1672
+ - debugging: Root cause analysis
1673
+ - learning-systems: Feedback scoring, pattern maturity
1674
+ - mcp-tool-authoring: Building MCP tools
1675
+ - resilience-patterns: Error recovery, retries
1676
+ - skill-creator: Creating new skills
1677
+ - swarm-coordination: Multi-agent workflows
1678
+ - tacit-knowledge-extraction: Pattern mining
1679
+ - testing-strategies: Vitest patterns
1680
+ - zod-validation: Schema validation
1681
+
1682
+ **Usage Pattern:**
1683
+ \`\`\`
1684
+ # Check what's available
1685
+ skills_list()
1686
+
1687
+ # Load a skill before starting work
1688
+ skills_use(name="debugging")
1689
+
1690
+ # Load with context
1691
+ skills_use(name="code-review", context="reviewing auth changes")
1692
+ \`\`\`
1693
+
1694
+ ## Rules
1695
+ - Preserve the existing content and style
1696
+ - Add the skills section in a logical place (near tool preferences or as a new section)
1697
+ - Don't duplicate if a skills section already exists - update it instead
1698
+ - Keep the tone consistent with the rest of the file
1699
+
1700
+ Edit the file now.`;
1701
+
1702
+ try {
1703
+ const result = Bun.spawnSync(["opencode", "run", prompt], {
1704
+ stdio: ["inherit", "pipe", "pipe"],
1705
+ timeout: 120000, // 2 minute timeout
1706
+ });
1707
+
1708
+ if (result.exitCode === 0) {
1709
+ s.stop("AGENTS.md updated with skill awareness");
1710
+ p.log.success("Skills section added to " + agentsPath);
1711
+ p.log.message(
1712
+ dim("Skills available: skills_list, skills_use, skills_read"),
1713
+ );
1714
+ } else {
1715
+ const stderr = result.stderr?.toString() || "";
1716
+ s.stop("Failed to update AGENTS.md");
1717
+ p.log.error(stderr || "Unknown error");
1718
+ }
1719
+ } catch (error) {
1720
+ s.stop("Failed to update AGENTS.md");
1721
+ p.log.error(String(error));
1722
+ }
1723
+
1724
+ p.outro("Done");
1725
+ }
1726
+
1528
1727
  // ============================================================================
1529
1728
  // Main
1530
1729
  // ============================================================================
@@ -1560,6 +1759,9 @@ switch (command) {
1560
1759
  }
1561
1760
  break;
1562
1761
  }
1762
+ case "agents":
1763
+ await agents();
1764
+ break;
1563
1765
  case "version":
1564
1766
  case "--version":
1565
1767
  case "-v":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm-plugin",
3
- "version": "0.12.26",
3
+ "version": "0.12.27",
4
4
  "description": "Multi-agent swarm coordination for OpenCode with learning capabilities, beads integration, and Agent Mail",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",