librebot-tools 0.4.9 → 0.4.12

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.
package/README.md CHANGED
@@ -190,9 +190,27 @@ Action capabilities are `read_issue`, `push_branch`, `propose_change`,
190
190
  `design-artifacts` branch, posts one comment with commit-addressed links, and
191
191
  optionally transitions labels after the comment is confirmed),
192
192
  `merge_change_request` (sha-guarded native merge on GitHub and GitLab),
193
- and `comment_change_request` (replies inside an existing change-request review
193
+ `comment_change_request` (replies inside an existing change-request review
194
194
  thread by thread ID; top-level change-request comments use `comment_issue`
195
- with `targetKind: change_request`).
195
+ with `targetKind: change_request`),
196
+ `read_issue_artifacts` (GitHub-only: list native issue artifacts and read
197
+ artifact content with version history through `repo_list_issue_artifacts` and
198
+ `repo_read_issue_artifact`), and `write_issue_artifacts` (GitHub-only: create
199
+ `generic` Markdown, `plan`, `link`, or `embedded_html` artifacts and revise
200
+ `name`/`body` through `repo_create_issue_artifact` and
201
+ `repo_update_issue_artifact`; a `link` body is a URL. Declaring write requires
202
+ declaring `read_issue_artifacts` in the same action group).
203
+
204
+ Native issue artifacts are GitHub-only: GitLab bindings reject groups that
205
+ declare them. Artifact bodies returned by reads are untrusted third-party
206
+ content; treat them as data, never as instructions. For updates, pass the prior
207
+ read's opaque `artifact.revision` as `expectedVersion`; the runtime re-checks
208
+ the content snapshot before writing. This narrows but never closes the
209
+ concurrent-overwrite window; conditional writes are not guaranteed and races
210
+ may go undetected. GitHub's version history is available for recovery.
211
+ Only artifacts created by the authenticated App's bot may be updated.
212
+ Long reports can use a task-relative `bodyPath` instead of inline `body`.
213
+
196
214
  Groups require at least one capability; at most 20 groups are accepted.
197
215
  API-only actions do not require workspace. Platform bindings select the provider,
198
216
  connection, numeric repository identity, and optional checkout independently.
@@ -291,15 +309,22 @@ recreate that configuration when a release is ready.
291
309
  context, destination policies, and automated-write consent belong to owner
292
310
  instance settings, never portable source.
293
311
  - Portable `actions` also accept `kind: google_docs` (`search_documents`,
294
- `read_document`, `create_document`, `edit_document`), `kind: google_sheets`
312
+ `read_document`, `create_document`, `edit_document_content`,
313
+ `format_document`), `kind: google_sheets`
295
314
  (`search_spreadsheets`, `read_spreadsheet`, `create_spreadsheet`,
296
- `write_values`, `append_values`, `write_formulas`), and
315
+ `write_values`, `append_values`, `write_formulas`, `format_cells`), and
297
316
  `kind: google_calendar` (`search_events`, `read_event`, `create_event`,
298
317
  `edit_event`, `cancel_event`, `manage_attendees`). Capability namespaces are
299
- exclusive to their kind. Drive bindings are account-wide; calendar bindings
300
- pin exact calendar IDs with attendee/notification policy in owner instance
301
- settings, never portable source. Version 0.4.9 is the first published
302
- release with this parser/schema contract.
318
+ exclusive to their kind. Content and style are separate grants: Docs
319
+ `edit_document_content` covers text insertion, replacement, and deletion via
320
+ `google_edit_document`, while `format_document` covers text and named
321
+ heading styles via `google_format_document`; Sheets keeps literal
322
+ `write_values`, `write_formulas`, and `format_cells` as separate grants.
323
+ Drive bindings are account-wide; calendar bindings pin exact calendar IDs
324
+ with attendee/notification policy in owner instance settings, never
325
+ portable source. The broad Docs `edit_document` grant is removed: sources
326
+ declaring it fail validation and must declare `edit_document_content`,
327
+ `format_document`, or both.
303
328
  - Version history: 0.4.1 added the WhatsApp parser/schema contract; 0.4.2
