@simplium/hive 4.0.0 → 4.2.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 (61) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/README.md +20 -13
  3. package/bin/hive-init.mjs +9 -2
  4. package/dist/claude/agents/ai-ml-engineer.md +1 -1
  5. package/dist/claude/agents/api-designer.md +1 -1
  6. package/dist/claude/agents/architecture-planner.md +1 -1
  7. package/dist/claude/agents/backend-developer.md +1 -1
  8. package/dist/claude/agents/billing-payments.md +1 -1
  9. package/dist/claude/agents/competitive-intelligence.md +1 -1
  10. package/dist/claude/agents/cost-optimization.md +1 -1
  11. package/dist/claude/agents/customer-success.md +1 -1
  12. package/dist/claude/agents/data-analyst.md +1 -1
  13. package/dist/claude/agents/database-engineer.md +1 -1
  14. package/dist/claude/agents/frontend-developer.md +1 -1
  15. package/dist/claude/agents/incident-response.md +1 -1
  16. package/dist/claude/agents/legal-compliance.md +1 -1
  17. package/dist/claude/agents/orchestrator.md +1 -1
  18. package/dist/claude/agents/product-manager.md +1 -1
  19. package/dist/claude/agents/security-auditor.md +1 -1
  20. package/dist/claude/agents/test-engineer.md +1 -1
  21. package/dist/claude/agents/ux-research.md +1 -1
  22. package/dist/claude/skills/accessibility.md +1 -1
  23. package/dist/claude/skills/analytics-implementation.md +1 -1
  24. package/dist/claude/skills/brand-design-system.md +1 -1
  25. package/dist/claude/skills/cloud-infrastructure.md +1 -1
  26. package/dist/claude/skills/devops-engineer.md +1 -1
  27. package/dist/claude/skills/documentation-writer.md +1 -1
  28. package/dist/claude/skills/email-deliverability.md +1 -1
  29. package/dist/claude/skills/growth-analytics.md +1 -1
  30. package/dist/claude/skills/landing-page-cro.md +1 -1
  31. package/dist/claude/skills/marketing-communications.md +1 -1
  32. package/dist/claude/skills/mobile-development.md +1 -1
  33. package/dist/claude/skills/observability.md +1 -1
  34. package/dist/claude/skills/release-manager.md +1 -1
  35. package/dist/claude/skills/search.md +1 -1
  36. package/dist/claude/skills/seo-aeo-geo.md +1 -1
  37. package/dist/claude/skills/translator-i18n.md +1 -1
  38. package/dist/claude/skills/voice-ai.md +1 -1
  39. package/dist/claude/skills/web-performance.md +1 -1
  40. package/dist/opencode/agents/ai-ml-engineer.md +3256 -0
  41. package/dist/opencode/agents/api-designer.md +2426 -0
  42. package/dist/opencode/agents/architecture-planner.md +3273 -0
  43. package/dist/opencode/agents/backend-developer.md +1502 -0
  44. package/dist/opencode/agents/billing-payments.md +2059 -0
  45. package/dist/opencode/agents/competitive-intelligence.md +2700 -0
  46. package/dist/opencode/agents/cost-optimization.md +1341 -0
  47. package/dist/opencode/agents/customer-success.md +3386 -0
  48. package/dist/opencode/agents/data-analyst.md +1765 -0
  49. package/dist/opencode/agents/database-engineer.md +1758 -0
  50. package/dist/opencode/agents/frontend-developer.md +3429 -0
  51. package/dist/opencode/agents/incident-response.md +1779 -0
  52. package/dist/opencode/agents/legal-compliance.md +2975 -0
  53. package/dist/opencode/agents/orchestrator.md +1837 -0
  54. package/dist/opencode/agents/product-manager.md +1252 -0
  55. package/dist/opencode/agents/security-auditor.md +333 -0
  56. package/dist/opencode/agents/test-engineer.md +1608 -0
  57. package/dist/opencode/agents/ux-research.md +2568 -0
  58. package/dist/opencode/plugins/hive-log.js +110 -0
  59. package/hooks/opencode-hive-log.d.ts +21 -0
  60. package/hooks/opencode-hive-log.js +110 -0
  61. package/package.json +2 -2
