@technomoron/agent-brain 0.1.4 → 0.1.6

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.
@@ -3,21 +3,25 @@ name: code-review
3
3
  description: Review code and track actionable findings as GitHub issues; follow up on existing issues and verify fixes.
4
4
  ---
5
5
 
6
- GitHub Issues in the affected repository are the sole authoritative record of review findings, discussion, status and resolution. Read the current issue before follow-up and resolve conflicting copies in favor of GitHub. Never persist findings or duplicate issue backlogs in Brain knowledge/reviews/todos, local Markdown files, review archives or another tracker. Do not use a Brain review-write tool unless its configured backend is verified to write directly to the same GitHub repository. If GitHub is unavailable or saving is unauthorized, report findings only in the reply and clearly state they are unsaved; do not create a fallback store.
6
+ Use GitHub Issues for code reviews by default unless the user explicitly states otherwise. GitHub Issues in the affected repository are the sole authoritative record of review findings, discussion, status and resolution. Read the current issue before follow-up and resolve conflicting copies in favor of GitHub. Never persist findings or duplicate issue backlogs in Brain knowledge/reviews/todos, local Markdown files, review archives or another tracker. Use the ordinary `issue_*` tools for review tracking; the legacy review tracking API is retired. If GitHub is unavailable or saving is unauthorized, report findings only in the reply and clearly state they are unsaved; do not create a fallback store.
7
7
 
8
8
  Use Brain for project constraints, specifications and reusable knowledge, not issue records. A confirmed general lesson may be saved under the memory workflow, with a link to the GitHub issue, but must not copy the finding or maintain its status elsewhere.
9
9
 
10
- Use Brain MCP for issue handling in the affected repository. List with `issue_list(origin="Code Review")`, paginate all relevant states, read with `issue_get` and paginate discussion with `issue_comments`. Create with `issue_create` (origin, type, Priority and a stable retry key), edit with `issue_update` using the current revision, and discuss with `issue_comment` or `issue_comment_update`. Close/reopen using `issue_update` state and state_reason. These tools write ordinary GitHub issues without a managed review block. Only when the required Brain backend or capability is unavailable, disclose that limitation and use the connector or `gh` as an explicit fallback. Never bypass permission or scope denials.
10
+ Use Brain MCP for issue handling in the affected repository. List with `issue_list(origin="Code Review")`, paginate all relevant states, read with `issue_get` and paginate discussion with `issue_comments`. Create with `issue_create` (origin, type, Priority and a stable retry key), edit with `issue_update` using the current revision, and discuss with `issue_comment` or `issue_comment_update`. Close/reopen using `issue_update` state and state_reason. These tools write ordinary GitHub issues without a managed review block. Use Brain MCP exclusively for issue reads, searches, metadata, comments and writes, and `list_repositories` for repository discovery. Do not use `gh` or a direct GitHub connector for these operations without explicit user approval for that fallback. If Brain lacks a capability, disclose the limitation and ask before using a fallback; unavailable tools alone are not approval. Never bypass permission or scope denials.
11
11
 
12
- Use `issue_search` for duplicate searches with structured origin/type/Priority filters; use `issue_metadata` to inspect definitions. Link follow-ups through `issue_relations`/`issue_relation_update` where supported. Configuration alignment requires explicit authorization: obtain `issue_config_preview`, review affected issues and organisation-wide usage, resolve mapping blockers, then apply with `issue_config_reconcile` using the exact preview revision. No setup skill or local GitHub credentials are required; never bypass a scope, permission or outside-usage blocker.
12
+ Use `issue_search` for duplicate searches with structured origin/type/Priority filters; use `issue_metadata` to inspect definitions. Link follow-ups through `issue_relations`/`issue_relation_update` where supported. For repository label, work type and Priority cleanup, discover and load `github-issue-cleanup` with `list_skills`/`get_skill`.
13
13
 
14
- 1. Confirm the repository and requested review scope. Retrieve relevant brain context, inspect the changes, and run checks that help verify suspected defects.
14
+ For findings spanning related repositories, use `list_repositories` to check accessible destinations. Explain the proposed issues and ask before creating them in additional repositories. After confirmation, select each affected repository, check for duplicates, create its issue and cross-link related issues. Access alone is not authorization; keep each repository’s backlog separate.
15
+
16
+ An authorized request to file an issue, including the default code-review workflow, also authorizes creating its missing allowed origin label in that repository. Inspect labels with `issue_metadata`; if the required label is absent, call `issue_label_ensure(origin=..., confirmed=true)` and verify the result, then create the issue. If `issue_create` reports a missing label, check for an existing issue before retrying with the same key and content. This authorization covers only the required label, not reconciliation, label deletion, existing issue migration or organisation types/fields. Ask separately for missing organisation definitions and broader cleanup; do not run `issue_config_reconcile` merely to unblock filing.
17
+
18
+ 1. Confirm the repository and requested review scope. Use `review_context` for constraints, decisions and path-specific knowledge; use `issue_list`/`issue_search` and `issue_comments` for findings and discussion. Inspect the changes, and run checks that help verify suspected defects.
15
19
  2. Retrieve open GitHub issues with origin label `Code Review` by default. Search closed issues and other types when relevant to prior decisions, regressions or duplicate detection. Read matching issues and update the existing issue when it describes the same problem.
16
20
  3. Report actionable defects with severity, evidence, affected file links, and reproduction or verification steps. Distinguish confirmed failures from suspected risks.
