@theronap/agnoclast-mcp 0.9.339 → 0.9.341

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.
@@ -12,10 +12,26 @@
12
12
  // (npx @theronap/agnoclast-mcp antigravity-sync, or a published cortex-agent) — a prerequisite this
13
13
  // adapter cannot satisfy alone. Until then wire() writes the artifacts + returns a blocking warning.
14
14
  import { homedir } from 'node:os'
15
- import { writeFileSync, existsSync, mkdirSync, chmodSync } from 'node:fs'
15
+ import { writeFileSync, existsSync, mkdirSync, chmodSync, readFileSync } from 'node:fs'
16
16
  import { join } from 'node:path'
17
+ import { backupFile } from './_fsutil.mjs'
17
18
 
18
19
  const AG_STATE = ['Library', 'Application Support', 'Antigravity']
20
+
21
+ // MCP WIRING (2026-11-12, Theron: "that's not how it connects Claude Code and Codex"). Antigravity is wired the
22
+ // way Cursor is: the desktop app's Connect runs `install --editor antigravity`, which merges a stdio server into
23
+ // Antigravity's GLOBAL MCP config. Path and shape from antigravity.google/docs/mcp (read 2026-11-12): global
24
+ // `~/.gemini/config/mcp_config.json`, root key `mcpServers`, a stdio entry takes `command`/`args`/`env`.
25
+ const AG_MCP_CONFIG = ['.gemini', 'config', 'mcp_config.json']
26
+
27
+ /** Merge the Agnoclast MCP server into an Antigravity mcp_config.json object. Pure + idempotent, like
28
+ * mergeCursorMcp: sets only the `agnoclast` entry and keeps every other server. */
29
+ export function mergeAntigravityMcp(existing, spec, token) {
30
+ const cfg = existing && typeof existing === 'object' ? { ...existing } : {}
31
+ cfg.mcpServers = cfg.mcpServers && typeof cfg.mcpServers === 'object' ? { ...cfg.mcpServers } : {}
32
+ cfg.mcpServers.agnoclast = { command: 'npx', args: ['-y', spec], env: { CORTEX_TOKEN: token } }
33
+ return cfg
34
+ }
19
35
  const AG_WATCH = [...AG_STATE, 'User', 'globalStorage']
20
36
 
21
37
  /** The launchd plist, home-substituted. Deterministic — golden-testable byte-for-byte. */
@@ -102,10 +118,44 @@ export default {
102
118
  docTrigger: 'watch',
103
119
  },
104
120
 
105
- // Writes the two artifacts deterministically. Does NOT launchctl-load (unverifiable side effect) and
106
- // returns a BLOCKING warning about the dev-checkout dependency — honest about not-yet-installable.
107
- async wire({ home = homedir(), log = () => {} } = {}) {
121
+ // 1. The MCP server, into Antigravity's global config (what Connect is for). 2. Capture artifacts, ONLY where
122
+ // the dev checkout they run from exists (see BLOCKER): on anyone else's machine they would be a watcher that
123
+ // can never work, so they are not written at all.
124
+ async wire({ home = homedir(), token, spec, log = () => {} } = {}) {
108
125
  const wrote = [], skipped = [], warnings = []
126
+
127
+ if (!token) warnings.push('no token — skipped the Antigravity MCP server')
128
+ else {
129
+ const mcpPath = join(home, ...AG_MCP_CONFIG)
130
+ try { // non-fatal: an IO error must not abort sibling editors
131
+ let existing = {}
132
+ if (existsSync(mcpPath)) {
133
+ const raw = readFileSync(mcpPath, 'utf8')
134
+ if (raw.trim()) {
135
+ try { existing = JSON.parse(raw) } catch {
136
+ // Data-loss guard, as for Cursor: it may hold other servers we cannot safely parse.
137
+ warnings.push(`${mcpPath} is not valid JSON — left untouched (fix it, then re-run) to avoid dropping your other MCP servers`)
138
+ existing = null
139
+ }
140
+ }
141
+ }
142
+ if (existing) {
143
+ const bak = backupFile(mcpPath)
144
+ mkdirSync(join(home, ...AG_MCP_CONFIG.slice(0, -1)), { recursive: true })
145
+ writeFileSync(mcpPath, JSON.stringify(mergeAntigravityMcp(existing, spec, token), null, 2))
146
+ wrote.push(mcpPath)
147
+ log(` ✓ MCP server → ${mcpPath}${bak ? ' (backup saved)' : ''}`)
148
+ }
149
+ } catch (e) {
150
+ warnings.push(`Antigravity MCP wiring skipped: ${e.message}`)
151
+ }
152
+ }
153
+
154
+ const agentDir = join(home, 'dev', 'cortex', 'packages', 'cortex-agent')
155
+ if (!existsSync(agentDir)) {
156
+ skipped.push('Antigravity session capture (needs the cortex-agent dev checkout — see the BLOCKER note)')
157
+ return { wrote, skipped, warnings }
158
+ }
109
159
  const cortexDir = join(home, '.cortex')
110
160
  const shPath = join(cortexDir, 'antigravity-sync.sh')
111
161
  const plistPath = join(home, 'Library', 'LaunchAgents', 'com.cortex.antigravity-sync.plist')
@@ -124,7 +174,7 @@ export default {
124
174
  warnings.push(`Antigravity artifact write skipped: ${e.message}`)
125
175
  }
126
176
 
127
- warnings.push('Antigravity NOT fully wired: (1) run `launchctl load ' + plistPath + '` to activate the watcher; (2) BLOCKER — the sync runs from a local dev checkout (~/dev/cortex/packages/cortex-agent), so it will not work on a machine without that checkout until a published antigravity-sync entrypoint exists.')
177
+ warnings.push('Antigravity capture NOT fully wired: (1) run `launchctl load ' + plistPath + '` to activate the watcher; (2) BLOCKER — the sync runs from a local dev checkout (~/dev/cortex/packages/cortex-agent), so it will not work on a machine without that checkout until a published antigravity-sync entrypoint exists.')
128
178
  return { wrote, skipped, warnings }
129
179
  },
130
180
  }
