attention-secretary 0.1.0 → 0.1.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.
- package/README.md +77 -82
- package/bin/attention.js +68 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,38 +1,26 @@
|
|
|
1
|
-
# Attention
|
|
1
|
+
# Attention
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**A personal secretary for your Mac. It keeps track of everything on your plate and puts what matters in front of you.**
|
|
4
4
|
|
|
5
|
-
[
|
|
5
|
+
English | [中文](https://github.com/markd88/attention-secretary/blob/main/README.zh-CN.md)
|
|
6
6
|
|
|
7
|
-
>
|
|
7
|
+
> Early version (0.1). The author uses it every day and it is still being polished. Problems and ideas are welcome as [Issues](https://github.com/markd88/attention-secretary/issues).
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## What it is
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
- **需要你拍板**:只有需要你决定的事、等你看的结果才会出现在这里。
|
|
13
|
-
- **秘书**:一个常驻的终端,直接打字就是跟它说话;它派出去的执行者各占一个标签,你随时可以点进去接手。
|
|
14
|
-
- **全部事项**:按工作分组,每件事的进度、下一步、项目目录都在详情里。
|
|
15
|
-
- **桌宠**:一只小猫(布偶猫或金渐层)待在桌面上,秘书在忙、有事等你拍板、你完成一件事时,它的动作会跟着变。单击摸摸它,双击打开工作窗口。
|
|
11
|
+
Attention is a macOS app that uses your own [Claude Code](https://docs.claude.com/en/docs/claude-code) or [Codex](https://github.com/openai/codex) as a secretary. It remembers everything you hand it, picks the few things that matter most each day, keeps track of how each piece of work is going, and brings you what needs your decision. The actual work goes to sessions it starts for you, or that you take over yourself.
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
- **Today**: the 3–5 things that matter most today, one line each.
|
|
14
|
+
- **Needs you**: only decisions that are yours to make, and results waiting for you.
|
|
15
|
+
- **Secretary**: a resident terminal. Type in it to talk to the secretary; each session it starts gets its own tab you can step into.
|
|
16
|
+
- **All items**: everything, grouped by area of work, with progress and the next step.
|
|
17
|
+
- **Desktop pet**: a cat that reacts when the secretary is busy, when something needs you, and when you finish something.
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Install
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
- **Claude Code 或 Codex 已经装好并且登录了**:在终端里运行 `claude`(或 `codex`)能正常对话就行。Attention 用的就是你终端里的那个,你的登录方式、网关、API Key 都原样沿用。第一次打开时选用哪一个,之后可以在设置里换。
|
|
23
|
-
- 用 npm 安装需要 Node.js 18 或更新。
|
|
21
|
+
You need macOS 13 or later, and Claude Code or Codex installed and signed in (running `claude` or `codex` in Terminal works). Attention uses that same one, with your sign-in and settings as they are.
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
curl -fsSL https://claude.ai/install.sh | bash
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
装好后在终端运行一次 `claude` 完成登录。
|
|
32
|
-
|
|
33
|
-
## 安装
|
|
34
|
-
|
|
35
|
-
### 用 npm(推荐)
|
|
23
|
+
With npm (Node.js 18 or later):
|
|
36
24
|
|
|
37
25
|
```bash
|
|
38
26
|
npm install -g attention-secretary
|
|
@@ -42,82 +30,89 @@ npm install -g attention-secretary
|
|
|
42
30
|
attention install
|
|
43
31
|
```
|
|
44
32
|
|
|
45
|
-
`
|
|
33
|
+
Or download the DMG for your chip (`arm64` for Apple silicon, `x86_64` for Intel) from [Releases](https://github.com/markd88/attention-secretary/releases) and drag Attention into Applications.
|
|
46
34
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
| `attention open` | 打开工作窗口 |
|
|
35
|
+
Attention is not notarized by Apple. If macOS blocks the first launch, go to System Settings → Privacy & Security and click **Open Anyway**.
|
|
36
|
+
|
|
37
|
+
## You stay in control
|
|
38
|
+
|
|
39
|
+
- A new item is shown to you as a draft and recorded only after you agree.
|
|
40
|
+
- Only you can mark something done.
|
|
41
|
+
- Anything outward-facing (sending messages, committing, paying, publishing) needs your authorization.
|
|
55
42
|
|
|
56
|
-
|
|
43
|
+
Your data stays on your Mac in `~/.attention`. Conversations go through your own Claude Code or Codex to the model service you chose. Attention's only network request of its own is a daily check for a new version number.
|
|
57
44
|
|
|
58
|
-
|
|
45
|
+
## More
|
|
59
46
|
|
|
60
|
-
|
|
47
|
+
<details>
|
|
48
|
+
<summary>CLI commands</summary>
|
|
49
|
+
|
|
50
|
+
Installing the npm package runs no scripts; nothing happens until you type one of these:
|
|
51
|
+
|
|
52
|
+
| Command | What it does |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `attention install` | Download, verify (release signature and checksums) and install |
|
|
55
|
+
| `attention update` | Update to the latest version, keeping your data |
|
|
56
|
+
| `attention rollback` | Go back to the previous version |
|
|
57
|
+
| `attention uninstall` | Uninstall; your data stays in `~/.attention` |
|
|
58
|
+
| `attention doctor` | Check that Claude Code can run the secretary |
|
|
59
|
+
| `attention open` | Open the work window |
|
|
61
60
|
|
|
62
|
-
Attention
|
|
61
|
+
When a new version is out, the About page says so. "Update Attention" there, or `attention update`, waits until the secretary finishes its current round. Without Node.js, download the new DMG and replace the app.
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
2. 打开「系统设置 → 隐私与安全性」,往下翻到安全性那一栏,会看到“已阻止打开 Attention”,点「仍要打开」。
|
|
66
|
-
3. 输入密码确认。
|
|
63
|
+
The `attention` command itself updates through npm: `npm install -g attention-secretary@latest`. `attention update` tells you when there is a newer one.
|
|
67
64
|
|
|
68
|
-
|
|
65
|
+
</details>
|
|
69
66
|
|
|
70
|
-
|
|
67
|
+
<details>
|
|
68
|
+
<summary>What the secretary does on its own</summary>
|
|
71
69
|
|
|
72
|
-
|
|
70
|
+
Day to day the secretary only keeps track. The one thing it does on its own is **pre-research**: for an item that hasn't started and whose first step is looking things up, it starts a session to do a first round of research, writes it up, and stops, waiting for you.
|
|
73
71
|
|
|
74
|
-
|
|
75
|
-
2
|
|
76
|
-
|
|
77
|
-
4. 直接在秘书终端里跟它说你手上有哪些事,它会整理成事项草稿给你确认,再排出今天该做的。比如:
|
|
78
|
-
- “帮我记一件事:周五前给王琳回邮件。”
|
|
79
|
-
- “把我今天要做的整理一下,按优先级排出来。”
|
|
80
|
-
- “这个任务在 `~/code/shop-app` 里做。”
|
|
72
|
+
- It works only in Attention's own workspace, never in your project folders, and takes no outward-facing action.
|
|
73
|
+
- At most 2 at a time; the rest wait in a queue.
|
|
74
|
+
- You can step in any time. Typing in its tab means you've taken over; "Stop", "No research" or closing the tab means that item won't be researched on its own again.
|
|
81
75
|
|
|
82
|
-
|
|
76
|
+
</details>
|
|
83
77
|
|
|
84
|
-
|
|
78
|
+
<details>
|
|
79
|
+
<summary>Skills, MCP servers and persona</summary>
|
|
85
80
|
|
|
86
|
-
|
|
81
|
+
In Settings:
|
|
87
82
|
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
- 列表上会显示「秘书调研中」或「秘书排队调研」。
|
|
91
|
-
- 你随时可以插手:打开看看不算打断;在里面说话就算你接手;点「停下」「不用调研」或关掉标签,这件事以后不会再被自动调研。
|
|
83
|
+
- **Skills / MCP**: on first launch the secretary gets the Skills, plugins and MCP servers you already have in Claude Code (or Codex). Remove what you don't need; to add one, ask the secretary. It changes these only when you ask.
|
|
84
|
+
- **Persona**: how the secretary talks and what you prefer, like CLAUDE.md / AGENTS.md. It can't override the secretary's core rules.
|
|
92
85
|
|
|
93
|
-
|
|
86
|
+
</details>
|
|
94
87
|
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
<details>
|
|
89
|
+
<summary>Tasks with a project folder</summary>
|
|
97
90
|
|
|
98
|
-
|
|
91
|
+
Tell the secretary "this happens in `~/code/xxx`" and the task remembers the folder. Sessions for it start right there, just as if you ran `claude` in that folder yourself: the project's CLAUDE.md, Skills, MCP servers and your own permission settings. The secretary never starts work in your project on its own; you click "Work on it" or tell it to.
|
|
99
92
|
|
|
100
|
-
|
|
93
|
+
</details>
|
|
101
94
|
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
<details>
|
|
96
|
+
<summary>Closing the window and quitting</summary>
|
|
104
97
|
|
|
105
|
-
|
|
98
|
+
- **Close the work window (⌘W)**: the menu bar, the pet and the secretary keep working.
|
|
99
|
+
- **Quit Attention (⌘Q)**: stops the secretary and its sessions, then quits. Items and history stay. It starts again the next time you open Attention, not at login.
|
|
106
100
|
|
|
107
|
-
|
|
101
|
+
</details>
|
|
108
102
|
|
|
109
|
-
|
|
103
|
+
<details>
|
|
104
|
+
<summary>Data and cost</summary>
|
|
110
105
|
|
|
111
|
-
|
|
106
|
+
- Items, results and settings are stored in `~/.attention`.
|
|
107
|
+
- Conversations, and what the work reads, go through your Claude Code / Codex to the model service you chose (or your gateway). Attention doesn't handle or forward them.
|
|
108
|
+
- The update check sends none of your data. There are no usage statistics.
|
|
109
|
+
- The secretary checks in every 30 minutes by default; saver mode checks less often during the day and stays quiet at night. Model calls use your own account's quota.
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
- 对话和工作中读到的内容,会经由你的 Claude Code / Codex 发给你自己选的模型服务(或你配置的网关);Attention 不经手、不转发。
|
|
115
|
-
- Attention 自己唯一的对外请求,是每天问一次 GitHub 上最新的版本号,不带任何你的数据,可以在关于页关掉。没有使用统计。
|
|
116
|
-
- 秘书默认每 30 分钟巡检一次;节约模式下白天间隔更长、夜间不打扰。模型调用消耗的是你自己账号的额度。
|
|
111
|
+
</details>
|
|
117
112
|
|
|
118
|
-
##
|
|
113
|
+
## Build from source
|
|
119
114
|
|
|
120
|
-
|
|
115
|
+
You need Python 3.12, the Xcode command line tools and Node.js (for some tests).
|
|
121
116
|
|
|
122
117
|
```bash
|
|
123
118
|
python3.12 -m venv .venv && .venv/bin/python -m pip install -e '.[api,dev,build]'
|
|
@@ -131,13 +126,13 @@ python3.12 -m venv .venv && .venv/bin/python -m pip install -e '.[api,dev,build]
|
|
|
131
126
|
.venv/bin/python scripts/build_app.py --output dist/Attention.app
|
|
132
127
|
```
|
|
133
128
|
|
|
134
|
-
|
|
129
|
+
See [docs/architecture.md](https://github.com/markd88/attention-secretary/blob/main/docs/architecture.md) and [RELEASING.md](https://github.com/markd88/attention-secretary/blob/main/RELEASING.md).
|
|
135
130
|
|
|
136
|
-
##
|
|
131
|
+
## Feedback
|
|
137
132
|
|
|
138
|
-
-
|
|
139
|
-
-
|
|
133
|
+
- Problems and ideas: [GitHub Issues](https://github.com/markd88/attention-secretary/issues). Remove private conversations, item titles, paths and credentials before posting.
|
|
134
|
+
- Security problems: report privately as described in [SECURITY.md](https://github.com/markd88/attention-secretary/blob/main/SECURITY.md).
|
|
140
135
|
|
|
141
|
-
##
|
|
136
|
+
## License
|
|
142
137
|
|
|
143
|
-
[MIT](LICENSE)
|
|
138
|
+
[MIT](https://github.com/markd88/attention-secretary/blob/main/LICENSE). Third-party components and the pet artwork's sources are listed in [THIRD_PARTY_NOTICES.md](https://github.com/markd88/attention-secretary/blob/main/THIRD_PARTY_NOTICES.md).
|
package/bin/attention.js
CHANGED
|
@@ -14,7 +14,7 @@ const https = require("https");
|
|
|
14
14
|
const http = require("http");
|
|
15
15
|
const os = require("os");
|
|
16
16
|
const path = require("path");
|
|
17
|
-
const { spawnSync } = require("child_process");
|
|
17
|
+
const { spawn, spawnSync } = require("child_process");
|
|
18
18
|
|
|
19
19
|
const pkg = require("../package.json");
|
|
20
20
|
const RELEASE_TRUST=require("../release-trust.json");
|
|
@@ -45,6 +45,10 @@ const EN = {
|
|
|
45
45
|
"下载 {name} …": "Downloading {name} …",
|
|
46
46
|
"下载的文件和发布时的校验值对不上,可能被篡改或下载不完整,不安装。": "The download doesn't match the release's checksum; it may be tampered with or incomplete. Not installing.",
|
|
47
47
|
"校验通过。": "Checksum OK.",
|
|
48
|
+
"\n提示:attention 命令有新版本 {latest}(现在是 {current}),运行 npm install -g attention-secretary@latest 更新。": "\nTip: a newer attention command is available ({latest}, you have {current}). Update it with npm install -g attention-secretary@latest.",
|
|
49
|
+
"正在解压并检查安装包 …": "Unpacking and checking the package …",
|
|
50
|
+
"正在安装到 {path} …": "Installing to {path} …",
|
|
51
|
+
"正在启动 Attention …": "Starting Attention …",
|
|
48
52
|
"解压失败:{error}": "Couldn't unpack: {error}",
|
|
49
53
|
"安装包里没有 Attention.app。": "The package has no Attention.app.",
|
|
50
54
|
"安装包的签名检查没有通过,不安装。": "The package's signature check failed; not installing.",
|
|
@@ -84,7 +88,23 @@ function T(text, values = {}) {
|
|
|
84
88
|
for (const [name, value] of Object.entries(values)) out = out.split("{" + name + "}").join(String(value));
|
|
85
89
|
return out;
|
|
86
90
|
}
|
|
87
|
-
function say(text) { process.stdout.write(text + "\n"); }
|
|
91
|
+
function say(text) { process.stdout.write((spinning ? "\r\x1b[K" : "") + text + "\n"); }
|
|
92
|
+
// A spinner for the slow steps, so the terminal doesn't look stuck. It runs in its own tiny process because most of
|
|
93
|
+
// these steps block this one (spawnSync, hashing). Without a terminal (CI, the app's updater) it just prints the line.
|
|
94
|
+
const SPINNER = `const label=process.argv[1],frames="⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏",start=Date.now();let i=0;
|
|
95
|
+
setInterval(()=>{const s=Math.floor((Date.now()-start)/1000);process.stdout.write("\\r\\x1b[K"+frames[i++%frames.length]+" "+label+(s>=5?" ("+s+"s)":""));},80);`;
|
|
96
|
+
let spinning = null;
|
|
97
|
+
function spin(label) {
|
|
98
|
+
stopSpin();
|
|
99
|
+
if (!process.stdout.isTTY) { say(label); return; }
|
|
100
|
+
spinning = spawn(process.execPath, ["-e", SPINNER, label], { stdio: ["ignore", "inherit", "ignore"] });
|
|
101
|
+
}
|
|
102
|
+
function stopSpin() {
|
|
103
|
+
if (!spinning) return;
|
|
104
|
+
spinning.kill("SIGKILL"); spinning = null;
|
|
105
|
+
process.stdout.write("\r\x1b[K");
|
|
106
|
+
}
|
|
107
|
+
process.on("exit", () => { if (spinning) spinning.kill("SIGKILL"); });
|
|
88
108
|
function fail(text) { throw new Error(text); }
|
|
89
109
|
function run(cmd, args, options = {}) {
|
|
90
110
|
const result = spawnSync(cmd, args, { encoding: "utf8", ...options });
|
|
@@ -220,13 +240,15 @@ async function download(info) {
|
|
|
220
240
|
const expected=sumText.toString("utf8").split("\n").map(line=>line.trim().split(/\s+/)).find(parts=>parts[1] && parts[1].replace(/^\*/,"")===asset.name);
|
|
221
241
|
if(!expected || !/^[a-fA-F0-9]{64}$/.test(expected[0]) || expected[0].toLowerCase()!==actual || actual!==signed.sha256 || fs.statSync(file).size!==signed.bytes)failTagged("verify", "checksum_failed", T("下载的文件和发布时的校验值对不上,可能被篡改或下载不完整,不安装。"));
|
|
222
242
|
say(T("校验通过。"));
|
|
243
|
+
spin(T("正在解压并检查安装包 …"));
|
|
223
244
|
const unzip=run("/usr/bin/ditto",["-x","-k",file,dir],{timeout:120000});
|
|
224
245
|
if(!unzip.ok)failTagged("unpack", "install_failed", T("解压失败:{error}",{error:unzip.err}));
|
|
225
246
|
const app=path.join(dir,APP_NAME);
|
|
226
247
|
if(!fs.existsSync(app) || fs.lstatSync(app).isSymbolicLink())failTagged("unpack", "install_failed", T("安装包里没有 Attention.app。"));
|
|
227
248
|
if(!run("/usr/bin/codesign",["--verify","--deep","--strict",app],{timeout:30000}).ok)failTagged("verify", "signature_failed", T("安装包的签名检查没有通过,不安装。"));
|
|
249
|
+
stopSpin();
|
|
228
250
|
return app;
|
|
229
|
-
} catch(error) {fs.rmSync(dir,{recursive:true,force:true});throw error;}
|
|
251
|
+
} catch(error) {stopSpin();fs.rmSync(dir,{recursive:true,force:true});throw error;}
|
|
230
252
|
}
|
|
231
253
|
|
|
232
254
|
// ---- the running app -----------------------------------------------------------------------------------------
|
|
@@ -281,12 +303,15 @@ async function stop(app) {
|
|
|
281
303
|
const file=path.join(DATA,"runtime","endpoint.json");
|
|
282
304
|
if(fs.existsSync(file)){
|
|
283
305
|
readEndpoint(file);
|
|
284
|
-
|
|
285
|
-
|
|
306
|
+
// --wait: stop and confirm it, and treat an endpoint left behind by a Host that already exited as stopped.
|
|
307
|
+
const stopped=run(backend(app),["stop","--wait","--root-dir",DATA],{timeout:60000});
|
|
308
|
+
if(!stopped.ok)throw Error(`Owned service could not be stopped (${stopped.err.split("\n").pop() || "no detail"}); not replacing app`);
|
|
286
309
|
}
|
|
287
310
|
if(descriptor){
|
|
288
311
|
const result=run("/bin/launchctl",["bootout",`gui/${UID}/${LABEL}`],{timeout:10000});
|
|
289
312
|
if(!result.ok && run("/bin/launchctl",["print",`gui/${UID}/${LABEL}`],{timeout:5000}).ok)throw Error("Service unload not confirmed");
|
|
313
|
+
for(let waited=0;waited<15000 && run("/bin/launchctl",["print",`gui/${UID}/${LABEL}`],{timeout:5000}).ok;waited+=500)
|
|
314
|
+
await new Promise(resolve=>setTimeout(resolve,500)); // bootout returns before the job is fully gone
|
|
290
315
|
}
|
|
291
316
|
// Never pkill by a broad command-line substring; unrelated UI/processes remain untouched.
|
|
292
317
|
}
|
|
@@ -325,13 +350,20 @@ function writeService(app) {
|
|
|
325
350
|
}
|
|
326
351
|
async function start(app, prior, overrides={}) {
|
|
327
352
|
const ops={run,endpoint:readEndpoint,identity:e=>localGet(e,"/v1/identity"),now:Date.now,
|
|
328
|
-
delay:ms=>new Promise(resolve=>setTimeout(resolve,ms)),timeout:
|
|
353
|
+
delay:ms=>new Promise(resolve=>setTimeout(resolve,ms)),timeout:90000,...overrides};
|
|
329
354
|
if(prior===undefined) {
|
|
330
355
|
prior=null;
|
|
331
356
|
if(fs.existsSync(path.join(DATA,"runtime","endpoint.json")))prior=ops.endpoint();
|
|
332
357
|
}
|
|
333
|
-
|
|
334
|
-
|
|
358
|
+
// Right after a bootout launchd can still be tearing the old job down and refuses the new one (5: Input/output
|
|
359
|
+
// error) for a few seconds: try again before giving up.
|
|
360
|
+
let boot;
|
|
361
|
+
for(let attempt=0;attempt<6;attempt++) {
|
|
362
|
+
boot=ops.run("/bin/launchctl",["bootstrap",`gui/${UID}`,PLIST],{timeout:10000});
|
|
363
|
+
if(boot.ok)break;
|
|
364
|
+
await ops.delay(2000);
|
|
365
|
+
}
|
|
366
|
+
if(!boot.ok)throw Error(`Background service registration failed (${boot.err || "launchctl bootstrap"}); startup not confirmed`);
|
|
335
367
|
const deadline=ops.now()+ops.timeout;
|
|
336
368
|
while(ops.now()<deadline) {
|
|
337
369
|
try {
|
|
@@ -516,7 +548,7 @@ async function replaceBundle(fresh,target,backup,ops) {
|
|
|
516
548
|
if(moved) {if(ops.compatible)ops.compatible(backup);ops.move(backup,target);if(ops.forgetBackup)ops.forgetBackup(backup);await startRecovered(target);}
|
|
517
549
|
else if(oldStopped && fs.existsSync(target)) {await startRecovered(target);}
|
|
518
550
|
persist("recovered");
|
|
519
|
-
} catch(recovery) {persist("recovery_failed");throw Error(`Update failed; recovery needs review: ${recovery.message}`);}
|
|
551
|
+
} catch(recovery) {persist("recovery_failed");throw Error(`Update failed (${error.message}); recovery needs review: ${recovery.message}`);}
|
|
520
552
|
throw error;
|
|
521
553
|
}
|
|
522
554
|
}
|
|
@@ -526,9 +558,12 @@ function moveToBackup(app) {
|
|
|
526
558
|
if(!run("/bin/mv", [app, path.join(BACKUPS, name)],{timeout:30000}).ok)throw Error("Backup move failed; not continuing");
|
|
527
559
|
return name;
|
|
528
560
|
}
|
|
529
|
-
function doctor(app, model) {
|
|
561
|
+
function doctor(app, model, label) {
|
|
530
562
|
const args = ["check"]; if (model) args.push("--model");
|
|
531
|
-
|
|
563
|
+
if (label) spin(label);
|
|
564
|
+
const result = spawnSync(backend(app), args, { encoding: "utf8", stdio: ["inherit", "pipe", "pipe"] });
|
|
565
|
+
stopSpin();
|
|
566
|
+
process.stdout.write(result.stdout || ""); process.stderr.write(result.stderr || "");
|
|
532
567
|
return result.status === 0;
|
|
533
568
|
}
|
|
534
569
|
|
|
@@ -580,17 +615,20 @@ async function install(version, mustBeNewer,fromApp=false) {
|
|
|
580
615
|
const target = path.join(current ? path.dirname(current) : targetDir(), APP_NAME);
|
|
581
616
|
fs.mkdirSync(BACKUPS,{recursive:true,mode:0o700});
|
|
582
617
|
const backup=path.join(BACKUPS,`Attention-${current?appVersion(current):"new"}-${Date.now()}.app`);
|
|
618
|
+
const ops=bundleOperations(current),record=ops.journal;
|
|
619
|
+
// The spinner follows the transaction: installing, then starting the new copy.
|
|
620
|
+
ops.journal=state=>{record(state);if(state.phase==="starting")spin(T("正在启动 Attention …"));};
|
|
621
|
+
spin(T("正在安装到 {path} …",{path:path.dirname(target)}));
|
|
583
622
|
try {
|
|
584
|
-
await replaceBundle(fresh,target,backup,
|
|
585
|
-
}finally{fs.rmSync(path.dirname(fresh),{recursive:true,force:true});}
|
|
623
|
+
await replaceBundle(fresh,target,backup,ops);
|
|
624
|
+
}finally{stopSpin();fs.rmSync(path.dirname(fresh),{recursive:true,force:true});}
|
|
586
625
|
say(T("✓ Attention {version} 已安装在 {path}", { version: latest, path: target }));
|
|
587
626
|
if(fromApp)return; // app update never triggers an extra paid model probe
|
|
588
627
|
if (!tools.claude) {
|
|
589
628
|
say(T("\n第一次打开时,在工作窗口里选 Codex,窗口会检查它能不能运行秘书。"));
|
|
590
629
|
return;
|
|
591
630
|
}
|
|
592
|
-
|
|
593
|
-
if (doctor(target, true)) {
|
|
631
|
+
if (doctor(target, true, T("正在检查你的 Claude Code 能不能运行秘书 …"))) {
|
|
594
632
|
say(T("\n第一次启动时,在工作窗口的「秘书」页面里会看到 Claude 问是否信任这个文件夹,选 “Yes, I trust this folder” 回车即可。"));
|
|
595
633
|
} else {
|
|
596
634
|
say(T("\n按上面的提示处理好以后,在工作窗口里点「重新检查」,或运行 attention doctor。"));
|
|
@@ -641,20 +679,31 @@ async function uninstall() {
|
|
|
641
679
|
say(T("你的数据还在 {path},如果确定不要了,可以自己把这个文件夹移到废纸篓。", { path: DATA }));
|
|
642
680
|
}
|
|
643
681
|
|
|
682
|
+
// The `attention` command itself is the npm package and doesn't update with the app. Say so when npm has a newer one.
|
|
683
|
+
// Quiet on any failure: this never gets in the way of an install.
|
|
684
|
+
async function cliUpdateHint(fetch=get) {
|
|
685
|
+
try {
|
|
686
|
+
const latest=(await fetch("https://registry.npmjs.org/attention-secretary/latest",true,0,262144,Date.now()+5000)).version;
|
|
687
|
+
if(typeof latest==="string" && newer(latest,pkg.version))
|
|
688
|
+
say(T("\n提示:attention 命令有新版本 {latest}(现在是 {current}),运行 npm install -g attention-secretary@latest 更新。",{latest,current:pkg.version}));
|
|
689
|
+
} catch {}
|
|
690
|
+
}
|
|
644
691
|
async function main() {
|
|
645
692
|
const [command, ...rest] = process.argv.slice(2);
|
|
646
693
|
const flag = name => { const i = rest.indexOf(name); return i >= 0 ? rest[i + 1] : undefined; };
|
|
647
694
|
switch (command) {
|
|
648
|
-
case "install":
|
|
695
|
+
case "install": await withInstallLock(()=>install(flag("--version"), false)); return cliUpdateHint();
|
|
649
696
|
case "update": {
|
|
650
697
|
const selected=flag("--from-app");
|
|
651
698
|
if(selected && selected!==installedApp())throw Error("Update target is not this installed app");
|
|
652
|
-
|
|
699
|
+
await withInstallLock(()=>install(flag("--version"), true,!!selected));
|
|
700
|
+
if(!selected) await cliUpdateHint(); // the app's own update button runs the copy inside the app
|
|
701
|
+
return;
|
|
653
702
|
}
|
|
654
703
|
case "recover": return withInstallLock(()=>recover());
|
|
655
704
|
case "rollback": return withInstallLock(()=>rollback());
|
|
656
705
|
case "uninstall": return withInstallLock(()=>uninstall());
|
|
657
|
-
case "doctor": { const app = installedApp(); if (!app) fail(T("还没有安装 Attention,先运行 attention install。")); process.exit(doctor(app, true) ? 0 : 2); }
|
|
706
|
+
case "doctor": { const app = installedApp(); if (!app) fail(T("还没有安装 Attention,先运行 attention install。")); process.exit(doctor(app, true, T("正在检查你的 Claude Code 能不能运行秘书 …")) ? 0 : 2); }
|
|
658
707
|
case "open": { const app = installedApp(); if (!app) fail(T("还没有安装 Attention。")); run("/usr/bin/open", [app]); return; }
|
|
659
708
|
case "--version": case "-v": say(pkg.version); return;
|
|
660
709
|
default:
|
|
@@ -670,4 +719,4 @@ async function main() {
|
|
|
670
719
|
}
|
|
671
720
|
}
|
|
672
721
|
if (require.main === module) main().catch(error => {process.stderr.write("✗ "+error.message+"\n");process.exitCode=1;});
|
|
673
|
-
else module.exports = { installedApp, installedCopies, download, newer, plistXml, get, checkedUrl, readEndpoint, localGet, replaceBundle, start, rollbackBundle, ensureTransactionSettled, withInstallLock, recoverBundle, bundleFingerprint, writeBackupReceipt, readBackupReceipt, trustedBackups };
|
|
722
|
+
else module.exports = { installedApp, installedCopies, download, newer, plistXml, get, checkedUrl, readEndpoint, localGet, replaceBundle, start, rollbackBundle, ensureTransactionSettled, withInstallLock, recoverBundle, bundleFingerprint, writeBackupReceipt, readBackupReceipt, trustedBackups, spin, stopSpin, say, cliUpdateHint };
|
package/package.json
CHANGED