17
- 4. When authorized to save findings, use Brain MCP `issue_create` or `issue_update` to create or update ordinary GitHub issues; direct GitHub access is only the disclosed fallback described above. Use GitHub issue numbers as permanent identities instead of H1/M1 numbering. Keep titles descriptive and classify origin and work type separately as specified below. Use the existing organization-level `Priority` issue field with `Urgent`, `High`, `Medium` and `Low` options. Map critical severity to `Urgent`, and high, medium and low severity to the corresponding Priority values. Do not create a separate Severity field or severity/priority labels. If the Priority field cannot be read or set, report the failed operation and retain the assessed severity and intended Priority in the issue body. Put evidence in the issue body and preserve unrelated content and discussion. Do not create a second brain record or private metadata block.
18
- 5. For follow-up, read the current issue and relevant code. After an authorized fix passes relevant checks, add an issue fix comment and close the issue as completed. This applies whether a person or AI made the fix. Close as not planned only on the user's decision; deferral leaves it open. Keep resolved issues for history; do not delete them.
21
+ 4. When authorized to save findings, use Brain MCP `issue_create` or `issue_update` to create or update ordinary GitHub issues; direct GitHub access requires the explicit fallback approval described above. Use GitHub issue numbers as permanent identities instead of H1/M1 numbering. Keep titles descriptive and classify origin and work type separately as specified below. Use the existing organization-level `Priority` issue field with `Urgent`, `High`, `Medium` and `Low` options. Map critical severity to `Urgent`, and high, medium and low severity to the corresponding Priority values. Do not create a separate Severity field or severity/priority labels. If the Priority field cannot be read or set, report the failed operation and retain the assessed severity and intended Priority in the issue body. Put evidence in the issue body and preserve unrelated content and discussion. Do not create a second brain record or private metadata block.
22
+ 5. For follow-up, read the current issue and relevant code. For an explicit request such as “Fix issue #14”, load git-workflow and make one atomic commit per issue (one per affected repository for a cross-repository fix), including the relevant tests and no unrelated changes. The request authorizes those commits, pushing them to the existing upstream, and the fix comment/closure unless the user says otherwise; opening a PR still requires authorization. Follow git-workflow to fetch and, when behind or diverged, try to pull before committing without automatic rebasing. Verify the push before linking the commit and closing; a failed push leaves the issue open. Run relevant checks after the fix and any pull/merge, before committing and pushing. Follow git-workflow’s validation and closure gates, including its limited heads-up exception; add the linked fix comment before closing through `issue_update`, then read back the comment and closed state. Never close an unfinished fix. This applies whether a person or AI made the fix. Close as not planned only on the user's decision; deferral leaves it open. Keep resolved issues for history; do not delete them.
19
23
 
20
- Write issue fix comments as a concise bullet list. Each item states what was fixed and links to the corresponding commit. Optionally append the version in parentheses. A single concise note at the bottom may describe how the fix was tested. Do not include headings, introductions, conclusions, deployment status, or unrelated outstanding work. Do not label the list “TL;DR”.
24
+ Write issue fix comments as a concise bullet list. Each item states what was fixed and links to the corresponding commit or PR. Optionally append the version in parentheses. A single concise note at the bottom may describe how the fix was tested. Do not include headings, introductions, conclusions, deployment status, or unrelated outstanding work. Do not label the list “TL;DR”.
21
25
 
22
26
  Example:
23
27
 
@@ -47,12 +51,12 @@ Do not use `Code Review` as an issue type. Do not combine origin labels. Do not
47
51
 
48
52
  Use the code-review skill for review findings and todo-manager for feature requests and tasks. Filter review lists by origin label `Code Review`, and feature-request lists by origin label `Feature Request`; type `Feature` alone can also include improvements discovered during review.
49
53
 
50
- Keep assessed defect severity in the finding text and map critical severity to Priority `Urgent`, with high/medium/low mapping to the corresponding Priority value. Do not create a parallel Severity field or severity/priority label system. Inspect available types, fields and labels before saving. Create missing origin labels and work types when authorized with the required permissions; report unavailable capabilities rather than silently substituting a different scheme.
54
+ Keep assessed defect severity in the finding text and map critical severity to Priority `Urgent`, with high/medium/low mapping to the corresponding Priority value. Do not create a parallel Severity field or severity/priority label system. Inspect available types, fields and labels before saving. Create the required missing origin label with `issue_label_ensure` under the filing authorization above; organisation work types require separate authorization and permissions; report unavailable capabilities rather than silently substituting a different scheme.
51
55
 
52
56
  Read back saved issues and verify exactly one origin label, the work type and Priority. Report any permission or API limitation explicitly; body text is only a disclosed fallback when Priority cannot be set. During authorized follow-up, check classification too. Do not reclassify unrelated backlog or remove existing fields or labels without authorization.
53
57
 
54
58
  Report findings and issue links relevant to the requested scope, checks performed, and limitations. Reassess unrelated backlog only when requested. GitHub owns issue history; no separate review files, archive, or severity-based numbering is needed.
55
59
 
56
- A request to review code permits inspection and a report; it does not itself authorize creating GitHub issues. Reuse authorization already given. If GitHub access is unavailable, report findings in the reply and state that they were not saved. Do not silently switch to the legacy brain review backend. Historical C1/H1 references require locating the old record; they are not GitHub issue numbers.
60
+ A request to review code uses GitHub Issues for actionable findings in the reviewed repository by default, unless the user requests a report only or otherwise overrides this workflow. Ask before filing in additional repositories. Reuse authorization already given. If GitHub access is unavailable, report findings in the reply and state that they were not saved. Do not fall back to local review storage. Historical C1/H1 references require locating the old record; they are not GitHub issue numbers.
57
61
 