@@ -11,7 +11,7 @@
11
11
  // That is safe because hiding a tool is a courtesy, and every gated route checks its own flag on the server.
12
12
 
13
13
  /** Tools any release flag gates — hidden when the server cannot be asked. Mirror of allGatedTools(). */
14
- export const GATED_FALLBACK = ['arrivals', 'attach_document', 'document_diff', 'download_file', 'export_page', 'file_arrival', 'file_document', 'find_documents', 'finish_task', 'get_document', 'hand_task', 'handed_tasks', 'hold_task', 'import_document_as_page', 'intake_shadow', 'list_documents', 'log_work', 'merge_pages', 'my_messages', 'my_tasks', 'pin_document', 'place_split_records', 'read_conversation', 'read_document', 'relink_links', 'send_message', 'set_manager', 'set_working_hours', 'split_page', 'split_records', 'store_file', 'tasks_waiting', 'undo_merge', 'undo_relink', 'undo_split', 'upload_document_version', 'work_log']
14
+ export const GATED_FALLBACK = ['arrivals', 'attach_document', 'document_diff', 'download_file', 'end_demo', 'export_page', 'file_arrival', 'file_document', 'find_documents', 'finish_task', 'get_document', 'hand_task', 'handed_tasks', 'hold_task', 'import_document_as_page', 'intake_shadow', 'list_documents', 'log_work', 'merge_pages', 'my_messages', 'my_tasks', 'pin_document', 'place_split_records', 'read_conversation', 'read_document', 'relink_links', 'send_message', 'set_manager', 'set_working_hours', 'split_page', 'split_records', 'start_demo', 'store_file', 'tasks_waiting', 'undo_merge', 'undo_relink', 'undo_split', 'upload_document_version', 'work_log']
15
15
 
16
16
  export const RELEASE_FETCH_TIMEOUT_MS = 2500
17
17
  /** A remembered answer older than this is not trusted: a week covers a quiet weekend without hiding tools for long. */
package/lib/server.mjs CHANGED
@@ -47,7 +47,7 @@ import {
47
47
  UPDATE_EVENT_DESCRIPTION, UPDATE_SERIES_DESCRIPTION, renderEventCancelled, renderSeriesRevised, seriesPatchBody,
48
48
  } from './calendar_events.mjs'
49
49
  import { formatFoundDocuments } from './found_documents.mjs'
50
- import { renderWorkLog } from './work_log_render.mjs'
50
+ import { renderLogWorkResult, renderWorkLog } from './work_log_render.mjs'
51
51
  import { fileSealedCapture } from './file_sealed_capture.mjs'
52
52
 
53
53
  // PAGE tiers (ADR-0071). Six for a PAGE; a RECORD keeps three (`privacy` on log_session and
