memory-journal-mcp 7.4.0 → 7.6.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.
@@ -1,8 +1,36 @@
1
- import { transformAutoReturn } from './chunk-OKOVZ5QE.js';
2
- import { workerData, parentPort } from 'worker_threads';
1
+ import { parentPort } from 'worker_threads';
3
2
  import * as vm from 'vm';
4
3
 
5
- var { code, methodList, timeoutMs, rpcPort: workerRpcPort } = workerData;
4
+ // src/codemode/worker-script.ts
5
+
6
+ // src/codemode/auto-return.ts
7
+ var NON_RETURNABLE = /^\s*(return|throw|const |let |var |if\b|else\b|for\b|while\b|do\b|switch\b|try\b|catch\b|finally\b|class |function |\/\/|\/\*|\{|\})/;
8
+ function transformAutoReturn(code) {
9
+ const trimmed = code.trimEnd();
10
+ if (!trimmed) return code;
11
+ let depth = 0;
12
+ let splitIndex = -1;
13
+ for (let i = trimmed.length - 1; i >= 0; i--) {
14
+ const ch = trimmed.charAt(i);
15
+ if (ch === "}" || ch === "]" || ch === ")") depth++;
16
+ else if (ch === "{" || ch === "[" || ch === "(") depth--;
17
+ if (depth === 0 && (ch === ";" || ch === "\n")) {
18
+ splitIndex = i;
19
+ break;
20
+ }
21
+ }
22
+ const lastStmt = (splitIndex >= 0 ? trimmed.slice(splitIndex + 1) : trimmed).trim();
23
+ if (!lastStmt) return code;
24
+ if (NON_RETURNABLE.test(lastStmt)) return code;
25
+ if (splitIndex >= 0) {
26
+ const before = trimmed.slice(0, splitIndex + 1);
27
+ return `${before}
28
+ return ${lastStmt}`;
29
+ }
30
+ return `return ${trimmed}`;
31
+ }
32
+
33
+ // src/codemode/worker-script.ts
6
34
  var rpcPort = null;
7
35
  var rpcIdCounter = 0;
8
36
  var pendingRpcRequests = /* @__PURE__ */ new Map();
@@ -62,7 +90,7 @@ function buildApiProxy(methods) {
62
90
  };
63
91
  return api;
64
92
  }