58
62
  The listed origin labels, work types and Priority options are exhaustive. Do not create or use additional values unless the user explicitly requests them. When authorized to align repositories, remove obsolete entries; check organization-wide entries for use outside the authorized repositories before removal.
@@ -1,14 +1,24 @@
1
1
  ---
2
2
  name: git-workflow
3
- description: Inspect Git changes, prepare commit messages, commit, and push within the user's authorization; enforce attribution and repository hygiene rules.
3
+ description: Inspect Git changes, commit and push within authorization; make atomic commits for explicit issue-fix requests.
4
4
  ---
5
5
 
6
+ Before every commit, inspect the branch, upstream, status and diff. Fetch the upstream and check whether the branch is ahead, behind or diverged. If out of sync because it is behind or diverged, try to pull before committing. Use `git pull --ff-only` when a fast-forward is possible; for divergence, inspect both histories and use an appropriate merge-based pull (`git pull --no-rebase`) when safe. Never rebase indiscriminately, force-push or rewrite shared history. Preserve local work; if it prevents a safe pull or conflicts remain, report the blocker instead of committing over an unsynchronized branch. If only ahead, no pull is needed. If there is no upstream or fetch/pull fails, disclose that before proceeding.
7
+
6
8
  Inspect status and the diff before staging. Preserve unrelated work; stage only the authorized scope unless the user explicitly asks to commit everything.
7
9
 
8
- Do not commit, push, tag, publish, or release without explicit user authorization. Reuse authorization already given; do not ask again for the same action. Before committing, show the changed files and exact commit message. Use the release skills for versioning, publishing and releases.
10
+ An explicit request such as “Fix issue #14” authorizes one atomic commit for that issue, including its relevant tests. Keep separate issues in separate commits and exclude unrelated changes. For a cross-repository fix, make a separate commit for the issue in each affected repository. Read the issue first and identify it with a neutral reference such as `Refs acme/catalog-api#14` in the commit message. Do not use GitHub auto-closing keywords (fix/fixes/fixed, close/closes/closed, resolve/resolves/resolved followed by an issue reference) in commit messages or PR titles/descriptions; closure must follow the fix comment and checks through `issue_update`. The request also authorizes pushing the issue commit to the existing upstream and linking it to the issue before closure. Opening a PR, tagging, publishing or releasing still requires authorization; follow any explicit user override.
11
+
12
+ Do not commit, push, tag, publish, or release without user authorization, including the issue-fix authorization above. Reuse authorization already given; do not ask again for the same action. Before committing, show the changed files and exact commit message. Use the release skills for versioning, publishing and releases.
9
13
 
10
14
  Write short, plain commit messages without category prefixes unless requested or required by the project. Never add AI-related attribution or mentions to commit messages or source code, and never add agent author or coauthor identities. Preserve the user's configured Git identity.
11
15
 
12
16
  Keep agent configuration and generated runtime files outside project repositories. Do not stage agent-only files or add agent-only ignore entries. Follow the global agent-file-storage constraint when available.
13
17
 
14
18
  Run configured project checks and relevant tests before committing. Resolve failures or clearly report blockers; do not claim unrun checks passed. For an authorized push, inspect the branch and upstream, push without rewriting shared history, and verify the result. Report commit IDs, push status, and any remaining changes.