@@ -2280,7 +2280,7 @@ function renderNudge(payload) {
2280
2280
  text: z.string().min(1).describe('the message body, as plain text'),
2281
2281
  cc: z.array(z.string()).optional().describe('cc addresses'),
2282
2282
  bcc: z.array(z.string()).optional().describe('bcc addresses'),
2283
- replyToRecordId: z.string().optional().describe('reply in the thread of this Agnoclast email record'),
2283
+ replyToRecordId: z.string().optional().describe('the Agnoclast email record you are answering. ALWAYS pass it (or replyToMessageId) when replying to someone\'s email, so the answer stays in their thread; without it they get a new, unconnected email'),
2284
2284
  replyToMessageId: z.string().optional().describe('reply in the thread of this message id (Gmail or Outlook)'),
2285
2285
  account: z.string().email().optional().describe('which connected mailbox (Gmail or Outlook) to send from, when the user has more than one'),
2286
2286
  from: z.enum(['own', 'overseer']).optional().describe("AI member agents only: 'own' (default) = your own address; 'overseer' = the mailbox an overseer opened to you"),
@@ -6634,7 +6634,8 @@ function renderNudge(payload) {
6634
6634
  const d = classify(res.status, res.headers.get('content-type'), await res.text(), res.headers.get('x-vercel-id'))
6635
6635
  return toolError(`Could not add to your work log: ${d.message}`)
6636
6636
  }
6637
- return { content: [{ type: 'text', text: 'Added to your work log for today.' }] }
6637
+ const out = await res.json().catch(() => null)
6638
+ return { content: [{ type: 'text', text: renderLogWorkResult(out?.pagesBehind) }] }
6638
6639
  },
6639
6640
  )
6640
6641
 
@@ -1,7 +1,10 @@
1
1
  // Renders GET /api/me/work-log for the `work_log` tool. Mirrors renderWorkLog in web/lib/engine/agent_work_log.ts
2
2
  // (the hosted connector's copy), which this package cannot import.
3
3
  const TZ = 'America/Denver'
4
- const KIND_WORD = { edit: 'edited', placement: 'filed', discard: 'discarded an arrival from' }
4
+ const KIND_WORD = { edit: 'edited', placement: 'filed', discard: 'discarded an arrival from', send: 'emailed' }
5
+
6
+ const PAGE_DEBT_HOW = 'A work-log line does not catch a page up. Read each one and fold in what the newer records change with edit_page. '
7
+ + 'If they change nothing on a page, name that page in log_work\'s `pages` and say so in the line; that clears it.'
5
8
 
6
9
  const time = (iso) => new Date(iso).toLocaleTimeString('en-US', { timeZone: TZ, hour: 'numeric', minute: '2-digit' })
7
10
  const stub = (a) => `${KIND_WORD[a.kind] ?? a.kind} ${a.what ? `"${a.what}"` : 'an item'}${a.reason ? ` (${a.reason})` : ''}`
@@ -20,7 +23,7 @@ export function renderWorkLog(log) {
20
23
  if (behind.length) {
21
24
  out.push('', `Agnoclast pages: ${behind.length} page${behind.length === 1 ? '' : 's'} you work on ${behind.length === 1 ? 'has' : 'have'} records newer than the page itself:`,
22
25
  ...behind.slice(0, 20).map((p) => `- "${p.title}": ${p.newer} record${p.newer === 1 ? '' : 's'} filed on it since its last edit (edit_page base_version ${p.version ?? '(read_page for it)'})`),
23
- 'Fold in what they change with edit_page, and say so in your log_work line.')
26
+ PAGE_DEBT_HOW)
24
27
  }
25
28
  if (uncovered.length) {
26
29
  out.push('', `Not yet covered by a line (${uncovered.length}):`,
@@ -29,3 +32,12 @@ export function renderWorkLog(log) {
29
32
  }
30
33
  return out.join('\n')
31
34
  }
35
+
36
+ /** What log_work answers (mirrors renderLogWorkResult): the line is saved, and any page still behind is named. */
37
+ export function renderLogWorkResult(pagesBehind) {
38
+ if (!pagesBehind?.length) return 'Added to your work log for today.'
39
+ const shown = pagesBehind.slice(0, 5).map((p) =>
40
+ ` - "${p.title}": ${p.newer} record${p.newer === 1 ? '' : 's'} filed on it since its last edit (edit_page base_version ${p.version ?? '(read_page for it)'})`).join('\n')
41
+ const more = pagesBehind.length > 5 ? `\n - …and ${pagesBehind.length - 5} more` : ''
42
+ return `Added to your work log for today. It did not catch these pages up:\n\n${shown}${more}\n${PAGE_DEBT_HOW}`
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/agnoclast-mcp",
3
- "version": "0.9.339",
3
+ "version": "0.9.341",
4
4
  "description": "Connect your AI assistant to Cortex — your org's projects, activity, gaps, and directives, scoped to you.",
5
5
  "type": "module",
6
6
  "bin": {