65
- async function executeCode() {
93
+ async function executeCode(code, methodList, timeoutMs) {
66
94
  const startCpu = process.cpuUsage();
67
95
  const startTime = performance.now();
68
96
  try {
@@ -76,7 +104,6 @@ async function executeCode() {
76
104
  info: (...args) => args,
77
105
  debug: (...args) => args
78
106
  },
79
- // Nulled globals
80
107
  setTimeout: void 0,
81
108
  setInterval: void 0,
82
109
  setImmediate: void 0,
@@ -88,7 +115,11 @@ async function executeCode() {
88
115
  globalThis: void 0
89
116
  };
90
117
  const context = vm.createContext(sandbox, {
91
- name: "codemode-worker-sandbox"
118
+ name: "codemode-worker-sandbox",
119
+ codeGeneration: {
120
+ strings: false,
121
+ wasm: false
122
+ }
92
123
  });
93
124
  const wrappedCode = `(async () => { ${transformAutoReturn(code)} })()`;
94
125
  const script = new vm.Script(wrappedCode, {
@@ -104,7 +135,6 @@ async function executeCode() {
104
135
  wallTimeMs: Math.round(endTime - startTime),
105
136
  cpuTimeMs: Math.round((endCpu.user + endCpu.system) / 1e3),
106
137
  memoryUsedMb: 0
107
- // Measured on host side via RSS delta
108
138
  };
109
139
  return { success: true, result, metrics };
110
140
  } catch (err) {
@@ -124,21 +154,81 @@ async function executeCode() {
124
154
  };
125
155
  }
126
156
  }
127
- rpcPort = workerRpcPort;
128
- rpcPort.ref();
129
- rpcPort.on("message", (response) => {
130
- const pending = pendingRpcRequests.get(response.id);
131
- if (pending) {
132
- pendingRpcRequests.delete(response.id);
133
- if (response.error) {
134
- pending.reject(new Error(response.error));
135
- } else {
136
- pending.resolve(response.result);
157
+ parentPort?.on("message", (msg) => {
158
+ void (async () => {
159
+ if (msg !== null && msg !== void 0 && typeof msg === "object" && "type" in msg && msg.type === "EXECUTE") {
160
+ const executeMsg = msg;
161
+ const {
162
+ id,
163
+ code,
164
+ methodList,
165
+ timeoutMs,
166
+ maxResultSize,
167
+ rpcPort: newRpcPort
168
+ } = executeMsg;
169
+ rpcPort = newRpcPort;
170
+ rpcIdCounter = 0;
171
+ pendingRpcRequests.clear();
172
+ rpcPort?.on("message", (response) => {
173
+ const pending = pendingRpcRequests.get(response.id);
174
+ if (pending) {
175
+ pendingRpcRequests.delete(response.id);
176
+ if (response.error) {
177
+ pending.reject(new Error(response.error));
178
+ } else {
179
+ pending.resolve(response.result);
180
+ }
181
+ }
182
+ });
183
+ const result = await executeCode(code, methodList, timeoutMs ?? 3e4);
184
+ if (result.success) {
185
+ try {
186
+ const egressLimit = maxResultSize ?? 100 * 1024;
187
+ let bytes = 0;
188
+ const cache = /* @__PURE__ */ new Set();
189
+ const resultJson = JSON.stringify(
190
+ result.result,
191
+ (_key, value) => {
192
+ if (typeof value === "object" && value !== null) {
193
+ if (cache.has(value)) return "[Circular]";
194
+ cache.add(value);
195
+ }
196
+ if (typeof value === "string") {
197
+ bytes += Buffer.byteLength(value, "utf8") + 2;
198
+ } else if (typeof value === "number" || typeof value === "boolean") {
199
+ bytes += Buffer.byteLength(String(value), "utf8");
200
+ } else {
201
+ bytes += 5;
202
+ }
203
+ if (bytes > egressLimit) {
204
+ throw new Error(`EgressLimitExceeded:${bytes}`);
205
+ }
206
+ return value;
207
+ }
208
+ );
209
+ if (resultJson !== void 0) {
210
+ const byteLength = Buffer.byteLength(resultJson, "utf8");
211
+ if (byteLength > egressLimit) {
212
+ throw new Error(`EgressLimitExceeded:${byteLength}`);
213
+ }
214
+ }
215
+ } catch (err) {
216
+ result.success = false;
217
+ const egressLimit = maxResultSize ?? 100 * 1024;
218
+ if (err instanceof Error && err.message.startsWith("EgressLimitExceeded:")) {
219
+ const actualBytesStr = err.message.split(":")[1];
220
+ const actualBytes = actualBytesStr !== void 0 ? Number(actualBytesStr) : egressLimit + 1;
221
+ const actualKb = (actualBytes / 1024).toFixed(1);
222
+ result.error = `Output limit exceeded: Result serialization exceeded the ${Math.round(egressLimit / 1024)}KB boundary (Actual size: >${actualKb}KB). Please aggregate or filter your results to reduce the payload size.`;
223
+ } else {
224
+ result.error = `Result could not be serialized or exceeded memory limits: ${err instanceof Error ? err.message : String(err)}`;
225
+ }
226
+ result.result = void 0;
227
+ }
228
+ }
229
+ rpcPort?.close();
230
+ rpcPort = null;
231
+ parentPort?.postMessage({ type: "RESULT", id, result });
137
232
  }
138
- }
139
- });
140
- void executeCode().then((result) => {
141
- rpcPort?.unref();
142
- rpcPort?.close();
143
- parentPort?.postMessage(result);
233
+ })();
144
234
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memory-journal-mcp",
3
- "version": "7.4.0",
3
+ "version": "7.6.0",
4
4
  "description": "Project context management for AI-assisted development - Persistent knowledge graphs and intelligent context recall across fragmented AI threads",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -25,8 +25,10 @@
25
25
  "test:watch": "vitest",
26
26
  "test:coverage": "vitest run --coverage && npx tsx scripts/update-badges.ts",
27
27
  "bench": "vitest bench --run",
28
+ "pretest:e2e": "node -e \"fs.rmSync('.test-output/e2e', { recursive: true, force: true })\"",
28
29
  "test:e2e": "playwright test",
29
- "generate:instructions": "node scripts/generate-server-instructions.ts"
30
+ "generate:instructions": "node scripts/generate-server-instructions.ts",
31
+ "prepublishOnly": "npm run check && npm run test && npm run build"
30
32
  },
31
33
  "keywords": [
32
34
  "mcp",
@@ -88,6 +90,7 @@
88
90
  "overrides": {
89
91
  "axios": "^1.13.6",
90
92
  "brace-expansion": "^2.0.2",
93
+ "diff": "9.0.0",
91
94
  "glob": "^11.1.0",
92
95
  "onnxruntime-web": "npm:empty-npm-package@1.0.0",
93
96
  "sharp": "npm:empty-npm-package@1.0.0",
package/skills/README.md CHANGED
@@ -45,6 +45,7 @@ The markdown body contains the full instructions the agent follows once the skil
45
45
  | `docker` | Production-grade Docker — multi-stage builds, security hardening, Compose v2, BuildKit, and CI/CD integration |
46
46
  | `github-actions` | GitHub Actions CI/CD — SHA pinning, reusable workflows, caching, matrix strategies, and artifacts v4 |
47
47
  | `github-commander` | GitHub pipeline workflows for orchestrating issues, regressions, and deployments |
48
+ | `github-copilot-cli` | Adversarial pre-push validation and full repository code audits driven by the @github/copilot terminal harness |
48
49
  | `gitlab` | Specialized assistant skill for managing repositories, code search, and CI/CD in GitLab |
49
50
  | `golang` | Master Go development with production-grade best practices from Google and Uber style guides |
50
51
  | `mysql` | Enterprise MySQL production rules — query safety, connection pooling, strict schema configurations |
@@ -67,6 +68,7 @@ This package natively bundles the `github-commander` skill, which equips your AI
67
68
  - **`issue-triage`**: End-to-end bug replication, PR submission, and Kanban lifecycle linking.
68
69
  - **`milestone-sprint`**: Sequential traversal of all open issues mapped to a specific release target.
69
70
  - **`pr-review`**: Exhaustive local execution, typechecking, and heuristic code reviews against base branches.
71
+ - **`copilot-audit`**: AI-evaluating-AI adversarial evaluations covering localized diffs and whole codebases.
70
72
  - **`security-audit`**: Deep Trivy/CodeQL supply chain matrix evaluation.
71
73
  - **`code-quality-audit`**: Enforcement of project guidelines, strict-typing boundaries, and import normalization.
72
74
  - **`perf-audit`**: Bundle-size constraints, runtime hot-path execution, and CI/CD cache-hit evaluations.
@@ -39,6 +39,7 @@ Load this skill when any of these apply:
39
39
  | ----------------------- | --------------------------------- | ------------------------------------------- |
40
40
  | **Issue Triage** | `workflows/issue-triage.md` | Fix a single GitHub issue end-to-end |
41
41
  | **PR Review** | `workflows/pr-review.md` | Review a PR with validation pipeline |
42
+ | **Copilot Audit** | `workflows/copilot-audit.md` | Adversarial Copilot CLI repo/PR review |
42
43
  | **Milestone Sprint** | `workflows/milestone-sprint.md` | Work through milestone issues sequentially |
43
44
  | **Roadmap Kickoff** | `workflows/roadmap-kickoff.md` | Translate planning epics into Kanban issues |
44
45
  | **Update Dependencies** | `workflows/update-deps.md` | Dependency update with audit trail |
@@ -0,0 +1,50 @@
1
+ # GitHub Copilot CLI Pre-Push Audit Workflow
2
+
3
+ This workflow orchestrates an AI-driven adversarial review using the GitHub Copilot CLI (`@github/copilot`). It acts as a strict secondary validation layer (a "second opinion") across both localized logic changes (PR reviews) and full repository inspections.
4
+
5
+ ## Phase 1: Environment Readiness & Authentication
6
+
7
+ 1. **Verify Copilot CLI Presence**:
8
+ Run `npm list -g @github/copilot`.
9
+ If missing, install it automatically: `npm i -g @github/copilot`.
10
+
11
+ 2. **Verify Authentication**:
12
+ Ensure the CLI is authenticated via `copilot auth`. If the user has not authenticated, pause the agentic execution and prompt them to authorize via the browser endpoint.
13
+
14
+ ## Phase 2: Execution Targeting (The Audit Context)
15
+
16
+ Determine whether this is a localized Feature Branch (Pre-Push PR) review or a whole Codebase Audit.
17
+
18
+ ### Path A: Pre-Push PR Review
19
+
20
+ 1. Diff the current working branch against the primary target (e.g., `main` or `master`).
21
+ 2. **Execute Single-Shot Evaluation Buffer**:
22
+ ```bash
23
+ git diff main | copilot "Act as an extremely strict, senior PR reviewer. Review this submitted git diff. Analyze edge cases, logic gaps, unhandled bounds, typescript compliance, and security flaws. Produce a Markdown-formatted table of defects."
24
+ ```
25
+
26
+ ### Path B: Comprehensive Codebase Review
27
+
28
+ 1. **Execute Single-Shot Codebase Buffer**:
29
+ ```bash
30
+ echo "Act as an adversarial security and performance auditor. Perform a comprehensive analysis of all files in this repository. Point out bad architectural couplings, injection vectors, unhandled error flows, and data boundaries that are not explicit. Output as a detailed Markdown report." | copilot
31
+ ```
32
+
33
+ ## Phase 3: Journal Archival (Verification Sync)
34
+
35
+ 1. Capture the exact Markdown payload generated by Copilot.
36
+ 2. Persist this via `memory-journal-mcp`:
37
+ - Tool: `create_entry` (or `team_create_entry` if shared).
38
+ - Type: `audit_finding` or `triage`.
39
+ - Title: "Copilot CLI Adversarial Review: [Topic]"
40
+ - Content: The generated JSON/Markdown from the terminal stdout.
41
+ - Tags: `copilot`, `review`, `github-commander`.
42
+
43
+ ## Phase 4: Human-in-the-Loop Gateway
44
+
45
+ 1. Analyze and summarize the Copilot payload.
46
+ 2. Present the summarized critique directly to the User.
47
+ 3. Pause and Wait. Do not commit or push the code.
48
+ 4. **Branching Action**:
49
+ - If User approves changes: Remediate the code directly based on Copilot's findings using local agent tool capabilities (`replace_file_content`, etc).
50
+ - If User rejects/ignores the findings: Proceed to standard commit and push pipelines.
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: github-copilot-cli
3
+ description: |
4
+ Documentation and instructions for integrating the GitHub Copilot CLI (`copilot`)
5
+ into agentic workflows. Use this skill when you need a "second opinion" adversarial
6
+ review of a local codebase, a pre-push PR review using alternative advanced models,
7
+ or shell suggestion capabilities from GitHub. Activates on "Copilot CLI", "local PR review",
8
+ or "codebase Copilot review".
9
+ ---
10
+
11
+ # GitHub Copilot CLI
12
+
13
+ The GitHub Copilot CLI (`@github/copilot`) acts as an interactive, terminal-native representation of the Copilot agentic ecosystem.
14
+
15
+ When integrated into an AI workflow (AI evaluating AI), it acts as a robust secondary reviewer mapping against different context windows and potentially different foundational models than the primary agent, significantly reducing confirmation bias during PR or full-repository reviews.
16
+
17
+ ## Installation & Authentication Baseline
18
+
19
+ Before using the CLI in automated pipelines, ensure the terminal environment is equipped and authenticated:
20
+
21
+ ```bash
22
+ # 1. Verify availability
23
+ npm list -g @github/copilot
24
+
25
+ # 2. Install if missing
26
+ npm i -g @github/copilot
27
+
28
+ # 3. Authenticate (Requires human interaction/browser approval)
29
+ copilot auth
30
+ ```
31
+
32
+ ## Agentic Interaction Strategies
33
+
34
+ Because the Copilot CLI launches an interactive REPL (`? What would you like to do?`), standalone non-interactive agents cannot easily navigate its interactive curses UI natively.
35
+
36
+ To effectively harness it during automated reviews, you must format non-interactive input buffers or leverage its single-shot explanation endpoints:
37
+
38
+ ### Non-Interactive Command Piping
39
+
40
+ While primarily interactive, you can echo requests directly into the tool for one-shot evaluation loops.
41
+
42
+ ```bash
43
+ # Full Repository Security Audit
44
+ echo "Please perform a comprehensive security analysis of all files in this repository. Point out unchecked injections, logic flaws, and credential leaks. Present it in markdown." | copilot
45
+
46
+ # Pre-Push PR Diff Review
47
+ git diff main | copilot "Act as a strict PR reviewer. Here is my local diff against main. List specifically what will break, style issues, and any unhandled edge cases."
48
+ ```
49
+
50
+ ### Direct Tool Commands
51
+
52
+ For precise shell suggestions or file explanations:
53
+
54
+ ```bash
55
+ # Shell Suggestion (Evaluates context and produces command)
56
+ gh copilot suggest "find all files over 5mb in the current directory"
57
+
58
+ # File Explanation
59
+ gh copilot explain "src/utils/crypto.ts"
60
+ ```
61
+
62
+ ## Workflows Integration
63
+
64
+ This skill works synergistically with `github-commander`. Use the `copilot-audit` workflow via `github-commander` to execute a structured, auditable validation loop utilizing this CLI before generating PRs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neverinfamous-agent-skills",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Foundational AI agent metacognitive skills and workflows for the Adamic ecosystem.",
5
5
  "type": "module",
6
6
  "main": "README.md",
@@ -15,6 +15,7 @@
15
15
  "docker/",
16
16
  "github-actions/",
17
17
  "github-commander/",
18
+ "github-copilot-cli/",
18
19
  "gitlab/",
19
20
  "golang/",
20
21
  "mysql/",
@@ -1,28 +0,0 @@
1
- // src/codemode/auto-return.ts
2
- var NON_RETURNABLE = /^\s*(return|throw|const |let |var |if\b|else\b|for\b|while\b|do\b|switch\b|try\b|catch\b|finally\b|class |function |\/\/|\/\*|\{|\})/;
3
- function transformAutoReturn(code) {
4
- const trimmed = code.trimEnd();
5
- if (!trimmed) return code;
6
- let depth = 0;
7
- let splitIndex = -1;
8
- for (let i = trimmed.length - 1; i >= 0; i--) {
9
- const ch = trimmed.charAt(i);
10
- if (ch === "}" || ch === "]" || ch === ")") depth++;
11
- else if (ch === "{" || ch === "[" || ch === "(") depth--;
12
- if (depth === 0 && (ch === ";" || ch === "\n")) {
13
- splitIndex = i;
14
- break;
15
- }
16
- }
17
- const lastStmt = (splitIndex >= 0 ? trimmed.slice(splitIndex + 1) : trimmed).trim();
18
- if (!lastStmt) return code;
19
- if (NON_RETURNABLE.test(lastStmt)) return code;
20
- if (splitIndex >= 0) {
21
- const before = trimmed.slice(0, splitIndex + 1);
22
- return `${before}
23
- return ${lastStmt}`;
24
- }
25
- return `return ${trimmed}`;
26
- }
27
-
28
- export { transformAutoReturn };