19
+
20
+ For an issue fix, use this order: finish the fix and any pull/merge, run relevant checks on the final changes, commit, push and verify the remote commit, add the linked bullet-list fix comment, then close through Brain MCP `issue_update` using the current revision. Read back the comment and closed state. If code changes after testing, rerun the affected checks before committing or pushing. A failed push leaves the issue open.
21
+
22
+ A heads-up about checks is an exception for unavailable checks or demonstrated unrelated failures when other evidence verifies the issue's acceptance criteria. Give the user that explanation before committing/pushing and record it in the fix comment before closure. Failing checks caused by the fix, unmet acceptance criteria or uncertainty whether the issue is fixed keep the issue open; a heads-up alone does not make an incomplete fix complete. Never claim unrun or failing checks passed. Follow an explicit user decision to defer closure.
23
+
24
+ Use code-review for review findings and todo-manager for other issues; preserve their existing resolution mechanism and concise bullet-list fix-comment format. Use Brain MCP for issue handling; `gh` and direct GitHub connectors require explicit user approval even for read-only fallback checks.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: github-issue-cleanup
3
+ description: Inspect and reconcile GitHub repository labels, issue types and Priority definitions, migrating existing issues. Use for issue configuration cleanup or alignment.
4
+ ---
5
+
6
+ Use Brain MCP in the selected repository. This skill is available through `list_skills` and `get_skill`, including discovery before repository selection. Select the intended repository before calling its `issue_*` tools. Ordinary issue edits belong to todo-manager or code-review.
7
+
8
+ For a missing origin label needed to file an authorized issue, call `issue_label_ensure` with the required `origin` and `confirmed: true`. Filing authorization includes this narrow setup step, including default review filing. The tool creates only that missing allowed label, preserves existing labels and issues, and never touches organisation types or fields. It is safe to repeat; verify its result. Do not invoke full reconciliation for a missing label. If required types or Priority definitions are missing, report them and ask for separately scoped setup/cleanup authorization.
9
+
10
+ Use Brain MCP exclusively for issue operations. Do not use `gh` or direct GitHub connectors, including read-only checks, without explicit user approval for the fallback; missing Brain capabilities do not grant approval.
11
+
12
+ For explicitly requested broader cleanup, call `issue_config_preview` with `settings` to inspect the configuration, proposed operations, affected issues, organisation impact and blockers without writes. Brain uses its server-held GitHub credential; no local GitHub login is needed.
13
+
14
+ The standard allows exactly one origin label per issue: Code Review, Bug Report, Feature Request, ToDo or Question. Work types are Bug, Security, Feature, Task, Inconsistency, Question and Documentation. Priority is independent: Urgent, High, Medium or Low. Severity maps critical to Urgent and high/medium/low to the matching Priority. Do not add category, severity or priority labels. Milestones are outside this workflow.
15
+
16
+ Resolve ambiguous values with explicit `label_migrations`, `type_migrations`, `priority_migrations`, `field_migrations` or per-issue `issue_overrides`. Use `defaults` only when the same classification is justified for every otherwise unresolved issue. A null label/field mapping acknowledges dropping that source value. Review `remove_fields` (which defaults to Severity) and `prune_types` (which defaults to true); include their effects in the reviewed scope. Optional profile `issue-standard.jsonc` changes presentation metadata, not the allowed taxonomy.
17
+
18
+ Show the concrete preview and obtain authorization for its mutations unless the user already authorized that scope. Organisation types and fields can affect other repositories; do not infer organisation-wide authorization from a repository cleanup request. Never bypass permission, outside-usage, incomplete-access or mapping blockers.
19
+
20
+ Apply with `issue_config_reconcile`, passing the same settings, exact preview `revision` and `confirmed: true`. Brain migrates issues before removing obsolete definitions and verifies the result. A stale revision, partial result or failure requires a fresh preview; inspect completed changes and remaining blockers before retrying. Report the verified outcome and any unresolved changes. Do not claim cleanup succeeded from a preview alone.
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: github-release
3
+ description: Prepare version bumps, tags, package publishing and GitHub Releases.
4
+ ---
5
+
6
+ # GitHub Release
7
+
8
+ Load changelog for change-note paths, formatting and entries. Load package-integrity-check for package validation and git-workflow for release commits and pushes.
9
+
10
+ Establish the requested release scope, version and destination from the user's instructions and project release workflow. Reuse authorization already given; get confirmation before any version bump, commit, tag, push, publication or GitHub Release that is not yet authorized. A release request does not imply unrelated changes.
11
+
12
+ Prepare the changelog and version metadata together, keeping package versions, lockfiles and release notes consistent. Run configured checks and relevant tests on the final changes before commits, tags and pushes. Follow the project's release tooling and dependency order for packages released separately.
13
+
14
+ After authorized release actions, verify the resulting remote tag, package or GitHub Release. Report the released version and any failed or incomplete steps; do not claim publication from a successful local build alone.
@@ -6,14 +6,15 @@ description: Use before package releases and publish-ready changes to verify pac
6
6
  # Package Integrity Check
7
7
 
8
8
  Use this skill for release and package policy checks that are not covered by normal project test commands.
9
+ Load changelog for changelog filenames, formatting and entry rules.
9
10
  For package release or publish-ready work, verify the relevant package directory before finalizing:
10
11
 
11
12
  - The directory contains `package.json` and is inside a git repository.
12
13
  - The repository path follows `<org>/<repo>`, and `package.json.name` is `@<org>/<package-dir-name>`.
13
14
  - `package.json.version`, `package.json.license`, and `package.json.copyright` are present and non-empty.
14
15
  - A package-local `LICENSE` file exists and contains the exact copyright string from `package.json.copyright`.
15
- - A package-local changelog exists, named either `CHANGES.md` (preferred) or `CHANGES` (legacy). Exactly one of the two, never both.
16
- - The first `Version ...` line in that changelog matches `Version <package.json.version> (<YYYY-MM-DD>)`.
16
+ - A package-local changelog exists and follows the changelog skill.
17
+ - Its newest version heading matches `package.json.version` and uses the release date.
17
18
  - The year in the top changelog version line appears in `package.json.copyright`.
18
19
  - The git `origin` remote matches `<org>/<repo>`.
19
20
  - The current branch has an upstream configured and is in sync with it after fetching.
@@ -1,17 +1,19 @@
1
1
  ---
2
2
  name: todo-manager
3
- description: Track feature requests and planned work in GitHub Issues without a separate local todo list.
3
+ description: Track feature requests and tasks in GitHub Issues; fix numbered issues with atomic commits, linked fix comments and closure.
4
4
  ---
5
5
 
6
- Use Brain MCP for all todo and issue handling, with GitHub Issues in the affected repository as the authoritative backlog. Use Brain's ordinary `issue_*` tools, not the local `todo_*` store. Use `issue_list` (paginate open and closed issues), `issue_get`, `issue_create`, `issue_update`, `issue_comments`, `issue_comment` and `issue_comment_update`. Supply origin, type and Priority on creation; reuse retry keys and read current revisions before edits. Comments paginate separately. Close/reopen through `issue_update`. Only when the required Brain backend or capability is unavailable, disclose that limitation and use the GitHub connector or `gh` as an explicit fallback. Never bypass permission or scope denials. Never create a separate local todo list or duplicate brain task records.
6
+ Use Brain MCP for all todo and issue handling, with GitHub Issues in the affected repository as the authoritative backlog. Use Brain's ordinary `issue_*` tools. The legacy `todo_*` tools and local task imports are retired. Historical task files remain read-only and are never migrated or deleted automatically. Use `issue_list` (paginate open and closed issues), `issue_get`, `issue_create`, `issue_update`, `issue_comments`, `issue_comment` and `issue_comment_update`. Supply origin, type and Priority on creation; reuse retry keys and read current revisions before edits. Comments paginate separately. Close/reopen through `issue_update`. Use Brain MCP exclusively for issue reads, searches, metadata, comments and writes, and `list_repositories` for repository discovery. Do not use `gh` or a direct GitHub connector for these operations without explicit user approval for that fallback. If Brain lacks a capability, disclose the limitation and ask before using a fallback; unavailable tools alone are not approval. Never bypass permission or scope denials. Never create a separate local todo list or duplicate brain task records.
7
7
 
