feishu-user-plugin 1.3.7 → 1.3.9

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.
Files changed (54) hide show
  1. package/.claude-plugin/plugin.json +13 -3
  2. package/CHANGELOG.md +87 -0
  3. package/README.md +20 -4
  4. package/package.json +10 -6
  5. package/proto/lark.proto +10 -0
  6. package/scripts/capture-feishu-protobuf.js +86 -0
  7. package/scripts/check-changelog.js +31 -0
  8. package/scripts/check-docs-sync.js +41 -0
  9. package/scripts/check-tool-count.js +32 -7
  10. package/scripts/decode-feishu-protobuf.js +115 -0
  11. package/scripts/explore-card-protobuf.js +144 -0
  12. package/scripts/explore-image-minimize.js +163 -0
  13. package/scripts/generate-release-artifacts.js +318 -0
  14. package/scripts/probe-feishu-docx.js +203 -0
  15. package/scripts/sync-server-json.js +71 -0
  16. package/scripts/sync-team-skills.sh +109 -7
  17. package/scripts/test-wiki-attach-fallback.js +71 -0
  18. package/scripts/test-ws-events.js +84 -0
  19. package/skills/feishu-user-plugin/SKILL.md +77 -5
  20. package/skills/feishu-user-plugin/references/CLAUDE.md +208 -297
  21. package/src/auth/cookie.js +30 -0
  22. package/src/auth/credentials.js +85 -0
  23. package/src/auth/profile-router.js +248 -0
  24. package/src/auth/uat.js +231 -0
  25. package/src/cli.js +86 -42
  26. package/src/clients/official/base.js +12 -248
  27. package/src/clients/user.js +19 -31
  28. package/src/config.js +13 -8
  29. package/src/events/cursor.js +103 -0
  30. package/src/events/event-buffer.js +103 -0
  31. package/src/events/event-log.js +151 -0
  32. package/src/events/index.js +12 -0
  33. package/src/events/lockfile.js +126 -0
  34. package/src/events/owner.js +73 -0
  35. package/src/events/ws-server.js +156 -0
  36. package/src/oauth.js +48 -7
  37. package/src/resolver.js +10 -0
  38. package/src/server.js +285 -3
  39. package/src/setup.js +100 -11
  40. package/src/test-all.js +12 -9
  41. package/src/test-events-cursor.js +56 -0
  42. package/src/test-events-lockfile.js +36 -0
  43. package/src/test-events-log.js +67 -0
  44. package/src/test-events-owner.js +64 -0
  45. package/src/test-fixtures/doc-blocks/sample-1.json +1256 -0
  46. package/src/test-read-doc-markdown.js +61 -0
  47. package/src/test-switch-profile.js +171 -0
  48. package/src/tools/_registry.js +1 -0
  49. package/src/tools/diagnostics.js +10 -3
  50. package/src/tools/docs.js +93 -3
  51. package/src/tools/events.js +174 -0
  52. package/src/tools/messaging-bot.js +2 -3
  53. package/src/tools/messaging-user.js +23 -14
  54. package/src/tools/profile.js +43 -7
@@ -1,28 +1,46 @@
1
- // src/tools/profile.js — multi-account profile management (v1.3.6).
1
+ // src/tools/profile.js — multi-account profile management.
2
2
  //
3
- // LARK_PROFILES_JSON env var registers extra credential sets; this module
4
- // exposes them via list_profiles + switch_profile so callers can hot-swap
5
- // between accounts/tenants without restarting the MCP server.
3
+ // v1.3.9 SSOT: profiles live in ~/.feishu-user-plugin/credentials.json under
4
+ // `profiles[]`. Switching writes `active` field; cross-process MCP picks it up
5
+ // via dispatcher mtime hook (~10μs/call) within ms.
6
+ //
7
+ // Legacy LARK_PROFILES_JSON env still works as a back-compat fallback when
8
+ // credentials.json doesn't exist. New profiles should be added via
9
+ // `npx feishu-user-plugin setup --profile <name> --app-id ... --app-secret ... --cookie ...`,
10
+ // then optionally `npx feishu-user-plugin oauth --profile <name>` for UAT.
6
11
 
7
12
  const { text, json } = require('./_registry');
8
13
 
