agent-things 0.0.0-stage → 1.2.1
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/LICENSE +21 -0
- package/NOTICE +5 -0
- package/README.md +221 -2
- package/README.zh-CN.md +222 -0
- package/bin/agent-things.cjs +8 -0
- package/bin/antigravity-session-status.cjs +96 -0
- package/bin/claude-session-status.cjs +55 -0
- package/bin/codex-session-status.cjs +287 -0
- package/mods/agent-things-ui/.claude-plugin/plugin.json +12 -0
- package/mods/agent-things-ui/SKILL.md +10 -0
- package/mods/agent-things-ui/hooks/controls.js +112 -0
- package/mods/agent-things-ui/hooks/foundation.js +431 -0
- package/mods/agent-things-ui/hooks/hooks.json +1 -0
- package/mods/agent-things-ui/hooks/presentation.js +223 -0
- package/mods/agent-things-ui/hooks/progress.js +1 -0
- package/mods/agent-things-ui/hooks/register.js +382 -0
- package/native/bin/bridge +0 -0
- package/native/bin/bridge.json +20 -0
- package/native/session-status-bridge.swift +280 -0
- package/outputs/antigravity-session-status.js +2476 -0
- package/outputs/codex-session-status.js +1761 -0
- package/package.json +75 -4
- package/scripts/build-antigravity-bundle.cjs +35 -0
- package/scripts/build-codex-bundle.cjs +31 -0
- package/scripts/build-native-bridge.cjs +55 -0
- package/scripts/build-shared-ui.cjs +16 -0
- package/scripts/setup-antigravity-service.cjs +71 -0
- package/scripts/setup-claude-service.cjs +21 -0
- package/skills/agent-things/SKILL.en.md +95 -0
- package/skills/agent-things/SKILL.md +99 -0
- package/skills/codex/things/SKILL.en.md +10 -0
- package/skills/codex/things/SKILL.md +10 -0
- package/skills/things/SKILL.en.md +10 -0
- package/skills/things/SKILL.md +10 -0
- package/skills/things/checklist.en.md +91 -0
- package/skills/things/checklist.md +95 -0
- package/src/analysis-app-server.cjs +74 -0
- package/src/analysis-assets/output.en.schema.json +93 -0
- package/src/analysis-assets/output.schema.json +93 -0
- package/src/analysis-assets/prompt.en.txt +17 -0
- package/src/analysis-assets/prompt.zh-CN.txt +18 -0
- package/src/analysis-budget.cjs +105 -0
- package/src/analysis-git.cjs +38 -0
- package/src/analysis-history.cjs +150 -0
- package/src/analysis-ledger.cjs +82 -0
- package/src/analysis-log.cjs +62 -0
- package/src/analysis-runner.cjs +203 -0
- package/src/analysis-service.cjs +197 -0
- package/src/analysis-source.cjs +72 -0
- package/src/antigravity-card.cjs +2063 -0
- package/src/antigravity-hook.cjs +138 -0
- package/src/antigravity-mcp-config.cjs +36 -0
- package/src/app-server.cjs +96 -0
- package/src/cdp.cjs +115 -0
- package/src/claude-inline-install.cjs +38 -0
- package/src/claude-mcp-config.cjs +29 -0
- package/src/cli/arguments.cjs +30 -0
- package/src/cli/environment-probe.cjs +130 -0
- package/src/cli/integration-state.cjs +15 -0
- package/src/cli/interactive-cli.cjs +236 -0
- package/src/cli/prompt-tui.cjs +420 -0
- package/src/cli/setup-orchestrator.cjs +449 -0
- package/src/codex-mcp-config.cjs +67 -0
- package/src/harnesses/antigravity/analysis-profile.cjs +41 -0
- package/src/harnesses/antigravity/antigravity-git.cjs +89 -0
- package/src/harnesses/antigravity/antigravity-harness.js +1477 -0
- package/src/harnesses/antigravity/antigravity-injector.cjs +104 -0
- package/src/harnesses/antigravity/antigravity-migration.cjs +235 -0
- package/src/harnesses/antigravity/antigravity-service.cjs +357 -0
- package/src/harnesses/antigravity/antigravity-title.cjs +155 -0
- package/src/harnesses/antigravity/gemini-runner.cjs +304 -0
- package/src/harnesses/antigravity/transcript-cleaner.cjs +129 -0
- package/src/harnesses/antigravity/transcript-source.cjs +100 -0
- package/src/harnesses/claude/claude-harness.js +93 -0
- package/src/harnesses/claude/claude-host-helper.cjs +176 -0
- package/src/harnesses/claude/claude-injector.cjs +95 -0
- package/src/harnesses/claude/claude-local-source.cjs +106 -0
- package/src/harnesses/claude/claude-navigation.cjs +99 -0
- package/src/harnesses/claude/claude-runner.cjs +74 -0
- package/src/harnesses/claude/claude-service.cjs +313 -0
- package/src/harnesses/claude/claude-source.cjs +70 -0
- package/src/harnesses/codex/codex-analysis.cjs +10 -0
- package/src/harnesses/codex/codex-card-bridge.js +123 -0
- package/src/harnesses/codex/codex-card-events.cjs +76 -0
- package/src/harnesses/codex/codex-card.cjs +169 -0
- package/src/harnesses/codex/codex-git.cjs +24 -0
- package/src/harnesses/codex/codex-harness.js +229 -0
- package/src/harnesses/codex/codex-local-card.js +97 -0
- package/src/harnesses/codex/codex-progress-context.cjs +84 -0
- package/src/harnesses/codex/codex-service.cjs +502 -0
- package/src/i18n.cjs +174 -0
- package/src/launchd.cjs +105 -0
- package/src/lifecycle-lock.cjs +13 -0
- package/src/local-progress-http.cjs +267 -0
- package/src/manual-status-agent.cjs +12 -0
- package/src/manual-status-startup.cjs +66 -0
- package/src/manual-status-store.cjs +466 -0
- package/src/mcp-stdio.cjs +67 -0
- package/src/model-router.cjs +63 -0
- package/src/native-bridge.cjs +17 -0
- package/src/npm-updates.cjs +228 -0
- package/src/plugins/things/assets/logo.svg +13 -0
- package/src/plugins/things/plugin.json +6 -0
- package/src/plugins/things/sidecars/things_board/app.js +447 -0
- package/src/plugins/things/sidecars/things_board/index.html +2141 -0
- package/src/plugins/things/sidecars/things_board/main.mjs +652 -0
- package/src/plugins/things/sidecars/things_board/package.json +6 -0
- package/src/plugins/things/sidecars/things_board/sidecar.json +21 -0
- package/src/plugins/things/sidecars/things_board/styles.css +560 -0
- package/src/plugins/things/sidecars/things_board/ui-i18n.mjs +434 -0
- package/src/progress-error.cjs +54 -0
- package/src/progress-tools.cjs +145 -0
- package/src/project-path.cjs +15 -0
- package/src/renderer-resource.cjs +17 -0
- package/src/request-budget.cjs +24 -0
- package/src/resolve.cjs +51 -0
- package/src/runtime-install.cjs +635 -0
- package/src/session-status-filter.cjs +136 -0
- package/src/session-status.js +992 -0
- package/src/session-view.cjs +34 -0
- package/src/startup/controller.cjs +354 -0
- package/src/startup/watch.cjs +126 -0
- package/src/state-file-lock.cjs +31 -0
- package/src/task-provenance.cjs +42 -0
- package/src/ui-foundation.cjs +435 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { progressState } from './progress.js';
|
|
2
|
+
import { draftTransition, forLang } from './foundation.js';
|
|
3
|
+
import { CONTENT_WIDTH, NOTE_LINE_WIDTH, colors, date, svg, headerRing, headerTitleSpec, statusBadgeSvg, timeTextSvg, scoreSvg, bar, preview, wrapText, measureButtonWidth, measureClearWidth, paneIconWidth } from './presentation.js';
|
|
4
|
+
|
|
5
|
+
let sessionId, cwd, home, data = null, projectGit = null, updateInfo = null, activeLang = 'zh', configLangLoaded = false;
|
|
6
|
+
let mode = 'overview', draft = null, baseRevision = 0, busy = false, error = '', source = null, sourceMode = 'overview';
|
|
7
|
+
let conflict = false, loading = false, refreshPromise = null;
|
|
8
|
+
let expanded = false, noteOpen = false, seen = false, sequence = 0, paneRequested = false, waitLoop = 0;
|
|
9
|
+
const PANE = 'agent-things', PANE_TITLE = 'Agent Things', PINNED = 'pane:pinned';
|
|
10
|
+
const SIDEBAR_HINT_DISMISSED = 'sidebar-hint:dismissed';
|
|
11
|
+
const FIRST_PAINT_WAIT_MS = 80;
|
|
12
|
+
|
|
13
|
+
const ui = () => forLang(activeLang);
|
|
14
|
+
const t = (key, vars) => ui().t(key, vars);
|
|
15
|
+
|
|
16
|
+
async function request($, action, fields = {}) {
|
|
17
|
+
home ||= await $.env.get('HOME');
|
|
18
|
+
const auth = JSON.parse(await $.fs.read(`${home}/Library/Application Support/AgentThings/claude/manual-state.json.http.json`));
|
|
19
|
+
const response = await $.http.fetch(`http://127.0.0.1:${auth.port}/inline`, {
|
|
20
|
+
method: 'POST', headers: { Authorization: `Bearer ${auth.token}`, 'Content-Type': 'application/json' },
|
|
21
|
+
body: JSON.stringify({ action, sessionId, cwd, requestId: `inline-${sessionId}-${++sequence}`, ...fields }),
|
|
22
|
+
});
|
|
23
|
+
const value = JSON.parse(response.text);
|
|
24
|
+
if (value?.lang === 'en' || value?.lang === 'zh') activeLang = value.lang;
|
|
25
|
+
if (!response.ok || value.error) throw Object.assign(new Error(value.error || t('claudeInlineOffline')), value.errorInfo || {});
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
function receive(value) {
|
|
29
|
+
if (value?.lang === 'en' || value?.lang === 'zh') activeLang = value.lang;
|
|
30
|
+
if ('updateInfo' in value) { updateInfo = value.updateInfo; return; }
|
|
31
|
+
if ((!data && 'revision' in value) || (data && value.revision >= data.revision)) data = value;
|
|
32
|
+
if (value.paneRequested) paneRequested = true;
|
|
33
|
+
if (value.projectGit) projectGit = value.projectGit;
|
|
34
|
+
if (value.source) source = value.source;
|
|
35
|
+
}
|
|
36
|
+
async function refresh($, includeGit = false) {
|
|
37
|
+
receive(await request($, 'read', { includeGit }));
|
|
38
|
+
}
|
|
39
|
+
// 在右侧侧栏打开卡片,并记为常驻:之后每个会话启动时自动打开,直到用户在侧栏关闭它。
|
|
40
|
+
async function openPane($) {
|
|
41
|
+
seen = true; paneRequested = false;
|
|
42
|
+
await $.store.set(PINNED, true);
|
|
43
|
+
await $.ui.open({ id: PANE, title: PANE_TITLE });
|
|
44
|
+
}
|
|
45
|
+
async function serveRequestedPane($) {
|
|
46
|
+
if (paneRequested) await openPane($);
|
|
47
|
+
}
|
|
48
|
+
// 同会话多入口同步:向本机后台挂起一个按会话的等待请求。本会话账本变化(任一入口保存、清除、
|
|
49
|
+
// 分析开始/进度/成功/失败)或侧栏弹窗请求「在侧栏打开」时立即返回;断开后恢复时补读一次。
|
|
50
|
+
// 草稿与基准修订号不受刷新影响;receive 只接受不旧于当前的数据,乱序回复不会把界面退回旧版本。
|
|
51
|
+
async function watchChanges($) {
|
|
52
|
+
const token = ++waitLoop;
|
|
53
|
+
if (refreshPromise) await refreshPromise.catch(() => {});
|
|
54
|
+
let offline = !data;
|
|
55
|
+
while (token === waitLoop) {
|
|
56
|
+
try {
|
|
57
|
+
if (offline) { await refresh($); offline = false; error = ''; $.ui.invalidate('ui.render'); await serveRequestedPane($); }
|
|
58
|
+
const value = await request($, 'watch', { since: data?.revision, waitMs: 20000 });
|
|
59
|
+
if (token !== waitLoop) return;
|
|
60
|
+
if (value.changed) { await refresh($); $.ui.invalidate('ui.render'); await serveRequestedPane($); }
|
|
61
|
+
if (value.paneRequested) await openPane($);
|
|
62
|
+
} catch (failure) {
|
|
63
|
+
if (token !== waitLoop) return;
|
|
64
|
+
offline = true;
|
|
65
|
+
// 旧版后台没有 watch:退回每 2 秒补读。
|
|
66
|
+
await $.clock.sleep(/(未知卡片操作|Unknown card action)/i.test(failure.message) ? 2000 : 1000);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function remember($) {
|
|
71
|
+
await $.store.set(`view:${sessionId}`, { mode, draft, baseRevision, expanded, conflict });
|
|
72
|
+
}
|
|
73
|
+
async function view($, next) {
|
|
74
|
+
mode = next; error = '';
|
|
75
|
+
await remember($); $.ui.invalidate('ui.render');
|
|
76
|
+
}
|
|
77
|
+
async function edit($) {
|
|
78
|
+
if (!draft) {
|
|
79
|
+
const record = data?.record;
|
|
80
|
+
const state = draftTransition({}, { type: 'begin', record });
|
|
81
|
+
draft = state.draft; baseRevision = state.baseRevision;
|
|
82
|
+
}
|
|
83
|
+
if (!projectGit) {
|
|
84
|
+
void refresh($, true).then(() => $.ui.invalidate('ui.render')).catch(() => {});
|
|
85
|
+
}
|
|
86
|
+
await view($, 'edit');
|
|
87
|
+
}
|
|
88
|
+
async function setDraft($, patch) {
|
|
89
|
+
draft = draftTransition({ draft, baseRevision }, { type: 'patch', patch }).draft;
|
|
90
|
+
$.ui.invalidate('ui.render');
|
|
91
|
+
await remember($);
|
|
92
|
+
}
|
|
93
|
+
async function setProgress($, value) {
|
|
94
|
+
if (value !== null && (!Number.isInteger(value) || value < 0 || value > 100)) {
|
|
95
|
+
error = t('invalidProgressError'); $.ui.invalidate('ui.render'); return;
|
|
96
|
+
}
|
|
97
|
+
await setDraft($, { progress: value, state: progressState(draft.state, value) });
|
|
98
|
+
}
|
|
99
|
+
async function operate($, action, fields = {}) {
|
|
100
|
+
if (busy) return;
|
|
101
|
+
busy = true; error = ''; $.ui.invalidate('ui.render');
|
|
102
|
+
try {
|
|
103
|
+
receive(await request($, action, fields));
|
|
104
|
+
if (action === 'save' || action === 'clear') { const state = draftTransition({ draft, baseRevision }, { type: action === 'clear' ? 'cleared' : 'saved', revision: data?.record?.revision || 0 }); draft = state.draft; baseRevision = state.baseRevision; conflict = false; mode = 'overview'; await remember($); }
|
|
105
|
+
if (action === 'source') {
|
|
106
|
+
let located;
|
|
107
|
+
try { located = await request($, 'locate', { taskId: fields.taskId }); }
|
|
108
|
+
catch (failure) { sourceMode = mode; mode = 'source'; throw failure; }
|
|
109
|
+
if (!located.navigation?.located) {
|
|
110
|
+
sourceMode = mode; mode = 'source'; error = located.navigation?.message || t('locateUnavailable');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} catch (failure) {
|
|
114
|
+
error = failure.message;
|
|
115
|
+
if (failure.code === 'REVISION_CONFLICT' && draft) { conflict = true; await remember($); }
|
|
116
|
+
}
|
|
117
|
+
finally { busy = false; $.ui.invalidate('ui.render'); }
|
|
118
|
+
}
|
|
119
|
+
async function rebaseDraft($) {
|
|
120
|
+
if (busy || !draft) return;
|
|
121
|
+
busy = true;
|
|
122
|
+
try {
|
|
123
|
+
await refresh($);
|
|
124
|
+
const state = draftTransition({ draft, baseRevision, conflict }, { type: 'rebase', revision: data?.session?.recordRevision ?? data?.record?.revision ?? 0 });
|
|
125
|
+
baseRevision = state.baseRevision; conflict = false;
|
|
126
|
+
error = t('conflictReloadedFeedback');
|
|
127
|
+
await remember($);
|
|
128
|
+
} catch (failure) { error = failure.message; }
|
|
129
|
+
finally { busy = false; $.ui.invalidate('ui.render'); }
|
|
130
|
+
}
|
|
131
|
+
async function ensureContext($) {
|
|
132
|
+
if (!configLangLoaded) {
|
|
133
|
+
configLangLoaded = true;
|
|
134
|
+
try {
|
|
135
|
+
home ||= await $.env.get('HOME');
|
|
136
|
+
const cfg = JSON.parse(await $.fs.read(`${home}/Library/Application Support/AgentThings/config.json`));
|
|
137
|
+
if (cfg?.lang === 'en' || cfg?.lang === 'zh') activeLang = cfg.lang;
|
|
138
|
+
} catch {}
|
|
139
|
+
}
|
|
140
|
+
if (sessionId) return;
|
|
141
|
+
sessionId = await $.session.id(); cwd = await $.session.cwd();
|
|
142
|
+
const saved = await $.store.get(`view:${sessionId}`);
|
|
143
|
+
if (saved) {
|
|
144
|
+
mode = ['overview', 'edit', 'completed'].includes(saved.mode) ? saved.mode : 'overview';
|
|
145
|
+
draft = saved.draft || null; baseRevision = saved.baseRevision || 0;
|
|
146
|
+
expanded = Boolean(saved.expanded); conflict = Boolean(saved.conflict && draft);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function startRefresh($, includeGit = false) {
|
|
150
|
+
if (refreshPromise) return refreshPromise;
|
|
151
|
+
if (!data) error = '';
|
|
152
|
+
refreshPromise = (async () => {
|
|
153
|
+
try {
|
|
154
|
+
await refresh($, includeGit);
|
|
155
|
+
error = '';
|
|
156
|
+
await serveRequestedPane($);
|
|
157
|
+
} catch (failure) {
|
|
158
|
+
if (!data) error = failure.message;
|
|
159
|
+
} finally {
|
|
160
|
+
loading = false;
|
|
161
|
+
refreshPromise = null;
|
|
162
|
+
$.ui.invalidate('ui.render');
|
|
163
|
+
}
|
|
164
|
+
})();
|
|
165
|
+
return refreshPromise;
|
|
166
|
+
}
|
|
167
|
+
async function raceWithin($, promise, timeoutMs) {
|
|
168
|
+
await Promise.race([promise, $.clock.sleep(timeoutMs)]);
|
|
169
|
+
}
|
|
170
|
+
async function initialize($) {
|
|
171
|
+
await ensureContext($);
|
|
172
|
+
void startRefresh($);
|
|
173
|
+
$.clock.after(0, async () => {
|
|
174
|
+
try { receive(await request($, 'update-info')); } catch { /* Upgrade discovery is retried by its explicit button. */ }
|
|
175
|
+
$.ui.invalidate('ui.render');
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function register(on) {
|
|
180
|
+
on('session.start', async ($, e, next) => {
|
|
181
|
+
await initialize($);
|
|
182
|
+
await $.command.register({ name: 'things', description: t('cardCommandDescription'), immediate: true });
|
|
183
|
+
if (paneRequested || await $.store.get(PINNED)) { seen = true; paneRequested = false; void $.ui.open({ id: PANE, title: PANE_TITLE }); }
|
|
184
|
+
void watchChanges($);
|
|
185
|
+
// 账本同步由 watchChanges 负责;这里只跟进升级进度。
|
|
186
|
+
$.clock.every(2000, async () => {
|
|
187
|
+
const updating = ['queued', 'checking', 'downloading', 'waiting', 'installing'].includes(updateInfo?.update?.stage);
|
|
188
|
+
if (!seen || busy || !updating) return;
|
|
189
|
+
try { receive(await request($, 'update-info')); } catch (failure) { error = failure.message; }
|
|
190
|
+
$.ui.invalidate('ui.render');
|
|
191
|
+
});
|
|
192
|
+
return next(e);
|
|
193
|
+
});
|
|
194
|
+
on('command.run', { command: 'things' }, async ($) => {
|
|
195
|
+
await ensureContext($);
|
|
196
|
+
seen = true;
|
|
197
|
+
const pending = startRefresh($);
|
|
198
|
+
if (!data) {
|
|
199
|
+
loading = true;
|
|
200
|
+
await raceWithin($, pending, FIRST_PAINT_WAIT_MS);
|
|
201
|
+
}
|
|
202
|
+
return { text: t('cardCommandReply') };
|
|
203
|
+
});
|
|
204
|
+
on('ui.close', async ($, e, next) => {
|
|
205
|
+
if (e.id === PANE && e.origin.kind === 'person') await $.store.set(PINNED, false).catch(() => {});
|
|
206
|
+
return next(e);
|
|
207
|
+
});
|
|
208
|
+
on('ui.message', async ($, e, next) => {
|
|
209
|
+
if (e.component !== 'CommandOutput' && !(e.component === 'Pane' && e.requestId === PANE)) return next(e);
|
|
210
|
+
if (e.element === 'progress-slider' && mode === 'edit' && e.data && 'value' in e.data && (e.data.value === null || Number.isInteger(e.data.value))) {
|
|
211
|
+
await setProgress($, e.data.value);
|
|
212
|
+
return {};
|
|
213
|
+
}
|
|
214
|
+
if (e.element === 'analyze' && e.data?.action === 'analyze') {
|
|
215
|
+
if (!data?.timeline?.some(event => event.status === 'pending')) await operate($, 'analyze');
|
|
216
|
+
return {};
|
|
217
|
+
}
|
|
218
|
+
if (e.element === 'open-pane' && e.data?.action === 'open-pane') { await openPane($); return {}; }
|
|
219
|
+
if (e.element === 'clear' && e.data?.action === 'clear') { await operate($, 'clear', { expectedRevision: data?.record?.revision || 0 }); return {}; }
|
|
220
|
+
if (e.element === 'save' && e.data?.action === 'save' && mode === 'edit') {
|
|
221
|
+
await operate($, 'save', { expectedRevision: baseRevision, record: draft }); return {};
|
|
222
|
+
}
|
|
223
|
+
return next(e);
|
|
224
|
+
});
|
|
225
|
+
on('ui.render', { component: 'CommandOutput' }, async ($, e, next) => {
|
|
226
|
+
if (e.props.command !== 'things' && e.props.command !== '/things') return next(e);
|
|
227
|
+
return draw($, e, false);
|
|
228
|
+
});
|
|
229
|
+
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => draw($, e, true));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
async function draw($, e, inPane) {
|
|
233
|
+
seen = true;
|
|
234
|
+
const { labels, taskLabels, strings } = ui();
|
|
235
|
+
const { Box, Text, Button, Input, Svg, Client } = $.ui.resolve(e);
|
|
236
|
+
const record = data?.record?.state ? data.record : null;
|
|
237
|
+
const tasks = data?.analysis?.ledger?.tasks || [];
|
|
238
|
+
const remaining = tasks.filter(task => task.status !== 'done'), completed = tasks.filter(task => task.status === 'done');
|
|
239
|
+
const active = data?.timeline?.findLast(event => event.status === 'pending');
|
|
240
|
+
const color = colors[(mode === 'edit' ? draft?.state : record?.state)] || colors.unstarted;
|
|
241
|
+
const rawCols = Number(e?.props?.bodyColumns ?? e?.viewport?.columns);
|
|
242
|
+
const paneCols = Number.isFinite(rawCols) && rawCols > 0 ? Math.max(12, rawCols - 2.2) : 32;
|
|
243
|
+
const viewWidth = inPane ? Math.max(130, Math.round(paneCols * 9.3)) : CONTENT_WIDTH;
|
|
244
|
+
const text = (value, props = {}) => Text({ children: [String(value)], ...props });
|
|
245
|
+
const button = (key, label, callback, props = {}) => Button({ key, label, onPress: callback, ...props });
|
|
246
|
+
const row = children => Box({ flexDirection: 'row', alignItems: 'center', width: '100%', gap: 1, children });
|
|
247
|
+
const rule = () => Svg({ source: svg(`<path d="M0 1H${viewWidth}" stroke="currentColor" opacity=".14"/>`, viewWidth, 2), alt: t('dividerAlt'), width: 4096, height: 2 });
|
|
248
|
+
const trailing = child => Box({ flexGrow: 1, justifyContent: 'flex-end', alignItems: 'center', children: [child] });
|
|
249
|
+
const colWidthFor = (px, minCols = 8.6) => Math.max(minCols, Math.ceil((px / 9.3) * 10) / 10);
|
|
250
|
+
const control = (key, props, width = 8.6) => Box({ width, children: [
|
|
251
|
+
Client({ key, module: './controls.js', width: '100%', height: props.action === 'clear' ? 1.4 : 1.8, props }),
|
|
252
|
+
] });
|
|
253
|
+
const statusBlockWidth = Math.max(56, viewWidth - 96 - 12);
|
|
254
|
+
const statusRow = ({ dotColor, dotOpacity = 1, label, timeLabel = '', labelOpacity = 1, score, scoreAlt, scoreOpacity = 1 }) => row([
|
|
255
|
+
Box({ flexDirection: 'column', flexGrow: 1, flexShrink: 1, minWidth: 0, gap: 0, children: [
|
|
256
|
+
Svg({ source: statusBadgeSvg(dotColor, label, statusBlockWidth, dotOpacity, labelOpacity), alt: label, width: statusBlockWidth, height: 18 }),
|
|
257
|
+
...(timeLabel ? [Svg({ source: timeTextSvg(timeLabel, statusBlockWidth), alt: timeLabel, width: statusBlockWidth, height: 18 })] : []),
|
|
258
|
+
] }),
|
|
259
|
+
Box({ flexShrink: 0, alignItems: 'flex-end', children: [
|
|
260
|
+
Svg({ source: scoreSvg(score, scoreOpacity), alt: scoreAlt, width: 96, height: 48 }),
|
|
261
|
+
] }),
|
|
262
|
+
]);
|
|
263
|
+
const taskLabelWidth = Math.max(60, Math.min(200, viewWidth - 28));
|
|
264
|
+
const unknownTaskLabel = taskLabels.unknown || t('taskLabels')?.unknown || (activeLang === 'en' ? 'Unknown status' : '状态未知');
|
|
265
|
+
const taskRow = task => Box({ key: `task-${task.id}`, position: 'relative', flexDirection: 'row', alignItems: 'center', width: '100%', gap: 1, children: [
|
|
266
|
+
text(task.status === 'done' ? '✓' : '○', { color: task.status === 'done' ? colors.completed : colors.unfinished }),
|
|
267
|
+
Box({ flexDirection: 'column', flexGrow: 1, minWidth: 0, children: [text(task.summary || task.title), Svg({ source: svg(`<text x="0" y="11" font-size="10" fill="currentColor" opacity=".68">${taskLabels[task.status] || unknownTaskLabel}</text>`, taskLabelWidth, 15, 'xMinYMid meet'), alt: taskLabels[task.status] || unknownTaskLabel, width: taskLabelWidth, height: 15 })] }),
|
|
268
|
+
Box({ position: 'absolute', right: 0, top: 0, height: '100%', justifyContent: 'center', alignItems: 'flex-end', display: 'none', hover: { display: 'flex' }, children: [button(`source-${task.id}`, t('viewSource'), () => operate($, 'source', { taskId: task.id }), { plain: true })] }),
|
|
269
|
+
] });
|
|
270
|
+
const content = [];
|
|
271
|
+
const skeletonLoading = !data && (loading || Boolean(refreshPromise));
|
|
272
|
+
const titleReserve = inPane ? 0 : 34;
|
|
273
|
+
const titleMaxWidth = Math.max(64, viewWidth - 42 - titleReserve);
|
|
274
|
+
const titleText = data?.title || t('fallbackShortTitle');
|
|
275
|
+
const titleSpec = headerTitleSpec(titleText, titleMaxWidth);
|
|
276
|
+
content.push(Box({ flexDirection: 'row', alignItems: 'flex-start', width: '100%', gap: 1, children: [
|
|
277
|
+
Box({ flexShrink: 0, children: [Svg({ source: headerRing(record, Boolean(active || skeletonLoading)), alt: `${record?.progress ?? t('progressUnrecordedWord')}%`, width: 32, height: 34, isInteractive: true })] }),
|
|
278
|
+
Box({ flexGrow: 1, flexShrink: 1, minWidth: 0, children: [Svg({ source: titleSpec.source, alt: titleText, width: titleSpec.width, height: titleSpec.height })] }),
|
|
279
|
+
] }));
|
|
280
|
+
if (!data && mode === 'overview') {
|
|
281
|
+
if (skeletonLoading) {
|
|
282
|
+
content.push(statusRow({ dotColor: 'currentColor', dotOpacity: '.35', label: t('loadingTitle'), labelOpacity: '.82', score: null, scoreAlt: t('loadingAlt'), scoreOpacity: '.35' }));
|
|
283
|
+
content.push(Svg({ source: bar(0, colors.unstarted, viewWidth), alt: t('loadingAlt'), width: 4096, height: 4 }));
|
|
284
|
+
const barW1 = Math.max(40, Math.round(viewWidth * 0.53));
|
|
285
|
+
const barW2 = Math.max(40, Math.round(viewWidth * 0.77));
|
|
286
|
+
const barW3 = Math.max(40, Math.round(viewWidth * 0.65));
|
|
287
|
+
content.push(Svg({ source: svg(`<rect x="0" y="2" width="${barW1}" height="10" rx="5" fill="currentColor" opacity=".12"/><rect x="0" y="20" width="${barW2}" height="10" rx="5" fill="currentColor" opacity=".08"/><rect x="0" y="38" width="${barW3}" height="10" rx="5" fill="currentColor" opacity=".08"/>`, viewWidth, 52, 'xMinYMid meet'), alt: t('loadingTasksAlt'), width: viewWidth, height: 52 }));
|
|
288
|
+
content.push(text(t('loadingSubtitle'), { size: 'footnote', dimColor: true }));
|
|
289
|
+
} else {
|
|
290
|
+
content.push(statusRow({ dotColor: 'currentColor', dotOpacity: '.45', label: t('notLoadedTitle'), score: null, scoreAlt: t('notLoadedAlt'), scoreOpacity: '.45' }));
|
|
291
|
+
content.push(Svg({ source: bar(0, colors.unstarted, viewWidth), alt: t('notLoadedAlt'), width: 4096, height: 4 }));
|
|
292
|
+
content.push(row([button('retry-load', t('retryLoadBtn'), () => { loading = true; error = ''; $.ui.invalidate('ui.render'); void startRefresh($); })]));
|
|
293
|
+
}
|
|
294
|
+
} else if (mode === 'source' && source) {
|
|
295
|
+
content.push(button('source-back', t('backPlain'), () => view($, sourceMode), { plain: true }));
|
|
296
|
+
content.push(text(source.title, { bold: true }), text(date(source.occurredAt), { dimColor: true }));
|
|
297
|
+
content.push(text(source.text || source.locator || t('emptySourceText')));
|
|
298
|
+
} else if (mode === 'completed') {
|
|
299
|
+
content.push(row([text(t('completedHeading'), { bold: true }), trailing(button('completed-back', t('backLabel'), () => view($, 'overview'), { plain: true, dimColor: true }))]));
|
|
300
|
+
content.push(...completed.map(taskRow));
|
|
301
|
+
if (!completed.length) content.push(text(t('emptyCompleted'), { dimColor: true }));
|
|
302
|
+
} else if (mode === 'edit' && draft) {
|
|
303
|
+
content.push(Box({ paddingTop: 1.5, paddingBottom: 1, children: [text(t('editHeading'), { bold: true })] }));
|
|
304
|
+
for (const [state, label] of Object.entries(labels)) {
|
|
305
|
+
if (state === 'pushed' && !projectGit?.hasRemote) continue;
|
|
306
|
+
content.push(Box({ flexDirection: 'row', width: '100%', alignItems: 'center', gap: 1, paddingX: 1, paddingY: .75,
|
|
307
|
+
borderStyle: 'round', borderColor: '#00000000', backgroundColor: draft.state === state ? '#8899aa24' : undefined,
|
|
308
|
+
children: [Box({ flexShrink: 0, children: [Svg({ source: svg(`<circle cx="6" cy="7" r="5" fill="none" stroke="${colors[state]}" stroke-width="1.5"/>${draft.state === state ? `<circle cx="6" cy="7" r="2.5" fill="${colors[state]}"/>` : ''}`, 12, 14, 'xMidYMid meet'), alt: label, width: 12, height: 14 })] }),
|
|
309
|
+
button(`state-${state}`, label, () => setDraft($, {
|
|
310
|
+
state, progress: state === 'unstarted' ? 0 : state === 'completed' || state === 'pushed' ? 100 : draft.state === 'unfinished' ? draft.progress : null,
|
|
311
|
+
}), { plain: true })] }));
|
|
312
|
+
}
|
|
313
|
+
content.push(Box({ paddingTop: 2, children: [Client({ key: 'progress-slider', module: './controls.js', width: '100%', height: 5.5,
|
|
314
|
+
props: { kind: 'slider', value: draft.progress, state: draft.state, width: viewWidth, progressLabel: t('progressLabel'), unrecordedWord: t('progressUnrecordedWord') } })] }));
|
|
315
|
+
content.push(row([trailing(button('clear-percentage', t('clearValueBtn'), () => setProgress($, null), { plain: true, dimColor: true }))]));
|
|
316
|
+
content.push(text(t('notesLabel'), { size: 'footnote', dimColor: true }));
|
|
317
|
+
content.push(Input({ key: 'note-input', value: draft.note, rows: 3, placeholder: t('notePlaceholder'),
|
|
318
|
+
onInput: value => setDraft($, { note: value }), onSubmit: value => setDraft($, { note: value }) }));
|
|
319
|
+
const saveLabel = busy ? t('savingBtn') : t('saveBtn');
|
|
320
|
+
const saveWidthCols = colWidthFor(measureButtonWidth(saveLabel), 8.6);
|
|
321
|
+
content.push(row([trailing(button('cancel', t('cancelBtn'), async () => { draft = null; await view($, 'overview'); }, { plain: true })),
|
|
322
|
+
control('save', { kind: 'button', action: 'save', disabled: busy, label: saveLabel }, saveWidthCols)]));
|
|
323
|
+
if (conflict) content.push(button('resolve-conflict', t('resolveConflictBtn'), () => rebaseDraft($), { plain: true }));
|
|
324
|
+
} else {
|
|
325
|
+
content.push(statusRow({ dotColor: color, label: labels[record?.state] || t('unrecordedSummary'), timeLabel: date(record?.updatedAt), score: record?.progress, scoreAlt: `${record?.progress ?? t('progressUnrecordedWord')}%` }));
|
|
326
|
+
content.push(Svg({ source: bar(record?.progress, color, viewWidth), alt: t('currentProgressAlt'), width: 4096, height: 4 }));
|
|
327
|
+
content.push(row([text(tasks.length ? t('totalsPattern', { done: completed.length, total: tasks.length }) : t('noTasksYet'), { size: 'footnote', dimColor: true }), trailing(text(record?.source === 'analysis' ? t('sourceAuto') : record ? t('sourceManual') : '', { size: 'footnote', dimColor: true }))]));
|
|
328
|
+
const noteMaxWidth = inPane ? Math.max(100, viewWidth - 16) : NOTE_LINE_WIDTH;
|
|
329
|
+
const wrappedNote = record?.note ? wrapText(record.note, noteMaxWidth) : '';
|
|
330
|
+
const previewNote = record?.note ? preview(record.note, noteMaxWidth) : '';
|
|
331
|
+
if (record?.note) content.push(Box({ width: '100%', flexDirection: 'column', children: [text(noteOpen ? wrappedNote : previewNote, { dimColor: true })] }));
|
|
332
|
+
if (record?.note && previewNote !== wrappedNote) content.push(button('expand-note', noteOpen ? t('collapse') : t('expandAll'), () => { noteOpen = !noteOpen; $.ui.invalidate('ui.render'); }, { plain: true, dimColor: true }));
|
|
333
|
+
const analyzeLabel = active ? t('btnUpdating') : t('btnUpdate');
|
|
334
|
+
const analyzeWidthCols = colWidthFor(measureButtonWidth(analyzeLabel), 8.6);
|
|
335
|
+
const clearLabel = t('btnClear');
|
|
336
|
+
const clearWidthCols = colWidthFor(measureClearWidth(clearLabel), 6.9);
|
|
337
|
+
content.push(row([
|
|
338
|
+
control('analyze', { kind: 'button', action: 'analyze', disabled: Boolean(active) || busy, label: analyzeLabel }, analyzeWidthCols),
|
|
339
|
+
button('edit', t('btnAdjust'), () => edit($), { plain: true, dimColor: true }),
|
|
340
|
+
trailing(control('clear', { kind: 'button', action: 'clear', disabled: busy, label: clearLabel }, clearWidthCols)),
|
|
341
|
+
]));
|
|
342
|
+
if (active) content.push(text(strings.analysisStages?.[active.stage] || strings.analysisStages?.analyzing || t('btnUpdating'), { dimColor: true }));
|
|
343
|
+
const failed = data?.timeline?.at(-1);
|
|
344
|
+
if (!active && failed?.status === 'failed') content.push(text(`${t('analysisFailedPrefix')}${failed.error || t('analysisFailedRetry')}`, { color: '#D43F3F' }));
|
|
345
|
+
content.push(rule());
|
|
346
|
+
const remainingHead = [text(t('remainingHeadingPattern', { count: remaining.length }), { bold: true })];
|
|
347
|
+
if (remaining.length > 3) remainingHead.push(trailing(button('expand-remaining', expanded ? t('collapseArrow') : t('showAllCountPattern', { count: remaining.length }), async () => { expanded = !expanded; await remember($); $.ui.invalidate('ui.render'); }, { plain: true, dimColor: true })));
|
|
348
|
+
content.push(row(remainingHead));
|
|
349
|
+
content.push(...(expanded ? remaining : remaining.slice(0, 3)).map(taskRow));
|
|
350
|
+
if (!remaining.length) content.push(text(tasks.length ? t('emptyNoRemaining') : t('emptyNoTasks'), { dimColor: true }));
|
|
351
|
+
content.push(rule());
|
|
352
|
+
content.push(row([button('completed-label', t('completedHeading'), () => view($, 'completed'), { plain: true }), trailing(button('completed', t('countArrowPattern', { count: completed.length }), () => view($, 'completed'), { plain: true, dimColor: true }))]));
|
|
353
|
+
content.push(rule());
|
|
354
|
+
content.push(row([button('note-label', t('notesLabel'), () => edit($), { plain: true }), trailing(button('edit-note', record?.note ? t('editLabel') : t('addLabel'), () => edit($), { plain: true, dimColor: true }))]));
|
|
355
|
+
const updating = ['queued', 'checking', 'downloading', 'waiting', 'installing'].includes(updateInfo?.update?.stage);
|
|
356
|
+
if (updating) content.push(text(t('upgradingShort'), { dimColor: true }));
|
|
357
|
+
else if (updateInfo?.available) content.push(row([text(t('updateAvailablePattern', { version: updateInfo.latestVersion || '' })), trailing(button('upgrade', t('upgradeBtn'), () => operate($, 'upgrade')))]));
|
|
358
|
+
if (updateInfo?.update?.stage === 'failed') content.push(text(`${t('updateFailedLabel')}: ${updateInfo.update.error || updateInfo.command}`, { color: '#D43F3F' }));
|
|
359
|
+
}
|
|
360
|
+
if (error) content.push(Box({ width: '100%', flexDirection: 'column', children: [text(wrapText(error, inPane ? Math.max(100, viewWidth - 16) : NOTE_LINE_WIDTH), { color: '#D43F3F' })] }));
|
|
361
|
+
if (mode === 'edit' && (conflict || error.includes('其他窗口') || error.includes('another window'))) content.push(button('reload-version', t('resolveConflictBtn'), async () => {
|
|
362
|
+
try { await refresh($); baseRevision = data.record?.revision || 0; error = ''; await remember($); }
|
|
363
|
+
catch (failure) { error = failure.message; }
|
|
364
|
+
$.ui.invalidate('ui.render');
|
|
365
|
+
}));
|
|
366
|
+
if (busy) content.push(text(t('processing'), { dimColor: true }));
|
|
367
|
+
if (mode === 'overview' && !await $.store.get(SIDEBAR_HINT_DISMISSED)) {
|
|
368
|
+
content.push(rule(), text(t('sidebarHintText'), { size: 'footnote', dimColor: true }));
|
|
369
|
+
content.push(row([trailing(button('dismiss-sidebar-hint', t('dismissHint'), async () => {
|
|
370
|
+
await $.store.set(SIDEBAR_HINT_DISMISSED, true);
|
|
371
|
+
$.ui.invalidate('ui.render');
|
|
372
|
+
}, { plain: true, dimColor: true }))]));
|
|
373
|
+
}
|
|
374
|
+
if (inPane) return Box({ key: 'things-pane', flexDirection: 'column', gap: 1, paddingX: 1, paddingTop: 1, paddingBottom: 1.75, width: '100%', children: content });
|
|
375
|
+
// 右上角「在侧栏打开」图标,与侧栏弹窗关闭按钮左侧的图标一致。
|
|
376
|
+
const openPaneLabel = t('openInSidebar');
|
|
377
|
+
const openPaneWidthCols = colWidthFor(paneIconWidth(openPaneLabel), 11.2);
|
|
378
|
+
content.push(Box({ position: 'absolute', top: 0, right: 1, paddingTop: 0.5, width: openPaneWidthCols, height: 1.9, children: [
|
|
379
|
+
Client({ key: 'open-pane', module: './controls.js', width: '100%', height: 1.4, props: { kind: 'icon', action: 'open-pane', label: openPaneLabel } }),
|
|
380
|
+
] }));
|
|
381
|
+
return Box({ key: 'things-card', position: 'relative', flexDirection: 'column', gap: 1, paddingX: 2.5, paddingTop: 2.75, paddingBottom: 1.75, width: 36.5, borderStyle: 'round', borderDimColor: true, children: content });
|
|
382
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"protocol": 1,
|
|
3
|
+
"architectures": [
|
|
4
|
+
"arm64",
|
|
5
|
+
"x86_64"
|
|
6
|
+
],
|
|
7
|
+
"minimumMacOS": "11.0",
|
|
8
|
+
"sourceSha256": "d917d82343dec8925643416976632333808e50333c997838d94dc67b70600285",
|
|
9
|
+
"sha256": "4e0873b56859da86f47f0b80f55eb7ab9ac91f5be18704ee88c0d90ec3f1d734",
|
|
10
|
+
"capabilities": [
|
|
11
|
+
"snapshot",
|
|
12
|
+
"watch",
|
|
13
|
+
"quit",
|
|
14
|
+
"launch",
|
|
15
|
+
"show",
|
|
16
|
+
"wallpaper",
|
|
17
|
+
"claim-lock",
|
|
18
|
+
"window-ready"
|
|
19
|
+
]
|
|
20
|
+
}
|