opencode-feishu-plugin 0.2.9 → 0.2.10

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.en.md CHANGED
@@ -182,7 +182,7 @@ Full config (including `cardMaxTables`, `topicStatus*`, `resumeSummary*`, `keepa
182
182
 
183
183
  Iterating from real usage feedback; current plan:
184
184
 
185
- - [x] **Accept images / files**: done — downloaded automatically into `<configDir>/plugins/feishu-files/` and attached to the session (requires `im:message:readonly`; default max 20MB per attachment).
185
+ - [x] **Accept images / files**: done — downloaded automatically into the session working directory at `.opencode/temp/opencode-feishu-plugin/` (with a built-in `.gitignore`, so `git status` stays clean; override with `attachmentsDir`; default max 20MB per attachment).
186
186
  - [ ] **New messages cut in by default when busy**: currently new messages queue natively while a session is busy (manual cut-in via `/steer`, `/now`). Planned: new messages default to **cutting in immediately**, interrupting the current step to run first.
187
187
 
188
188
  ## Advanced topics & development
package/README.md CHANGED
@@ -182,7 +182,7 @@ agent 反问时表单会变成飞书卡片,**点按钮或在话题里直接发
182
182
 
183
183
  按真实使用反馈迭代,当前规划:
184
184
 
185
- - [x] **接收图片 / 文件**:已支持——自动下载到 `<configDir>/plugins/feishu-files/` 并作为附件挂进会话(需开 `im:message:readonly`;单附件默认 ≤20MB)。
185
+ - [x] **接收图片 / 文件**:已支持——自动下载到**会话工作目录**下的 `.opencode/temp/opencode-feishu-plugin/`(内置 `.gitignore`,不污染 `git status`;可用 `attachmentsDir` 覆盖;单附件默认 ≤20MB)。
186
186
  - [ ] **忙时新消息默认插队**:目前会话忙时新消息默认排队(可用 `/steer`、`/now` 手动插队)。规划:忙时你发的新消息**默认直接插队**,立即打断当前步骤优先执行。
187
187
 
188
188
  ## 高级主题与开发
package/dist/index.js CHANGED
@@ -4,14 +4,14 @@ import http from 'http';
4
4
  import https from 'https';
5
5
  import http2 from 'http2';
6
6
  import util from 'util';
7
- import path, { dirname, isAbsolute, join, sep, resolve as resolve$1, basename } from 'path';
7
+ import path, { dirname, isAbsolute, sep, join, resolve as resolve$1, basename } from 'path';
8
8
  import zlib from 'zlib';
9
9
  import stream3, { Readable } from 'stream';
10
10
  import { EventEmitter } from 'events';
11
11
  import fs, { mkdirSync, createWriteStream, readFileSync, realpathSync, statSync } from 'fs';
12
12
  import qs from 'querystring';
13
- import { homedir } from 'os';
14
- import { mkdir, stat, rm, readFile, readdir } from 'fs/promises';
13
+ import { homedir, tmpdir } from 'os';
14
+ import { mkdir, stat, rm, writeFile, readFile, readdir } from 'fs/promises';
15
15
 
16
16
  var __create = Object.create;
17
17
  var __defProp = Object.defineProperty;
@@ -144037,7 +144037,6 @@ function resolveConfig2(raw, env = process.env, deps = {}) {
144037
144037
  );
144038
144038
  const attachmentTimeoutMs = clamp4(asNumber(merged.attachmentTimeoutMs, 3e4), 5e3, 12e4);
144039
144039
  const attachmentsDirRaw = asString(merged.attachmentsDir).trim();
144040
- const attachmentsDir = attachmentsDirRaw ? attachmentsDirRaw : join(resolveConfigDir(env, deps.configDir), "plugins", "feishu-files");
144041
144040
  const keepaliveIntervalMs = clamp4(
144042
144041
  asNumber(merged.keepaliveIntervalMs, 20 * 60 * 1e3),
144043
144042
  5 * 60 * 1e3,
@@ -144102,7 +144101,7 @@ function resolveConfig2(raw, env = process.env, deps = {}) {
144102
144101
  acceptAttachments,
144103
144102
  attachmentMaxBytes,
144104
144103
  attachmentTimeoutMs,
144105
- attachmentsDir
144104
+ ...attachmentsDirRaw ? { attachmentsDir: attachmentsDirRaw } : {}
144106
144105
  };
144107
144106
  }
144108
144107
  function loadConfigFile(env, deps, warnings) {
@@ -145257,6 +145256,18 @@ function createFeishuSender(client, log2, options2 = {}) {
145257
145256
  }
145258
145257
  };
145259
145258
  }
145259
+ var ATTACHMENT_DIR_RELATIVE = [".opencode", "temp", "opencode-feishu-plugin"];
145260
+ function resolveAttachmentDir(override, sessionDir) {
145261
+ if (override && override.trim()) return override.trim();
145262
+ if (sessionDir && sessionDir.trim()) return join(sessionDir.trim(), ...ATTACHMENT_DIR_RELATIVE);
145263
+ return join(tmpdir(), "opencode-feishu-plugin");
145264
+ }
145265
+ async function ensureAttachmentDirGitIgnored(dir) {
145266
+ try {
145267
+ await writeFile(join(dir, ".gitignore"), "*\n", { flag: "wx" });
145268
+ } catch {
145269
+ }
145270
+ }
145260
145271
  var AttachmentTimeoutError = class extends Error {
145261
145272
  constructor() {
145262
145273
  super("attachment-timeout");
@@ -145316,11 +145327,12 @@ function attachmentSavedPrompt(input) {
145316
145327
  return input.kind === "image" ? `[\u9644\u4EF6] \u56FE\u7247\u300C${input.name}\u300D\u5DF2\u4FDD\u5B58\u5230 ${input.path}\uFF08${size6}\uFF09\uFF0C\u53EF\u76F4\u63A5\u67E5\u770B\u3002` : `[\u9644\u4EF6] \u6587\u4EF6\u300C${input.name}\u300D\u5DF2\u4FDD\u5B58\u5230 ${input.path}\uFF08${size6}\uFF09\u3002`;
145317
145328
  }
145318
145329
  async function downloadAttachment(input) {
145319
- const { client, messageId, attachment, dir, maxBytes, timeoutMs, log: log2 } = input;
145330
+ const { client, messageId, attachment, dir, maxBytes, timeoutMs, log: log2, gitIgnore } = input;
145320
145331
  const startedAt = Date.now();
145321
145332
  let target;
145322
145333
  try {
145323
145334
  await mkdir(dir, { recursive: true });
145335
+ if (gitIgnore) await ensureAttachmentDirGitIgnored(dir);
145324
145336
  const res = await withTimeout(
145325
145337
  client.im.messageResource.get({
145326
145338
  params: { type: attachment.kind },
@@ -151978,10 +151990,12 @@ async function start(ctx, config, log2, logSink) {
151978
151990
  client,
151979
151991
  messageId: message.messageId,
151980
151992
  attachment: message.attachment,
151981
- dir: config.attachmentsDir,
151993
+ dir: resolveAttachmentDir(config.attachmentsDir, link2?.dir),
151982
151994
  maxBytes: config.attachmentMaxBytes,
151983
151995
  timeoutMs: config.attachmentTimeoutMs,
151984
- log: log2
151996
+ log: log2,
151997
+ // 显式配置的目录不动;默认的会话内目录顺手放 `.gitignore`,避免污染 git status。
151998
+ ...config.attachmentsDir ? {} : { gitIgnore: true }
151985
151999
  });
151986
152000
  if (outcome.ok) {
151987
152001
  files.push({ uri: pathToFileURL(outcome.path).href });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-feishu-plugin",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "Feishu/Lark plugin for OpenCode V2 — single-user topics as sessions, in-card permission approvals, streaming cards. Minimal permissions, no public endpoint.",
5
5
  "type": "module",
6
6
  "main": "index.js",