agent-things 1.2.2 → 1.3.2

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 (34) hide show
  1. package/mods/agent-things-ui/.claude-plugin/plugin.json +1 -1
  2. package/mods/agent-things-ui/hooks/controls.js +1 -1
  3. package/mods/agent-things-ui/hooks/foundation.js +120 -2
  4. package/mods/agent-things-ui/hooks/presentation.js +9 -6
  5. package/mods/agent-things-ui/hooks/register.js +3 -3
  6. package/outputs/antigravity-session-status.js +276 -99
  7. package/outputs/codex-session-status.js +236 -27
  8. package/package.json +1 -1
  9. package/scripts/build-shared-ui.cjs +13 -1
  10. package/skills/things/SKILL.en.md +3 -1
  11. package/skills/things/SKILL.md +3 -1
  12. package/src/analysis-assets/output.en.schema.json +6 -3
  13. package/src/analysis-assets/output.schema.json +6 -3
  14. package/src/analysis-assets/prompt.en.txt +1 -1
  15. package/src/analysis-assets/prompt.zh-CN.txt +1 -1
  16. package/src/analysis-history.cjs +27 -6
  17. package/src/analysis-service.cjs +1 -1
  18. package/src/antigravity-card.cjs +516 -88
  19. package/src/antigravity-hook.cjs +12 -7
  20. package/src/antigravity-mcp-config.cjs +45 -15
  21. package/src/cli/setup-orchestrator.cjs +6 -4
  22. package/src/harnesses/antigravity/antigravity-harness.js +159 -73
  23. package/src/harnesses/claude/claude-harness.js +583 -2
  24. package/src/harnesses/claude/claude-host-helper.cjs +5 -2
  25. package/src/harnesses/claude/claude-service.cjs +57 -1
  26. package/src/harnesses/claude/claude-source.cjs +18 -5
  27. package/src/harnesses/codex/codex-card-bridge.js +19 -1
  28. package/src/harnesses/codex/codex-card.cjs +1 -1
  29. package/src/plugins/things/sidecars/things_board/index.html +275 -126
  30. package/src/plugins/things/sidecars/things_board/main.mjs +38 -5
  31. package/src/plugins/things/sidecars/things_board/styles.css +22 -6
  32. package/src/plugins/things/sidecars/things_board/ui-i18n.mjs +119 -1
  33. package/src/session-status.js +117 -26
  34. package/src/ui-foundation.cjs +119 -1
@@ -1,7 +1,9 @@
1
1
  'use strict';
2
+ const fs = require('node:fs');
2
3
  const path = require('node:path');
3
4
  const os = require('node:os');
4
5
  const crypto = require('node:crypto');
6
+ const { execFileSync } = require('node:child_process');
5
7
  const { ManualStatusStore } = require('../../manual-status-store.cjs');
6
8
  const { startProgressHttp } = require('../../local-progress-http.cjs');
7
9
  const { callProgressTool } = require('../../progress-tools.cjs');
@@ -18,6 +20,44 @@ const { ClaudeLocalSource } = require('./claude-local-source.cjs');
18
20
  const { sessionView, PROTOCOL_VERSION } = require('../../session-view.cjs');
19
21
  const { errorDetails } = require('../../progress-error.cjs');
20
22
  const { readConfiguredLang, getUi } = require('../../i18n.cjs');
23
+ const { createPresentation } = require('../../ui-foundation.cjs');
24
+
25
+ const claudePresentation = createPresentation('zh');
26
+ let cachedOsThemeMode = null;
27
+ let cachedOsThemeModeTs = 0;
28
+ function detectOsThemeMode() {
29
+ const now = Date.now();
30
+ if (cachedOsThemeMode && now - cachedOsThemeModeTs < 10000) return cachedOsThemeMode;
31
+ try {
32
+ const out = execFileSync('defaults', ['read', '-g', 'AppleInterfaceStyle'], {
33
+ encoding: 'utf8',
34
+ timeout: 300,
35
+ stdio: ['ignore', 'pipe', 'ignore'],
36
+ }).trim();
37
+ cachedOsThemeMode = /^dark$/i.test(out) ? 'dark' : 'light';
38
+ } catch {
39
+ // On macOS, AppleInterfaceStyle is absent when System Appearance is Light.
40
+ cachedOsThemeMode = 'light';
41
+ }
42
+ cachedOsThemeModeTs = now;
43
+ return cachedOsThemeMode;
44
+ }
45
+
46
+ function readClaudeDefaultAccent() {
47
+ let mode = detectOsThemeMode();
48
+ try {
49
+ const cfgPath = path.join(os.homedir(), 'Library', 'Application Support', 'Claude', 'config.json');
50
+ if (fs.existsSync(cfgPath)) {
51
+ const cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf8'));
52
+ const rawMode = cfg?.userThemeMode;
53
+ if (rawMode === 'light' || rawMode === 'dark') mode = rawMode;
54
+ else if (!rawMode && (cfg?.darkMode === 'light' || cfg?.darkMode === 'dark')) mode = cfg.darkMode;
55
+ }
56
+ } catch {}
57
+ const fallbackHex = mode === 'light' ? '#C6613F' : '#D97757';
58
+ const palette = claudePresentation.resolveAccentPalette(fallbackHex, { isDark: mode === 'dark', fallback: fallbackHex });
59
+ return { ...palette, mode, codeTheme: mode === 'light' ? 'claude-light' : 'claude-dark' };
60
+ }
21
61
 