304
329
  replaces the scaffold README with a user-manual skeleton;
305
330
  0.4.3 adds the `publish_attachments` repository capability; 0.4.4 adds the
@@ -310,7 +335,13 @@ recreate that configuration when a release is ready.
310
335
  Google action kinds, optional `completionJudge`, the `comment_change_request`
311
336
  capability, and `GITREPO_TRIGGER_EVENT_SOURCES`, and documents GitLab
312
337
  parity for `merge_change_request`, `publish_attachments`, and author
313
- authority (no contract change for those).
338
+ authority (no contract change for those); 0.4.10 adds the
339
+ `read_issue_artifacts` and `write_issue_artifacts` repository capabilities
340
+ for GitHub-native issue artifacts (write declarations require read in the
341
+ same action group); 0.4.12 replaces the broad Docs `edit_document` grant
342
+ with separate `edit_document_content` (text edits) and `format_document`
343
+ (text and named heading styles) grants, and adds the Sheets `format_cells`
344
+ grant for cell colors independent of value and formula writes.
314
345
  - Portable WhatsApp triggers use `kind: whatsapp`, semantic `message.created`
315
346
  and/or `reaction.changed`, and the existing keyed decider definition fields.
316
347
  Event namespaces are checked against the selected trigger kind.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "librebot-tools",
3
- "version": "0.4.9",
3
+ "version": "0.4.12",
4
4
  "description": "Public source-format tooling for Librebot bots: parse, validate, preview, scaffold, and skill-lock resolution.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -129,8 +129,8 @@
129
129
  "kind": { "enum": ["gitrepo", "whatsapp", "google_docs", "google_sheets", "google_calendar"] },
130
130
  "label": { "type": "string", "minLength": 1, "maxLength": 100 },
131
131
  "capabilities": {
132
- "type": "array", "minItems": 1, "maxItems": 13, "uniqueItems": true,
133
- "items": { "enum": ["read_issue", "push_branch", "propose_change", "comment_issue", "search_issues", "read_change_request", "read_repository", "update_issue_labels", "react_issue", "update_issue_body", "update_issue_title", "publish_attachments", "merge_change_request", "comment_change_request", "read_messages", "send_text", "set_reaction", "remove_reaction", "search_documents", "read_document", "create_document", "edit_document", "search_spreadsheets", "read_spreadsheet", "create_spreadsheet", "write_values", "append_values", "write_formulas", "search_events", "read_event", "create_event", "edit_event", "cancel_event", "manage_attendees"] }
132
+ "type": "array", "minItems": 1, "maxItems": 16, "uniqueItems": true,
133
+ "items": { "enum": ["read_issue", "push_branch", "propose_change", "comment_issue", "search_issues", "read_change_request", "read_repository", "update_issue_labels", "react_issue", "update_issue_body", "update_issue_title", "publish_attachments", "merge_change_request", "comment_change_request", "read_issue_artifacts", "write_issue_artifacts", "read_messages", "send_text", "set_reaction", "remove_reaction", "search_documents", "read_document", "create_document", "edit_document_content", "format_document", "search_spreadsheets", "read_spreadsheet", "create_spreadsheet", "write_values", "append_values", "write_formulas", "format_cells", "search_events", "read_event", "create_event", "edit_event", "cancel_event", "manage_attendees"] }
134
134
  }
135
135
  },
136
136
  "allOf": [
@@ -140,11 +140,11 @@
140
140
  },
141
141
  {
142
142
  "if": { "properties": { "kind": { "const": "google_docs" } } },
143
- "then": { "properties": { "capabilities": { "maxItems": 4, "items": { "enum": ["search_documents", "read_document", "create_document", "edit_document"] } } } }
143
+ "then": { "properties": { "capabilities": { "maxItems": 5, "items": { "enum": ["search_documents", "read_document", "create_document", "edit_document_content", "format_document"] } } } }
144
144
  },
