@ossdeveloper/github-compliance 1.0.0 → 1.0.2

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 (3) hide show
  1. package/dist/plugin.js +31 -25
  2. package/package.json +1 -1
  3. package/tools.ts +37 -25
package/dist/plugin.js CHANGED
@@ -12796,52 +12796,58 @@ function tool(input) {
12796
12796
  tool.schema = exports_external;
12797
12797
  // tools.ts
12798
12798
  var createComplianceRecordTool = tool({
12799
- description: "Create a compliance record AFTER user approves the draft. MUST be called after explicit user approval. This records that human approval was obtained and allows the GitHub write operation to proceed.",
12799
+ description: "Create compliance record",
12800
12800
  args: {
12801
- tool_name: tool.schema.string({ description: "GitHub tool name (e.g., issue_write, pull_request_write)" }),
12802
- owner: tool.schema.string({ description: "Repository owner (user or org)" }),
12803
- repo: tool.schema.string({ description: "Repository name" }),
12804
- title: tool.schema.string().optional({ description: "Issue/PR title" }),
12805
- body: tool.schema.string({ description: "Issue/PR body content" }),
12806
- github_username: tool.schema.string({ description: "GitHub username of human approver" }),
12807
- approved_at: tool.schema.string({ description: "ISO8601 timestamp when user approved" }),
12808
- checks: tool.schema.array(tool.schema.object({
12809
- check_type: tool.schema.string({ description: "Type of check performed" }),
12810
- passed: tool.schema.boolean({ description: "Whether check passed" }),
12811
- details: tool.schema.record(tool.schema.string(), tool.schema.any()).optional({ description: "Additional details" })
12812
- })).optional({ description: "List of compliance checks performed" })
12801
+ tool_name: exports_external.string(),
12802
+ owner: exports_external.string(),
12803
+ repo: exports_external.string(),
12804
+ title: exports_external.string().optional(),
12805
+ body: exports_external.string(),
12806
+ github_username: exports_external.string(),
12807
+ approved_at: exports_external.string(),
12808
+ checks: exports_external.string().optional()
12813
12809
  },
12814
12810
  async execute(args, _context) {
12811
+ let checks3 = [];
12812
+ if (args.checks) {
12813
+ try {
12814
+ checks3 = JSON.parse(args.checks);
12815
+ } catch {
12816
+ checks3 = [];
12817
+ }
12818
+ }
12819
+ const body = Buffer.from(args.body, "base64").toString("utf-8");
12820
+ const title = args.title ? Buffer.from(args.title, "base64").toString("utf-8") : null;
12815
12821
  const input = {
12816
12822
  tool_name: args.tool_name,
12817
12823
  owner: args.owner,
12818
12824
  repo: args.repo,
12819
- title: args.title || null,
12820
- body: args.body,
12825
+ title,
12826
+ body,
12821
12827
  github_username: args.github_username,
12822
12828
  approved_at: args.approved_at,
12823
- checks: args.checks || []
12829
+ checks: checks3
12824
12830
  };
12825
12831
  const recordId = await createComplianceRecord(input);
12826
- return {
12832
+ return JSON.stringify({
12827
12833
  success: true,
12828
12834
  record_id: recordId,
12829
- message: "Compliance record created. You may now execute the GitHub write operation.",
12835
+ message: "Compliance record created",
12830
12836
  expires_at: new Date(Date.now() + 30 * 60 * 1000).toISOString()
12831
- };
12837
+ });
12832
12838
  }
12833
12839
  });
12834
12840
  var getComplianceStatusTool = tool({
12835
- description: "Check if a valid compliance record exists for a planned GitHub write operation.",
12841
+ description: "Check compliance status",
12836
12842
  args: {
12837
- tool_name: tool.schema.string({ description: "GitHub tool name" }),
12838
- owner: tool.schema.string({ description: "Repository owner" }),
12839
- repo: tool.schema.string({ description: "Repository name" }),
12840
- content_hash: tool.schema.string({ description: "SHA256 hash of the content (format: sha256:...)" })
12843
+ tool_name: exports_external.string(),
12844
+ owner: exports_external.string(),
12845
+ repo: exports_external.string(),
12846
+ content_hash: exports_external.string()
12841
12847
  },
12842
12848
  async execute(args, _context) {
12843
12849
  const status = await getComplianceStatus(args.tool_name, args.owner, args.repo, args.content_hash);
12844
- return status;
12850
+ return JSON.stringify(status);
12845
12851
  }
12846
12852
  });
12847
12853
  var tools = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossdeveloper/github-compliance",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "GitHub compliance plugin for OpenCode - enforces human approval for write operations",
5
5
  "main": "dist/plugin.js",
6
6
  "type": "module",
package/tools.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  import { tool } from "@opencode-ai/plugin";
10
+ import { z } from "zod";
10
11
  import type { Plugin } from "@opencode-ai/plugin";
11
12
  import {
12
13
  createComplianceRecord,
@@ -26,43 +27,54 @@ import {
26
27
  *
27
28
  * The tool records that human approval was obtained and creates
28
29
  * a valid compliance record that will allow the GitHub write operation.
30
+ *
31
+ * Note: body and title are base64 encoded to work around BunShell serialization
32
+ * issues with multiline strings. Caller should encode these values.
29
33
  */
30
34
  export const createComplianceRecordTool = tool({
31
- description: "Create a compliance record AFTER user approves the draft. MUST be called after explicit user approval. This records that human approval was obtained and allows the GitHub write operation to proceed.",
35
+ description: "Create compliance record",
32
36
  args: {
33
- tool_name: tool.schema.string({ description: "GitHub tool name (e.g., issue_write, pull_request_write)" }),
34
- owner: tool.schema.string({ description: "Repository owner (user or org)" }),
35
- repo: tool.schema.string({ description: "Repository name" }),
36
- title: tool.schema.string().optional({ description: "Issue/PR title" }),
37
- body: tool.schema.string({ description: "Issue/PR body content" }),
38
- github_username: tool.schema.string({ description: "GitHub username of human approver" }),
39
- approved_at: tool.schema.string({ description: "ISO8601 timestamp when user approved" }),
40
- checks: tool.schema.array(tool.schema.object({
41
- check_type: tool.schema.string({ description: "Type of check performed" }),
42
- passed: tool.schema.boolean({ description: "Whether check passed" }),
43
- details: tool.schema.record(tool.schema.string(), tool.schema.any()).optional({ description: "Additional details" })
44
- })).optional({ description: "List of compliance checks performed" })
37
+ tool_name: z.string(),
38
+ owner: z.string(),
39
+ repo: z.string(),
40
+ title: z.string().optional(),
41
+ body: z.string(),
42
+ github_username: z.string(),
43
+ approved_at: z.string(),
44
+ checks: z.string().optional()
45
45
  },
46
46
  async execute(args, _context) {
47
+ let checks: CreateRecordInput['checks'] = [];
48
+ if (args.checks) {
49
+ try {
50
+ checks = JSON.parse(args.checks);
51
+ } catch {
52
+ checks = [];
53
+ }
54
+ }
55
+
56
+ const body = Buffer.from(args.body, 'base64').toString('utf-8');
57
+ const title = args.title ? Buffer.from(args.title, 'base64').toString('utf-8') : null;
58
+
47
59
  const input: CreateRecordInput = {
48
60
  tool_name: args.tool_name,
49
61
  owner: args.owner,
50
62
  repo: args.repo,
51
- title: args.title || null,
52
- body: args.body,
63
+ title,
64
+ body,
53
65
  github_username: args.github_username,
54
66
  approved_at: args.approved_at,
55
- checks: args.checks || []
67
+ checks
56
68
  };
57
69
 
58
70
  const recordId = await createComplianceRecord(input);
59
71
 
60
- return {
72
+ return JSON.stringify({
61
73
  success: true,
62
74
  record_id: recordId,
63
- message: "Compliance record created. You may now execute the GitHub write operation.",
75
+ message: "Compliance record created",
64
76
  expires_at: new Date(Date.now() + 30 * 60 * 1000).toISOString()
65
- };
77
+ });
66
78
  }
67
79
  });
68
80
 
@@ -73,16 +85,16 @@ export const createComplianceRecordTool = tool({
73
85
  * before attempting a GitHub write operation.
74
86
  */
75
87
  export const getComplianceStatusTool = tool({
76
- description: "Check if a valid compliance record exists for a planned GitHub write operation.",
88
+ description: "Check compliance status",
77
89
  args: {
78
- tool_name: tool.schema.string({ description: "GitHub tool name" }),
79
- owner: tool.schema.string({ description: "Repository owner" }),
80
- repo: tool.schema.string({ description: "Repository name" }),
81
- content_hash: tool.schema.string({ description: "SHA256 hash of the content (format: sha256:...)" })
90
+ tool_name: z.string(),
91
+ owner: z.string(),
92
+ repo: z.string(),
93
+ content_hash: z.string()
82
94
  },
83
95
  async execute(args, _context) {
84
96
  const status = await getComplianceStatus(args.tool_name, args.owner, args.repo, args.content_hash);
85
- return status;
97
+ return JSON.stringify(status);
86
98
  }
87
99
  });
88
100