@@ -0,0 +1,110 @@
1
+ /**
2
+ * HIVE traceability plugin for OpenCode (parity with the Claude Code hook).
3
+ *
4
+ * Auto-loaded from .opencode/plugins/. When a HIVE agent runs as a subagent
5
+ * via the `task` tool, appends:
6
+ * - a row to HIVE-LOG.md (ISO 42001 A.9 audit trail)
7
+ * - a line to .opencode/hive-events.jsonl (machine-readable event stream)
8
+ *
9
+ * Design constraints (same as the CC hook):
10
+ * - Zero dependencies (node:fs/node:path only — Bun supports node: imports).
11
+ * - Never throws: a logging plugin must never break the tool flow.
12
+ * - Only logs HIVE agents (version stamp check in the adapter file).
13
+ *
14
+ * Implementation note: `tool.execute.before` receives the tool args
15
+ * (input.tool + output.args, per opencode.ai/docs/plugins); the args are
16
+ * captured per callID there and the log row is written on
17
+ * `tool.execute.after` (completion), so we don't depend on the undocumented
18
+ * shape of the after-payload. Tool id and arg names (`task`, `subagent_type`,
19
+ * `description`) verified against sst/opencode source (src/tool/task.ts).
20
+ */
21
+
22
+ import { readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync } from "node:fs";
23
+ import { join, dirname } from "node:path";
24
+
25
+ const LOG_HEADER = `# HIVE Session Log
26
+
27
+ AI agent invocation log for traceability (ISO 42001 A.9 — logging of AI decision-making events).
28
+
29
+ Rows are appended automatically by the HIVE hook (Claude Code) / plugin (OpenCode).
30
+ Manual fallback: \`npm run log-session -- --agent <name> --task "..." --outcome COMPLETED|PARTIAL|FAILED [--tokens N]\`
31
+
32
+ | Date | Agent | Task | Outcome | Tokens |
33
+ |------|-------|------|---------|--------|
34
+ `;
35
+
36
+ function sanitizeCell(text, maxLen = 120) {
37
+ return String(text ?? "")
38
+ .replace(/\s+/g, " ")
39
+ .replace(/\|/g, "\\|")
40
+ .trim()
41
+ .slice(0, maxLen);
42
+ }
43
+
44
+ function isHiveAgent(projectDir, agent) {
45
+ if (!agent || !/^[a-z][a-z0-9-]*$/.test(agent)) return false;
46
+ for (const rel of [join(".opencode", "agents"), join(".claude", "agents")]) {
47
+ const p = join(projectDir, rel, `${agent}.md`);
48
+ if (existsSync(p) && readFileSync(p, "utf-8").slice(0, 2000).includes("HIVE Framework v")) return true;
49
+ }
50
+ return false;
51
+ }
52
+
53
+ function logInvocation(projectDir, agent, task) {
54
+ const date = new Date().toISOString().split("T")[0];
55
+ const row = `| ${date} | ${agent} | ${sanitizeCell(task)} | COMPLETED | — |`;
56
+
57
+ const logPath = join(projectDir, "HIVE-LOG.md");
58
+ if (existsSync(logPath)) {
59
+ writeFileSync(logPath, readFileSync(logPath, "utf-8").trimEnd() + "\n" + row + "\n", "utf-8");
60
+ } else {
61
+ writeFileSync(logPath, LOG_HEADER + row + "\n", "utf-8");
62
+ }
63
+
64
+ const eventsPath = join(projectDir, ".opencode", "hive-events.jsonl");
65
+ mkdirSync(dirname(eventsPath), { recursive: true });
66
+ appendFileSync(
67
+ eventsPath,
68
+ JSON.stringify({
69
+ ts: new Date().toISOString(),
70
+ event: "hive_agent_invocation",
71
+ agent,
72
+ task: sanitizeCell(task),
73
+ runtime: "opencode",
74
+ }) + "\n",
75
+ "utf-8",
76
+ );
77
+ }
78
+
79
+ export const HiveLogPlugin = async ({ directory }) => {
80
+ const projectDir = directory || process.cwd();
81
+ const pending = new Map(); // callID → { agent, task }
82
+
83
+ return {
84
+ "tool.execute.before": async (input, output) => {
85
+ try {
86
+ if (input?.tool !== "task") return;
87
+ const args = output?.args ?? {};
88
+ const agent = args.subagent_type;
89
+ if (!isHiveAgent(projectDir, agent)) return;
90
+ const key = input?.callID ?? `${agent}:${Date.now()}`;
91
+ pending.set(key, { agent, task: args.description || args.prompt || "—" });
92
+ } catch {
93
+ // never break the tool flow
94
+ }
95
+ },
96
+
97
+ "tool.execute.after": async (input) => {
98
+ try {
99
+ if (input?.tool !== "task") return;
100
+ const key = input?.callID;
101
+ const entry = key !== undefined && pending.has(key) ? pending.get(key) : null;
102
+ if (key !== undefined) pending.delete(key);
103
+ if (!entry) return;
104
+ logInvocation(projectDir, entry.agent, entry.task);
105
+ } catch {
106
+ // never break the tool flow
107
+ }
108
+ },
109
+ };
110
+ };
@@ -0,0 +1,21 @@
1
+ /** Type declarations for the OpenCode traceability plugin (see .js for docs). */
2
+
3
+ export interface OcToolInput {
4
+ tool?: string;
5
+ callID?: string;
6
+ }
7
+
8
+ export interface OcToolOutput {
9
+ args?: Record<string, unknown>;
10
+ }
11
+
12
+ export interface OcPluginContext {
13
+ directory?: string;
14
+ }
15
+
16
+ export interface OcHooks {
17
+ "tool.execute.before": (input: OcToolInput, output: OcToolOutput) => Promise<void>;
18
+ "tool.execute.after": (input: OcToolInput) => Promise<void>;
19
+ }
20
+
21
+ export function HiveLogPlugin(ctx: OcPluginContext): Promise<OcHooks>;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * HIVE traceability plugin for OpenCode (parity with the Claude Code hook).
3
+ *
4
+ * Auto-loaded from .opencode/plugins/. When a HIVE agent runs as a subagent
5
+ * via the `task` tool, appends:
6
+ * - a row to HIVE-LOG.md (ISO 42001 A.9 audit trail)
7
+ * - a line to .opencode/hive-events.jsonl (machine-readable event stream)
8
+ *
9
+ * Design constraints (same as the CC hook):
10
+ * - Zero dependencies (node:fs/node:path only — Bun supports node: imports).
11
+ * - Never throws: a logging plugin must never break the tool flow.
12
+ * - Only logs HIVE agents (version stamp check in the adapter file).
13
+ *
14
+ * Implementation note: `tool.execute.before` receives the tool args
15
+ * (input.tool + output.args, per opencode.ai/docs/plugins); the args are
16
+ * captured per callID there and the log row is written on
17
+ * `tool.execute.after` (completion), so we don't depend on the undocumented
18
+ * shape of the after-payload. Tool id and arg names (`task`, `subagent_type`,
19
+ * `description`) verified against sst/opencode source (src/tool/task.ts).
20
+ */
21
+
22
+ import { readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync } from "node:fs";
23
+ import { join, dirname } from "node:path";
24
+
25
+ const LOG_HEADER = `# HIVE Session Log
26
+
27
+ AI agent invocation log for traceability (ISO 42001 A.9 — logging of AI decision-making events).
28
+
29
+ Rows are appended automatically by the HIVE hook (Claude Code) / plugin (OpenCode).
30
+ Manual fallback: \`npm run log-session -- --agent <name> --task "..." --outcome COMPLETED|PARTIAL|FAILED [--tokens N]\`
31
+
32
+ | Date | Agent | Task | Outcome | Tokens |
33
+ |------|-------|------|---------|--------|
34
+ `;
35
+
36
+ function sanitizeCell(text, maxLen = 120) {
37
+ return String(text ?? "")
38
+ .replace(/\s+/g, " ")
39
+ .replace(/\|/g, "\\|")
40
+ .trim()
41
+ .slice(0, maxLen);
42
+ }
43
+
44
+ function isHiveAgent(projectDir, agent) {
45
+ if (!agent || !/^[a-z][a-z0-9-]*$/.test(agent)) return false;
46
+ for (const rel of [join(".opencode", "agents"), join(".claude", "agents")]) {
47
+ const p = join(projectDir, rel, `${agent}.md`);
48
+ if (existsSync(p) && readFileSync(p, "utf-8").slice(0, 2000).includes("HIVE Framework v")) return true;
49
+ }
50
+ return false;
51
+ }
52
+
53
+ function logInvocation(projectDir, agent, task) {
54
+ const date = new Date().toISOString().split("T")[0];
55
+ const row = `| ${date} | ${agent} | ${sanitizeCell(task)} | COMPLETED | — |`;
56
+
57
+ const logPath = join(projectDir, "HIVE-LOG.md");
58
+ if (existsSync(logPath)) {
59
+ writeFileSync(logPath, readFileSync(logPath, "utf-8").trimEnd() + "\n" + row + "\n", "utf-8");
60
+ } else {
61
+ writeFileSync(logPath, LOG_HEADER + row + "\n", "utf-8");
62
+ }
63
+
64
+ const eventsPath = join(projectDir, ".opencode", "hive-events.jsonl");
65
+ mkdirSync(dirname(eventsPath), { recursive: true });
66
+ appendFileSync(
67
+ eventsPath,
68
+ JSON.stringify({
69
+ ts: new Date().toISOString(),
70
+ event: "hive_agent_invocation",
71
+ agent,
72
+ task: sanitizeCell(task),
73
+ runtime: "opencode",
74
+ }) + "\n",
75
+ "utf-8",
76
+ );
77
+ }
78
+
79
+ export const HiveLogPlugin = async ({ directory }) => {
80
+ const projectDir = directory || process.cwd();
81
+ const pending = new Map(); // callID → { agent, task }
82
+
83
+ return {
84
+ "tool.execute.before": async (input, output) => {
85
+ try {
86
+ if (input?.tool !== "task") return;
87
+ const args = output?.args ?? {};
88
+ const agent = args.subagent_type;
89
+ if (!isHiveAgent(projectDir, agent)) return;
90
+ const key = input?.callID ?? `${agent}:${Date.now()}`;
91
+ pending.set(key, { agent, task: args.description || args.prompt || "—" });
92
+ } catch {
93
+ // never break the tool flow
94
+ }
95
+ },
96
+
97
+ "tool.execute.after": async (input) => {
98
+ try {
99
+ if (input?.tool !== "task") return;
100
+ const key = input?.callID;
101
+ const entry = key !== undefined && pending.has(key) ? pending.get(key) : null;
102
+ if (key !== undefined) pending.delete(key);
103
+ if (!entry) return;
104
+ logInvocation(projectDir, entry.agent, entry.task);
105
+ } catch {
106
+ // never break the tool flow
107
+ }
108
+ },
109
+ };
110
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simplium/hive",
3
- "version": "4.0.0",
4
- "description": "Multi-agent AI framework for software development 36 specialized agents, NestJS runtime, evidence-based validation, MCP integration",
3
+ "version": "4.2.0",
4
+ "description": "Agent governance layer 36 curated agent & skill definitions with portable permission translation, traceability and anti-fabrication discipline for Claude Code and OpenCode",
5
5
  "license": "Apache-2.0",
6
6
  "author": "José (Simplium.io) <servicios@simplium.io>",
7
7
  "homepage": "https://github.com/marcablanca/hive-framework#readme",