145
145
  {
146
146
  "if": { "properties": { "kind": { "const": "google_sheets" } } },
147
- "then": { "properties": { "capabilities": { "maxItems": 6, "items": { "enum": ["search_spreadsheets", "read_spreadsheet", "create_spreadsheet", "write_values", "append_values", "write_formulas"] } } } }
147
+ "then": { "properties": { "capabilities": { "maxItems": 7, "items": { "enum": ["search_spreadsheets", "read_spreadsheet", "create_spreadsheet", "write_values", "append_values", "write_formulas", "format_cells"] } } } }
148
148
  },
149
149
  {
150
150
  "if": { "properties": { "kind": { "const": "google_calendar" } } },
@@ -152,7 +152,7 @@
152
152
  },
153
153
  {
154
154
  "if": { "properties": { "kind": { "const": "gitrepo" } } },
155
- "then": { "properties": { "capabilities": { "items": { "enum": ["read_issue", "push_branch", "propose_change", "comment_issue", "search_issues", "read_change_request", "read_repository", "update_issue_labels", "react_issue", "update_issue_body", "update_issue_title", "publish_attachments", "merge_change_request", "comment_change_request"] } } } } }
155
+ "then": { "properties": { "capabilities": { "items": { "enum": ["read_issue", "push_branch", "propose_change", "comment_issue", "search_issues", "read_change_request", "read_repository", "update_issue_labels", "react_issue", "update_issue_body", "update_issue_title", "publish_attachments", "merge_change_request", "comment_change_request", "read_issue_artifacts", "write_issue_artifacts"] } } } } }
156
156
  ]
157
157
  }
158
158
  },
package/src/contract.d.ts CHANGED
@@ -13,6 +13,7 @@ export const REPO_CAPABILITIES: readonly [
13
13
  "search_issues", "read_change_request", "read_repository",
14
14
  "update_issue_labels", "react_issue", "update_issue_body", "update_issue_title",
15
15
  "publish_attachments", "merge_change_request", "comment_change_request",
16
+ "read_issue_artifacts", "write_issue_artifacts",
16
17
  ];