22
62
  const DEFAULT_PORT = 29889;
23
63
  const DEFAULT_STATE_FILE = path.join(os.homedir(), 'Library/Application Support/AgentThings/claude/manual-state.json');
@@ -48,6 +88,7 @@ class ClaudeService {
48
88
  this.keyChanges = new Map(); this.keySignatures = new Map(); this.watchers = new Map(); this.loggedReads = new Map();
49
89
  this.watchStartRevision = 0;
50
90
  this.lastLang = this.currentLang();
91
+ this.currentAccent = null;
51
92
  // 所有写入都经最外层 transaction(write 自身也会进入 transaction):在其结束后比对各会话的变化。
52
93
  const transaction = this.store.transaction.bind(this.store);
53
94
  this.store.transaction = operation => {
@@ -69,6 +110,9 @@ class ClaudeService {
69
110
  if (typeof this.store?.lang === 'function') return this.store.lang();
70
111
  return readConfiguredLang({ dataDir: path.dirname(this.stateFile) });
71
112
  }
113
+ activeAccent() {
114
+ return this.currentAccent || readClaudeDefaultAccent();
115
+ }
72
116
  requestHost(method, threadId, options) {
73
117
  const id = crypto.randomUUID();
74
118
  const en = this.currentLang() === 'en';
@@ -118,6 +162,18 @@ class ClaudeService {
118
162
  try {
119
163
  if (message.type === 'list') { /* Return the current snapshot. */ }
120
164
  else if (message.type === 'panel-event') this.log(`panel.${message.action}`, { key: message.key });
165
+ else if (message.type === 'theme-sync') {
166
+ const mode = message.mode === 'light' ? 'light' : 'dark';
167
+ const palette = claudePresentation.resolveAccentPalette(message.accent, {
168
+ isDark: mode === 'dark',
169
+ fallback: mode === 'light' ? '#C6613F' : '#D97757',
170
+ });
171
+ const nextAccent = { ...palette, mode, codeTheme: typeof message.codeTheme === 'string' ? message.codeTheme : '' };
172
+ if (JSON.stringify(this.currentAccent) !== JSON.stringify(nextAccent)) {
173
+ this.currentAccent = nextAccent;
174
+ for (const k of [...this.watchers.keys()]) this.wakeWatchers(k, { changed: true });
175
+ }
176
+ }
121
177
  else if (message.type === 'open-pane') {
122
178
  if (!this.store.validKey(message.key) || JSON.parse(message.key)[0] !== 'local') throw new Error(en ? 'Invalid Claude session identifier' : '无效 Claude 会话标识');
123
179
  pane = { delivered: await this.deliverPane(message.key, 4000) };
@@ -184,7 +240,7 @@ class ClaudeService {
184
240
  const projection = this.store.readSessionProjection(key);
185
241
  // 只记每个会话读到新修订号的那一次:旧版插件每 2 秒轮询,逐次记录会刷满日志并冲掉验收记录。
186
242
  if (message.action === 'read' && this.loggedReads.get(key) !== projection.revision) { this.loggedReads.set(key, projection.revision); this.log('sync.inline_read', { revision: projection.revision }); }
187
- return { session: sessionView(this.store, key, { capabilities: { locate: true }, projection, lang }), key, title: session.title || t('fallbackShortTitle'), record: projection.record, lang,
243
+ return { session: sessionView(this.store, key, { capabilities: { locate: true }, projection, lang }), key, title: session.title || t('fallbackShortTitle'), record: projection.record, lang, accent: this.activeAccent(),
188
244
  revision: projection.revision, paneRequested: this.takePaneRequest(key), analysis: projection.analysis ? { ledger: { ...projection.analysis.ledger, tasks: projection.activeTasks } } : null, timeline: projection.timelineSummary, source,
189
245
  ...(message.action === 'read' && message.includeGit ? { projectGit: await this.projectGit(key) } : {}) };
190
246
  }
@@ -1,9 +1,21 @@
1
1
  'use strict';
2
2
  const crypto = require('node:crypto');
3
+ const { stripLeadingEnvelopes } = require('../../analysis-history.cjs');
3
4
 
4
- function textContent(content) {
5
- if (typeof content === 'string') return content;
6
- return Array.isArray(content) ? content.filter(part => part.type === 'text').map(part => part.text || '').join('\n') : '';
5
+ function textContent(content, { stripEnvelopes = false } = {}) {
6
+ const cleanPart = text => (stripEnvelopes ? stripLeadingEnvelopes(text) : String(text || ''));
7
+ if (typeof content === 'string') return cleanPart(content);
8
+ return Array.isArray(content)
9
+ ? content.filter(part => part?.type === 'text').map(part => cleanPart(part.text || '')).filter(Boolean).join('\n')
10
+ : '';
11
+ }
12
+
13
+ function cleanCompactSummary(text) {
14
+ let value = String(text || '').trim();
15
+ value = value.replace(/^This session is being continued from a previous conversation[\s\S]*?(?=<system-reminder>|\bSummary:)/i, '');
16
+ value = stripLeadingEnvelopes(value);
17
+ value = value.replace(/\n+(?:If you need specific details from before compaction|Continue the conversation from where it left off|Please continue the conversation|If you are working with the user|The messages after this summary are the most recent messages from before compaction)[\s\S]*$/i, '').trim();
18
+ return value ? `[前情摘要]\n${value}` : '';
7
19
  }
8
20
 
9
21
  function transcriptTurns(result) {
@@ -21,9 +33,10 @@ function appendTranscriptEntry(turns, entry) {
21
33
  function cleanTranscriptMessage(entry) {
22
34
  const message = entry.message || entry;
23
35
  const role = message.role || entry.type;
24
- if (!['user', 'assistant'].includes(role) || entry.isSidechain) return null;
36
+ if (!['user', 'assistant'].includes(role) || entry.isSidechain || entry.isMeta) return null;
25
37
  if (role === 'assistant' && message.stop_reason && message.stop_reason !== 'end_turn') return null;
26
- const original = textContent(message.content);
38
+ let original = textContent(message.content, { stripEnvelopes: true });
39
+ if (role === 'user' && entry.isCompactSummary) original = cleanCompactSummary(original);
27
40
  const text = original.length > 24000 ? `${original.slice(0, 12000)}\n[内容已精简]\n${original.slice(-12000)}` : original;
28
41
  if (!text.trim()) return null;
29
42
  const id = entry.uuid || entry.id;
@@ -108,13 +108,31 @@
108
108
  mount();
109
109
  } else if (data.method === 'ui/notifications/host-context-changed') {
110
110
  theme = data.params?.theme;
111
+ if (theme === 'light' || theme === 'dark') {
112
+ document.documentElement.style.colorScheme = theme;
113
+ document.documentElement.setAttribute('data-theme', theme);
114
+ }
115
+ const hostAccent = data.params?.styles?.variables?.['--color-ring-primary'];
116
+ if (hostAccent) {
117
+ window.__agentThingsHostAccent = hostAccent;
118
+ document.documentElement.style.setProperty('--agent-things-accent', hostAccent);
119
+ }
111
120
  window.__codexSessionStatus?.setTheme(theme);
112
121
  }
113
122
  });
114
123
 
115
- request('ui/initialize', { appInfo: { name: 'agent-things', version: window.__agentThingsVersion || '1.1.1' }, appCapabilities: {}, protocolVersion: '2026-01-26' }, 5000)
124
+ request('ui/initialize', { appInfo: { name: 'agent-things', version: window.__agentThingsVersion || '1.3.2' }, appCapabilities: {}, protocolVersion: '2026-01-26' }, 5000)
116
125
  .then(result => {
117
126
  theme = result?.hostContext?.theme;
127
+ if (theme === 'light' || theme === 'dark') {
128
+ document.documentElement.style.colorScheme = theme;
129
+ document.documentElement.setAttribute('data-theme', theme);
130
+ }
131
+ const hostAccent = result?.hostContext?.styles?.variables?.['--color-ring-primary'];
132
+ if (hostAccent) {
133
+ window.__agentThingsHostAccent = hostAccent;
134
+ document.documentElement.style.setProperty('--agent-things-accent', hostAccent);
135
+ }
118
136
  ready = true;
119
137
  notify('ui/notifications/initialized', {});
120
138
  mount();
@@ -52,7 +52,7 @@ const resource = {
52
52
  const renderer = fs.readFileSync(path.join(__dirname, '../../session-status.js'), 'utf8');
53
53
  const bridge = fs.readFileSync(path.join(__dirname, 'codex-card-bridge.js'), 'utf8');
54
54
  const htmlLang = lang === 'en' ? 'en' : 'zh-CN';
55
- return `<!doctype html><html lang="${htmlLang}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><body style="margin:0"><main id="progress-card" aria-live="polite">${t('loadingTitle')}</main><script>window.__agentThingsVersion = ${JSON.stringify(require('../../../package.json').version)};window.__agentThingsLang = ${JSON.stringify(lang)};\n${browserSource}\n${renderer}\n${bridge}</script></body></html>`;
55
+ return `<!doctype html><html lang="${htmlLang}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>:root{color-scheme:light dark;color:light-dark(#576374,#a0a6ad);background:transparent}body{margin:0;font:13px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}#progress-card:empty{display:none}</style><body style="margin:0"><main id="progress-card" aria-live="polite">${t('loadingTitle')}</main><script>window.__agentThingsVersion = ${JSON.stringify(require('../../../package.json').version)};window.__agentThingsLang = ${JSON.stringify(lang)};\n${browserSource}\n${renderer}\n${bridge}</script></body></html>`;
56
56
  },
57
57
  };
58
58