Parcourir la source

Add IMESSAGE_APPEND_SIGNATURE env var (default true)

Kenneth Lien il y a 5 mois
Parent
commit
6d0053f69e
2 fichiers modifiés avec 11 ajouts et 1 suppressions
  1. 8 1
      external_plugins/imessage/README.md
  2. 3 0
      external_plugins/imessage/server.ts

+ 8 - 1
external_plugins/imessage/README.md

@@ -17,7 +17,7 @@ If you click Don't Allow, or the prompt never appears, grant it manually: **Syst
 
 These are Claude Code commands — run `claude` to start a session first.
 
-Install the plugin. No env vars needed.
+Install the plugin. No env vars required.
 ```
 /plugin install imessage@claude-plugins-official
 ```
@@ -57,6 +57,13 @@ Handles are phone numbers (`+15551234567`) or Apple ID emails (`them@icloud.com`
 | **History & search** | Direct SQLite queries against `chat.db`. Full history — not just messages since the server started. |
 | **Attachments** | `chat.db` stores absolute filesystem paths. The first inbound image per message is surfaced to the assistant as a local path it can `Read`. Outbound attachments send as separate messages after the text. |
 
+## Environment variables
+
+| Variable | Default | Effect |
+| --- | --- | --- |
+| `IMESSAGE_APPEND_SIGNATURE` | `true` | Appends `\nSent by Claude` to outbound messages. Set to `false` to disable. |
+| `IMESSAGE_ACCESS_MODE` | — | Set to `static` to disable runtime pairing and read `access.json` only. |
+
 ## Access control
 
 See **[ACCESS.md](./ACCESS.md)** for DM policies, groups, self-chat, delivery config, skill commands, and the `access.json` schema.

+ 3 - 0
external_plugins/imessage/server.ts

@@ -30,6 +30,8 @@ import { homedir } from 'os'
 import { join, basename, sep } from 'path'
 
 const STATIC = process.env.IMESSAGE_ACCESS_MODE === 'static'
+const APPEND_SIGNATURE = process.env.IMESSAGE_APPEND_SIGNATURE !== 'false'
+const SIGNATURE = '\nSent by Claude'
 const CHAT_DB = join(homedir(), 'Library', 'Messages', 'chat.db')
 
 const STATE_DIR = join(homedir(), '.claude', 'channels', 'imessage')
@@ -550,6 +552,7 @@ mcp.setRequestHandler(CallToolRequestSchema, async req => {
         const limit = Math.max(1, Math.min(access.textChunkLimit ?? MAX_CHUNK_LIMIT, MAX_CHUNK_LIMIT))
         const mode = access.chunkMode ?? 'length'
         const chunks = chunk(text, limit, mode)
+        if (APPEND_SIGNATURE && chunks.length > 0) chunks[chunks.length - 1] += SIGNATURE
         let sent = 0
 
         for (let i = 0; i < chunks.length; i++) {