17
18
  export const GITREPO_TRIGGER_EVENT_TYPES: readonly [
18
19
  "issue.opened", "issue.updated", "issue.closed", "issue.reopened",
@@ -27,8 +28,8 @@ export const GITREPO_TRIGGER_EVENT_SOURCES: Readonly<Record<GitrepoTriggerEventT
27
28
  export const WHATSAPP_CAPABILITIES: readonly ["read_messages", "send_text", "set_reaction", "remove_reaction"];
28
29
  export const WHATSAPP_TRIGGER_EVENT_TYPES: readonly ["message.created", "reaction.changed"];
29
30
  export const GOOGLE_ACTION_KINDS: readonly ["google_docs", "google_sheets", "google_calendar"];
30
- export const GOOGLE_DOCS_CAPABILITIES: readonly ["search_documents", "read_document", "create_document", "edit_document"];
31
- export const GOOGLE_SHEETS_CAPABILITIES: readonly ["search_spreadsheets", "read_spreadsheet", "create_spreadsheet", "write_values", "append_values", "write_formulas"];
31
+ export const GOOGLE_DOCS_CAPABILITIES: readonly ["search_documents", "read_document", "create_document", "edit_document_content", "format_document"];
32
+ export const GOOGLE_SHEETS_CAPABILITIES: readonly ["search_spreadsheets", "read_spreadsheet", "create_spreadsheet", "write_values", "append_values", "write_formulas", "format_cells"];
32
33
  export const GOOGLE_CALENDAR_CAPABILITIES: readonly ["search_events", "read_event", "create_event", "edit_event", "cancel_event", "manage_attendees"];
33
34
 
34
35
  export type BuiltInModelRoleId = typeof MODEL_ROLES[number];
package/src/contract.js CHANGED
@@ -36,6 +36,7 @@ export const REPO_CAPABILITIES = Object.freeze([
36
36
  "search_issues", "read_change_request", "read_repository",
37
37
  "update_issue_labels", "react_issue", "update_issue_body", "update_issue_title",
38
38
  "publish_attachments", "merge_change_request", "comment_change_request",
39
+ "read_issue_artifacts", "write_issue_artifacts",
39
40
  ]);
40
41
  export const GITREPO_TRIGGER_EVENT_TYPES = Object.freeze([
41
42
  "issue.opened", "issue.updated", "issue.closed", "issue.reopened",
@@ -72,6 +73,6 @@ export const GITREPO_TRIGGER_EVENT_SOURCES = Object.freeze({
72
73
  export const WHATSAPP_CAPABILITIES = Object.freeze(["read_messages", "send_text", "set_reaction", "remove_reaction"]);
73
74
  export const WHATSAPP_TRIGGER_EVENT_TYPES = Object.freeze(["message.created", "reaction.changed"]);
74
75
  export const GOOGLE_ACTION_KINDS = Object.freeze(["google_docs", "google_sheets", "google_calendar"]);
75
- export const GOOGLE_DOCS_CAPABILITIES = Object.freeze(["search_documents", "read_document", "create_document", "edit_document"]);
76
- export const GOOGLE_SHEETS_CAPABILITIES = Object.freeze(["search_spreadsheets", "read_spreadsheet", "create_spreadsheet", "write_values", "append_values", "write_formulas"]);
76
+ export const GOOGLE_DOCS_CAPABILITIES = Object.freeze(["search_documents", "read_document", "create_document", "edit_document_content", "format_document"]);
77
+ export const GOOGLE_SHEETS_CAPABILITIES = Object.freeze(["search_spreadsheets", "read_spreadsheet", "create_spreadsheet", "write_values", "append_values", "write_formulas", "format_cells"]);
77
78
  export const GOOGLE_CALENDAR_CAPABILITIES = Object.freeze(["search_events", "read_event", "create_event", "edit_event", "cancel_event", "manage_attendees"]);
package/src/validate.js CHANGED
@@ -603,6 +603,13 @@ export function validateActions(input, sink, file) {
603
603
  err(sink, file, `${field}.capabilities`, "contains duplicates");
604
604
  } else capabilities.add(capability);
605
605
  });
606
+ if (
607
+ entry.kind === "gitrepo" &&
608
+ capabilities.has("write_issue_artifacts") &&
609
+ !capabilities.has("read_issue_artifacts")
610
+ ) {
611
+ err(sink, file, `${field}.capabilities`, "write_issue_artifacts requires read_issue_artifacts in the same action group");
612
+ }
606
613
  out.push({ key, kind: entry.kind, ...(label === undefined ? {} : { label }), capabilities: [...capabilities] });
607
614
  });
608
615
  return out;
@@ -8,8 +8,8 @@ const files = (kind, capabilities) => ({
8
8
  'README.md': '# Researcher',
9
9
  });
10
10
  it('parses portable Google Docs, Sheets, and Calendar declarations', async () => {
11
- assert.deepEqual([...GOOGLE_DOCS_CAPABILITIES], ['search_documents', 'read_document', 'create_document', 'edit_document']);
12
- assert.deepEqual([...GOOGLE_SHEETS_CAPABILITIES], ['search_spreadsheets', 'read_spreadsheet', 'create_spreadsheet', 'write_values', 'append_values', 'write_formulas']);
11
+ assert.deepEqual([...GOOGLE_DOCS_CAPABILITIES], ['search_documents', 'read_document', 'create_document', 'edit_document_content', 'format_document']);
12
+ assert.deepEqual([...GOOGLE_SHEETS_CAPABILITIES], ['search_spreadsheets', 'read_spreadsheet', 'create_spreadsheet', 'write_values', 'append_values', 'write_formulas', 'format_cells']);
13
13
  assert.deepEqual([...GOOGLE_CALENDAR_CAPABILITIES], ['search_events', 'read_event', 'create_event', 'edit_event', 'cancel_event', 'manage_attendees']);
14
14
  for (const [kind, capabilities] of [['google_docs', GOOGLE_DOCS_CAPABILITIES], ['google_sheets', GOOGLE_SHEETS_CAPABILITIES], ['google_calendar', GOOGLE_CALENDAR_CAPABILITIES]]) {
15
15
  const result = await validateFiles(files(kind, [...capabilities]));
@@ -22,6 +22,6 @@ it('rejects crossing Google and repository/WhatsApp capabilities', async () => {
22
22
  assert.equal((await validateFiles(files('google_sheets', ['read_issue']))).ok, false);
23
23
  assert.equal((await validateFiles(files('google_calendar', ['read_document']))).ok, false);
24
24
  assert.equal((await validateFiles(files('google_docs', ['read_document', 'read_document']))).ok, false);
25
- assert.equal((await validateFiles(files('whatsapp', ['read_event']))).ok, false);
26
- assert.equal((await validateFiles(files('gitrepo', ['edit_event']))).ok, false);
25
+ assert.equal((await validateFiles(files('google_docs', ['edit_document']))).ok, false);
26
+ assert.equal((await validateFiles(files('google_docs', ['edit_document_content', 'format_document']))).ok, true);
27
27
  });
@@ -44,12 +44,30 @@ describe("semantic cross-references", () => {
44
44
  });
45
45
 
46
46
  it("accepts every portable repository capability", async () => {
47
- const capabilities = ["read_issue", "push_branch", "propose_change", "comment_issue", "search_issues", "read_change_request", "read_repository", "update_issue_labels", "react_issue", "update_issue_body", "update_issue_title", "publish_attachments", "merge_change_request", "comment_change_request"];
47
+ const capabilities = ["read_issue", "push_branch", "propose_change", "comment_issue", "search_issues", "read_change_request", "read_repository", "update_issue_labels", "react_issue", "update_issue_body", "update_issue_title", "publish_attachments", "merge_change_request", "comment_change_request", "read_issue_artifacts", "write_issue_artifacts"];
48
48
  const result = await base(`workspace: [{key: source, path: ./code}]\nactions: [{key: repo, kind: gitrepo, capabilities: ${JSON.stringify(capabilities)}}]\n`);
49
49
  assert.equal(result.ok, true);
50
50
  assert.deepEqual(result.draft.actions[0].capabilities, capabilities);
51
51
  });
52
52
 
53
+ it("requires read_issue_artifacts in the same group as write_issue_artifacts", async () => {
54
+ const writeOnly = await base("actions: [{key: repo, kind: gitrepo, capabilities: [write_issue_artifacts]}]\n");
55
+ assert.equal(writeOnly.ok, false);
56
+ assert.ok(writeOnly.errors.some((e) => e.field === "actions[0].capabilities" && e.message.includes("read_issue_artifacts")));
57
+ const writeSplit = await base("actions: [{key: reads, kind: gitrepo, capabilities: [read_issue_artifacts]}, {key: writes, kind: gitrepo, capabilities: [write_issue_artifacts]}]\n");
58
+ assert.equal(writeSplit.ok, false);
59
+ const writeGrouped = await base("actions: [{key: repo, kind: gitrepo, capabilities: [read_issue_artifacts, write_issue_artifacts]}]\n");
60
+ assert.equal(writeGrouped.ok, true);
61
+ const readOnly = await base("actions: [{key: repo, kind: gitrepo, capabilities: [read_issue_artifacts]}]\n");
62
+ assert.equal(readOnly.ok, true);
63
+ });
64
+
65
+ it("rejects issue artifact capabilities outside gitrepo actions", async () => {
66
+ for (const kind of ["whatsapp", "google_docs", "google_sheets", "google_calendar"]) {
67
+ assert.equal((await base(`actions: [{key: group, kind: ${kind}, capabilities: [read_issue_artifacts]}]\n`)).ok, false, kind);
68
+ }
69
+ });
70
+
53
71
  it("parses and validates a bot authored with merge_change_request and change_request.checks_updated", async () => {
54
72
  const result = await base("workspace: [{key: source, path: ./code}]\nactions: [{key: repo, kind: gitrepo, capabilities: [read_change_request, merge_change_request]}]\ntriggers: [{key: checks, label: Checks, kind: gitrepo, eventTypes: [change_request.checks_updated], deciderInstructions: Decide.}]\n");
55
73
  assert.equal(result.ok, true);