8
- Use `issue_search` for literal text and structured filters, `issue_metadata` for available definitions/assignees/milestones, and `issue_relations`/`issue_relation_update` for parents, sub-issues and dependencies. For explicitly authorized configuration alignment, call `issue_config_preview`, review changes, affected issues and blockers, then call `issue_config_reconcile` with the same settings, preview revision and confirmation. Supply explicit migration mappings for ambiguous values; do not bypass outside-usage or permission blockers. Brain performs this workflow through its server-held GitHub credential without an LLM or local GitHub login.
8
+ Use `issue_search` for literal text and structured filters, `issue_metadata` for available definitions/assignees/milestones, and `issue_relations`/`issue_relation_update` for parents, sub-issues and dependencies. For repository label, work type and Priority cleanup, discover and load `github-issue-cleanup` with `list_skills`/`get_skill`.
9
+
10
+ An authorized request to file an issue, including the default code-review workflow, also authorizes creating its missing allowed origin label in that repository. Inspect labels with `issue_metadata`; if the required label is absent, call `issue_label_ensure(origin=..., confirmed=true)` and verify the result, then create the issue. If `issue_create` reports a missing label, check for an existing issue before retrying with the same key and content. This authorization covers only the required label, not reconciliation, label deletion, existing issue migration or organisation types/fields. Ask separately for missing organisation definitions and broader cleanup; do not run `issue_config_reconcile` merely to unblock filing.
9
11
 
10
12
  1. Confirm the repository and requested task. Retrieve open issues of the relevant type by default; search existing open and closed issues before creating a request to avoid duplicates.
11
13
  2. Create or update issues only when requested or authorized by the current workflow. Use issue numbers as permanent IDs, descriptive titles, and clear requirements or acceptance criteria. Read the current issue before updates and preserve unrelated content and discussion.
12
14
  3. Use exactly one origin label: `Feature Request` for a requested capability, `ToDo` for a manually added task or a follow-up task triggered by a review issue fix, `Bug Report` for a reported defect, `Question` for a question, or `Code Review` for a review finding. Link review-fix follow-up tasks to the original issue.
13
- 4. Set exactly one work type independently of origin: `Bug`, `Security`, `Feature`, `Task`, `Inconsistency`, `Question` or `Documentation`. A feature request normally has type `Feature`; a manual or follow-up task normally has type `Task`. `Code Review` is an origin label, never an issue type. Do not add `bug` or `enhancement` category labels that duplicate type. The five origin labels are the entire allowed label set; do not create or apply additional labels unless the user explicitly requests them. Use the existing `Priority` field (`Urgent`, `High`, `Medium`, `Low`), without creating severity/priority labels or a separate Severity field. Create missing origin labels or work types only when authorized with the required permissions. Read back origin, type and Priority after saving and report unavailable capabilities. Use code-review for review findings. Filter feature-request lists by origin label `Feature Request`, not type alone.
14
- 5. Leave unfinished or deferred requests open. After an authorized implementation passes relevant checks, record verification and close the issue as completed. Close as not planned only on the user's decision. Preserve closed issues for history rather than deleting them.
15
+ 4. Set exactly one work type independently of origin: `Bug`, `Security`, `Feature`, `Task`, `Inconsistency`, `Question` or `Documentation`. A feature request normally has type `Feature`; a manual or follow-up task normally has type `Task`. `Code Review` is an origin label, never an issue type. Do not add `bug` or `enhancement` category labels that duplicate type. The five origin labels are the entire allowed label set; do not create or apply additional labels unless the user explicitly requests them. Use the existing `Priority` field (`Urgent`, `High`, `Medium`, `Low`), without creating severity/priority labels or a separate Severity field. Use `issue_label_ensure` for the required missing origin label under the filing authorization above; organisation work types require separate authorization and permissions. Read back origin, type and Priority after saving and report unavailable capabilities. Use code-review for review findings; GitHub Issues are the default unless the user explicitly states otherwise. For findings spanning related accessible repositories, ask before filing in additional repositories, then keep and cross-link the issues in their affected repositories. Filter feature-request lists by origin label `Feature Request`, not type alone.
16
+ 5. Leave unfinished or deferred requests open. An explicit request such as “Fix issue #14” authorizes one atomic commit per issue, pushing to the existing upstream, and its fix comment/closure unless the user says otherwise; load git-workflow to fetch and try to pull when behind or diverged before committing, without automatic rebasing. Verify the push before linking and closing; a failed push leaves the issue open. Keep unrelated issues in separate commits, with one commit per affected repository for cross-repository fixes. Run relevant checks after the fix and any pull/merge, before committing and pushing. Follow git-workflow’s validation and closure gates, including its limited heads-up exception; add a concise bullet-list fix comment linking the corresponding commit or authorized PR and record verification or check limitations before closing through `issue_update` with the current revision. Read back the comment and closed state. Close as not planned only on the user's decision. Preserve closed issues for history rather than deleting them.
15
17
 