9
14
  const schemas = [
10
15
  {
11
16
  name: 'list_profiles',
12
- description: '[Plugin] List all available identity profiles (sets of LARK_COOKIE/APP_ID/APP_SECRET/UAT). The "default" profile uses the top-level env vars; additional profiles come from LARK_PROFILES_JSON. Marks the currently active profile.',
17
+ description: '[Plugin] List all available identity profiles (each profile has its own LARK_COOKIE / APP_ID / APP_SECRET / UAT). v1.3.9 SSOT: profiles live in ~/.feishu-user-plugin/credentials.json::profiles. Legacy fallback: LARK_PROFILES_JSON env var. Marks the currently active profile.',
13
18
  inputSchema: { type: 'object', properties: {} },
14
19
  },
15
20
  {
16
21
  name: 'switch_profile',
17
- description: '[Plugin] Switch the active identity profile. Subsequent tool calls use the new profile\'s credentials. Cached client instances are reset so the next call rebuilds against the new creds.',
22
+ description: '[Plugin v1.3.9] Switch the active identity profile. Atomically writes credentials.json::active; cached clients in this process are invalidated; cross-process MCPs (Codex / another Claude Code) auto-sync via dispatcher mtime check on next tool call (~10μs). To add a new profile, run `npx feishu-user-plugin setup --profile <name> --app-id ... --app-secret ... --cookie ...` then `npx feishu-user-plugin oauth --profile <name>` for UAT.',
18
23
  inputSchema: {
19
24
  type: 'object',
20
25
  properties: {
21
- name: { type: 'string', description: 'Profile name. "default" for top-level env vars; any key from LARK_PROFILES_JSON otherwise.' },
26
+ name: { type: 'string', description: 'Profile name. Use "default" for the primary profile; other names come from credentials.json or LARK_PROFILES_JSON.' },
22
27
  },
23
28
  required: ['name'],
24
29
  },
25
30
  },
31
+ {
32
+ name: 'manage_profile_hints',
33
+ description: '[Plugin v1.3.8] Inspect / set / clear profileHints — the resourceKey → profileName cache the auto-switch middleware uses to remember which profile owns each Feishu resource. Useful when a hint goes stale (e.g., a profile lost access to a doc).',
34
+ inputSchema: {
35
+ type: 'object',
36
+ properties: {
37
+ action: { type: 'string', enum: ['list', 'set', 'clear'], description: 'list = show all hints; set = upsert one; clear = remove one or all.' },
38
+ resource_key: { type: 'string', description: 'For set/clear: the resourceKey, e.g. "doc:doccnXXX" or "chat:oc_zzz". Omit on clear to wipe all hints.' },
39
+ profile: { type: 'string', description: 'For set: the profile name to associate with the resource_key.' },
40
+ },
41
+ required: ['action'],
42
+ },
43
+ },
26
44
  ];
27
45
 
28
46
  const handlers = {
@@ -38,6 +56,24 @@ const handlers = {
38
56
  ctx.setActiveProfile(target);
39
57
  return text(`Switched to profile: ${target}`);
40
58
  },
59
+ async manage_profile_hints(args, _ctx) {
60
+ const credentials = require('../auth/credentials');
61
+ if (args.action === 'list') {
62
+ return json({ hints: credentials.getProfileHints() });
63
+ }
64
+ if (args.action === 'set') {
65
+ if (!args.resource_key) return text('manage_profile_hints(set): resource_key is required');
66
+ if (!args.profile) return text('manage_profile_hints(set): profile is required');
67
+ const ok = credentials.setProfileHint(args.resource_key, args.profile);
68
+ return text(ok ? `Hint set: ${args.resource_key} → ${args.profile}` : 'Hint not set (no credentials.json — run `npx feishu-user-plugin migrate --confirm`)');
69
+ }
70
+ if (args.action === 'clear') {
71
+ const ok = credentials.clearProfileHint(args.resource_key);
72
+ const target = args.resource_key || '<all>';
73
+ return text(ok ? `Hint cleared: ${target}` : `No hint to clear for: ${target}`);
74
+ }
75
+ return text(`manage_profile_hints: unknown action "${args.action}". Use list / set / clear.`);
76
+ },
41
77
  };
42
78
 
43
79
  module.exports = { schemas, handlers };