16
18
  A request to do work does not by itself authorize creating a saved task or GitHub issue. Reuse authorization already given. Do not migrate or delete existing local tasks without authorization. If GitHub is unavailable, report the limitation and unsaved requests in the reply.
17
19
 
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.syncConnector = syncConnector;
4
- const zod_1 = require("zod");
5
- const config_1 = require("./config");
6
- const todos_1 = require("./todos");
7
- const githubIssue = zod_1.z.object({ number: zod_1.z.number().int(), title: zod_1.z.string(), body: zod_1.z.string().nullable(), state: zod_1.z.enum(['open', 'closed']),
8
- html_url: zod_1.z.url(), pull_request: zod_1.z.unknown().optional(), labels: zod_1.z.array(zod_1.z.union([zod_1.z.string(), zod_1.z.object({ name: zod_1.z.string() })])) });
9
- const trelloCard = zod_1.z.object({ id: zod_1.z.string(), name: zod_1.z.string(), desc: zod_1.z.string(), closed: zod_1.z.boolean(), dueComplete: zod_1.z.boolean(), due: zod_1.z.string().nullable(),
10
- url: zod_1.z.url(), labels: zod_1.z.array(zod_1.z.object({ name: zod_1.z.string() })) });
11
- // Fetch connector JSON with bounded requests and sanitized network errors.
12
- async function readRemote(url, headers) {
13
- let response;
14
- try {
15
- response = await fetch(url, { headers, redirect: 'error', signal: AbortSignal.timeout(30000) });
16
- }
17
- catch {
18
- throw new Error(`Could not reach ${url.hostname}; check connector credentials and network access.`);
19
- }
20
- if (!response.ok)
21
- throw new Error(`Connector ${url.hostname} returned HTTP ${response.status}`);
22
- return response.json();
23
- }
24
- // Import configured GitHub issues or Trello cards as local tasks.
25
- async function syncConnector(store, name, scope) {
26
- store.scopeDirectory(scope);
27
- const connector = (0, config_1.readBrainConfig)(store.configRoot)?.connectors[name];
28
- if (!connector)
29
- throw new Error(`Connector not configured: ${name}`);
30
- const tasks = [];
31
- if (connector.type === 'github') {
32
- const token = process.env[connector.tokenEnv];
33
- for (let page = 1;; page += 1) {
34
- if (page > 100)
35
- throw new Error('GitHub import exceeds 10000 issues; split the task source before importing.');
36
- const url = new URL(`https://api.github.com/repos/${connector.repository}/issues`);
37
- url.search = new URLSearchParams({ state: 'all', per_page: '100', page: String(page) }).toString();
38
- const issues = zod_1.z.array(githubIssue).parse(await readRemote(url, { accept: 'application/vnd.github+json', 'user-agent': 'agent-brain', ...(token ? { authorization: `Bearer ${token}` } : {}) }));
39
- for (const issue of issues.filter((issue) => !issue.pull_request))
40
- tasks.push({
41
- scope, title: issue.title, description: issue.body ?? '', status: issue.state === 'closed' ? 'done' : 'todo',
42
- labels: issue.labels.map((label) => typeof label === 'string' ? label : label.name),
43
- source: { type: 'github', external_id: `${connector.repository}#${issue.number}`, url: issue.html_url }
44
- });
45
- if (issues.length < 100)
46
- break;
47
- }
48
- }
49
- else {
50
- const key = process.env[connector.keyEnv];
51
- const token = process.env[connector.tokenEnv];
52
- if (!key || !token)
53
- throw new Error(`Set ${connector.keyEnv} and ${connector.tokenEnv} before importing Trello tasks.`);
54
- const url = new URL(`https://api.trello.com/1/boards/${connector.board}/cards/all`);
55
- url.search = new URLSearchParams({ key, token, fields: 'id,name,desc,closed,dueComplete,due,url,labels' }).toString();
56
- const cards = zod_1.z.array(trelloCard).parse(await readRemote(url, {}));
57
- for (const card of cards)
58
- tasks.push({ scope, title: card.name, description: card.desc,
59
- status: card.dueComplete ? 'done' : card.closed ? 'cancelled' : 'todo',
60
- ...(card.due ? { due: card.due.slice(0, 10) } : {}), labels: card.labels.map((label) => label.name),
61
- source: { type: 'trello', external_id: card.id, url: card.url }
62
- });
63
- }
64
- return (0, todos_1.importTodos)(store, tasks);
65
- }
@@ -1,205 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GithubReviews = exports.reviewInput = void 0;
4
- exports.githubReviews = githubReviews;
5
- exports.githubReviewConfig = githubReviewConfig;
6
- const fs = require("node:fs");
7
- const node_crypto_1 = require("node:crypto");
8
- const jsonc_parser_1 = require("jsonc-parser");
9
- const zod_1 = require("zod");
10
- const repositories_1 = require("./repositories");
11
- const config_1 = require("./config");
12
- const store_1 = require("./store");
13
- const configSchema = zod_1.z.object({ backend: zod_1.z.literal('github'), repository: repositories_1.repositoryId.optional(),
14
- tokenEnv: zod_1.z.string().regex(/^[A-Z_][A-Z0-9_]*$/).default('GITHUB_TOKEN'), writesEnabled: zod_1.z.boolean().default(false) }).strict();
15
- exports.reviewInput = zod_1.z.object({ key: zod_1.z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._/-]*$/).max(200),
16
- title: zod_1.z.string().trim().min(1).max(250), content: zod_1.z.string().trim().min(1).max(40000), severity: store_1.severitySchema,
17
- applies_to: zod_1.z.array(zod_1.z.string().max(500)).max(100).default([]), confirmed: zod_1.z.literal(true) }).strict();
18
- const metadata = zod_1.z.object({ key: zod_1.z.string(), severity: store_1.severitySchema, applies_to: zod_1.z.array(zod_1.z.string()) });
19
- const issueSchema = zod_1.z.object({ number: zod_1.z.number().int().positive(), title: zod_1.z.string(), body: zod_1.z.string().nullable(),
20
- state: zod_1.z.enum(['open', 'closed']), state_reason: zod_1.z.string().nullable().optional(), html_url: zod_1.z.string().url(),
21
- updated_at: zod_1.z.string(), pull_request: zod_1.z.unknown().optional() });
22
- // Hash review content for revisions and repository-specific retry files.
23
- const hash = (value) => (0, node_crypto_1.createHash)('sha256').update(value).digest('hex');
24
- const start = '<!-- agent-mcp-review:start -->';
25
- const end = '<!-- agent-mcp-review:end -->';
26
- class GithubReviews {
27
- // Bind the review backend to its store, configuration and GitHub repository.
28
- constructor(store, config, repository) {
29
- this.store = store;
30
- this.config = config;
31
- this.repository = repository;
32
- }
33
- // Send an authenticated GitHub issue request with time and size limits.
34
- async request(route, method = 'GET', body) {
35
- return this.requestApi('/repos/' + this.repository + '/issues' + route, method, body);
36
- }
37
- // Send a bounded request to a fixed GitHub API path.
38
- async requestApi(route, method = 'GET', body) {
39
- const token = process.env[this.config.tokenEnv];
40
- if (!token)
41
- throw new Error('Set ' + this.config.tokenEnv + ' for GitHub reviews');
42
- const response = await fetch('https://api.github.com' + route, {
43
- method, redirect: 'error', signal: AbortSignal.timeout(30000), headers: { accept: 'application/vnd.github+json',
44
- 'content-type': 'application/json', 'user-agent': 'agent-brain', authorization: 'Bearer ' + token,
45
- 'X-GitHub-Api-Version': '2026-03-10' }, ...(body ? { body: JSON.stringify(body) } : {})
46
- });
47
- if (!response.ok)
48
- throw new Error('GitHub request failed with HTTP ' + response.status + (response.status === 403 ? '; check token permissions, organisation policy and rate limits' : ''));
49
- if (response.status === 204)
50
- return null;
51
- const text = await response.text();
52
- if (text.length > 4 * 1024 * 1024)
53
- throw new Error('GitHub response exceeds 4 MiB');
54
- return JSON.parse(text);
55
- }
56
- // Extract managed review metadata from an ordinary GitHub issue.
57
- data(issue) {
58
- if (issue.pull_request)
59
- return null;
60
- const body = issue.body ?? '';
61
- const match = /<!-- agent-mcp-meta:([A-Za-z0-9_-]+) -->/.exec(body);
62
- if (!match || !body.includes(start) || !body.includes(end))
63
- return null;
64
- let decoded;
65
- try {
66
- decoded = JSON.parse(Buffer.from(match[1], 'base64url').toString('utf8'));
67
- }
68
- catch {
69
- return null;
70
- }
71
- const parsed = metadata.safeParse(decoded);
72
- if (!parsed.success)
73
- return null;
74
- return { ...parsed.data, id: 'github:' + this.repository + '#' + issue.number, finding: '#' + issue.number,
75
- title: issue.title, content: body, state: issue.state === 'open' ? 'open' : issue.state_reason === 'not_planned' ? 'wontfix' : 'fixed',
76
- url: issue.html_url, revision: hash(JSON.stringify(issue)), backend: 'github' };
77
- }
78
- // Page through managed findings and sort them by severity.
79
- async list(state = 'open') {
80
- const found = [];
81
- for (let page = 1; page <= 100; page++) {
82
- const issues = zod_1.z.array(issueSchema).parse(await this.request('?state=' + state + '&per_page=100&page=' + page));
83
- for (const issue of issues) {
84
- const item = this.data(issue);
85
- if (item)
86
- found.push(item);
87
- }
88
- if (issues.length < 100)
89
- return found.sort((a, b) => ['critical', 'high', 'medium', 'low'].indexOf(a.severity) - ['critical', 'high', 'medium', 'low'].indexOf(b.severity));
90
- }
91
- throw new Error('GitHub review listing exceeds 100 pages; narrow the repository backlog before retrying');
92
- }
93
- // Extract an issue number belonging to the configured repository.
94
- number(id) {
95
- const prefix = 'github:' + this.repository + '#';
96
- const number = id.startsWith(prefix) ? id.slice(prefix.length) : id.replace(/^#/, '');
97
- if (!/^[1-9][0-9]*$/.test(number))
98
- throw new Error('Issue must belong to the configured repository');
99
- return number;
100
- }
101
- // Read a managed GitHub finding by its issue identity.
102
- async get(id) {
103
- const item = this.data(issueSchema.parse(await this.request('/' + this.number(id))));
104
- if (!item)
105
- throw new Error('Issue is not an agent-mcp review finding');
106
- return item;
107
- }
108
- // Serialize GitHub writes and enforce the explicit write gate.
109
- async locked(work) {
110
- if (!this.config.writesEnabled)
111
- throw new Error('GitHub review writes are disabled; configure writesEnabled explicitly');
112
- const lock = this.store.safePath('runtime', 'github-review.lock');
113
- const descriptor = fs.openSync(lock, 'wx', 0o600);
114
- try {
115
- return await work();
116
- }
117
- finally {
118
- fs.closeSync(descriptor);
119
- fs.unlinkSync(lock);
120
- }
121
- }
122
- // Encode a finding inside the reserved GitHub review markers.
123
- block(input) {
124
- if (input.content.includes('<!-- agent-mcp-'))
125
- throw new Error('Finding content contains a reserved marker');
126
- const encoded = Buffer.from(JSON.stringify({ key: input.key, severity: input.severity, applies_to: input.applies_to })).toString('base64url');
127
- return start + '\n<!-- agent-mcp-meta:' + encoded + ' -->\nSeverity: ' + input.severity + '\n\n' + input.content + '\n' + end;
128
- }
129
- // Create a finding or return the issue already associated with its retry key.
130
- async create(input) {
131
- input = exports.reviewInput.parse(input);
132
- return this.locked(async () => {
133
- const file = this.store.safePath('runtime', 'github-review-keys-' + hash(this.repository) + '.json');
134
- const keys = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : {};
135
- if (Object.prototype.hasOwnProperty.call(keys, input.key)) {
136
- const existing = await this.get(keys[input.key]);
137
- if (existing.key !== input.key)
138
- throw new Error('Stored review retry key does not match its GitHub issue');
139
- return { ...existing, created: false };
140
- }
141
- const existing = (await this.list('all')).find((item) => item.key === input.key);
142
- if (existing)
143
- return { ...existing, created: false };
144
- const item = this.data(issueSchema.parse(await this.request('', 'POST', { title: input.title, body: this.block(input) })));
145
- if (!item)
146
- throw new Error('GitHub returned an invalid review finding');
147
- Object.defineProperty(keys, input.key, { value: item.id, enumerable: true, configurable: true, writable: true });
148
- fs.writeFileSync(file + '.tmp', JSON.stringify(keys), { mode: 0o600 });
149
- fs.renameSync(file + '.tmp', file);
150
- return { ...item, created: true };
151
- });
152
- }
153
- // Revise the managed finding while preserving unrelated issue content.
154
- async update(id, revision, changes) {
155
- return this.locked(async () => {
156
- const current = await this.get(id);
157
- if (current.revision !== revision)
158
- throw new Error('GitHub finding changed; read it again before updating');
159
- const managed = current.content.slice(current.content.indexOf(start), current.content.indexOf(end));
160
- const block = this.block({ ...current, ...changes, content: changes.content ?? managed.slice(managed.indexOf('\n\n') + 2).trim() });
161
- const body = current.content.slice(0, current.content.indexOf(start)) + block + current.content.slice(current.content.indexOf(end) + end.length);
162
- const issue = issueSchema.parse(await this.request('/' + this.number(id), 'PATCH', { title: changes.title ?? current.title, body }));
163
- return this.data(issue);
164
- });
165
- }
166
- // Close a current finding with its resolution reason.
167
- async resolve(id, revision, state, reason) {
168
- return this.locked(async () => {
169
- const current = await this.get(id);
170
- if (current.revision !== revision)
171
- throw new Error('GitHub finding changed; read it again before closing');
172
- const issue = issueSchema.parse(await this.request('/' + this.number(id), 'PATCH', {
173
- state: 'closed', state_reason: state === 'fixed' ? 'completed' : 'not_planned', body: current.content + '\n\nResolution: ' + reason
174
- }));
175
- return this.data(issue);
176
- });
177
- }
178
- }
179
- exports.GithubReviews = GithubReviews;
180
- // Load the optional GitHub review backend for the active profile.
181
- function githubReviews(store, selectedRepository) {
182
- const settings = githubReviewConfig(store, selectedRepository);
183
- return settings ? new GithubReviews(store, settings.config, settings.repository) : null;
184
- }
185
- // Resolve the repository-bound GitHub configuration shared by issue and review tools.
186
- function githubReviewConfig(store, selectedRepository) {
187
- const local = store.safePath(store.profile ?? 'default', 'review.jsonc');
188
- const global = !fs.existsSync(local);
189
- const file = global ? store.safePath('global', 'review.jsonc') : local;
190
- if (!fs.existsSync(file))
191
- return null;
192
- const errors = [];
193
- const document = (0, jsonc_parser_1.parse)(store.read(file), errors);
194
- if (errors.length)
195
- throw new Error('Invalid review.jsonc');
196
- const config = global ? configSchema.omit({ repository: true }).parse(document) : configSchema.parse(document);
197
- const project = (0, config_1.listBrainProjects)(store.configRoot).find((item) => item.profile === store.profile);
198
- const registered = project?.repository?.url ? (0, repositories_1.githubRepository)(project.repository.url) : null;
199
- const repository = global
200
- ? selectedRepository ?? registered ?? (repositories_1.repositoryId.safeParse(project?.name).success ? project.name : null)
201
- : ('repository' in config ? config.repository : undefined) ?? registered;
202
- if (!repository)
203
- throw new Error('GitHub reviews need an explicit repository or a registered GitHub remote');
204
- return { config, repository: repositories_1.repositoryId.parse(repository) };
205
- }