@cydm/pie 4.1.0 → 4.2.0
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/dist/builtin/extensions/ask-user/index.js +2 -2
- package/dist/builtin/extensions/cron/index.js +177 -24
- package/dist/builtin/extensions/im-forward/index.js +500 -64
- package/dist/builtin/extensions/memory/index.js +3 -3
- package/dist/builtin/extensions/pie-ipc/index.js +10 -3
- package/dist/builtin/extensions/pie-proc/README.md +13 -0
- package/dist/builtin/extensions/pie-proc/index.js +41 -9
- package/dist/builtin/extensions/plan-mode/index.js +2 -2
- package/dist/builtin/extensions/subagent/index.js +3 -3
- package/dist/builtin/extensions/todo/index.js +2 -2
- package/dist/chunks/{chunk-WK4N5HT5.js → chunk-BK36Y35W.js} +31 -0
- package/dist/chunks/{chunk-UOZHQ73X.js → chunk-J2LGVYH2.js} +2 -2
- package/dist/chunks/{chunk-FDLLNPIE.js → chunk-PC6HUZAD.js} +1 -1
- package/dist/chunks/{chunk-TDKNKNPL.js → chunk-PFXSA2LK.js} +3 -3
- package/dist/chunks/{concierge-cli-VWNRJG5A.js → concierge-cli-R3RIBGJL.js} +142 -53
- package/dist/chunks/{src-AB7PLORG.js → src-AQ4H43UM.js} +2 -2
- package/dist/chunks/{src-ZZZO4HSR.js → src-VPMIQGEW.js} +1 -1
- package/dist/cli.js +85 -15
- package/package.json +2 -2
|
@@ -2,6 +2,9 @@ import { createRequire as __createRequire } from "node:module"; const require =
|
|
|
2
2
|
import {
|
|
3
3
|
readProcessCommandLine
|
|
4
4
|
} from "./chunk-X6LBWHK3.js";
|
|
5
|
+
import {
|
|
6
|
+
getConfigDir
|
|
7
|
+
} from "./chunk-ILUHTKF3.js";
|
|
5
8
|
import "./chunk-LZQXQOPJ.js";
|
|
6
9
|
|
|
7
10
|
// src/commands/concierge-cli.ts
|
|
@@ -11,6 +14,22 @@ import * as fs from "node:fs";
|
|
|
11
14
|
import * as os from "node:os";
|
|
12
15
|
import * as path from "node:path";
|
|
13
16
|
var require_ = createRequire(import.meta.url);
|
|
17
|
+
var MAI_SECTION_MARKER = "## \u591A\u4F1A\u8BDD\u534F\u4F5C";
|
|
18
|
+
var MAI_SECTION = `
|
|
19
|
+
${MAI_SECTION_MARKER}
|
|
20
|
+
|
|
21
|
+
- IM \u547D\u4EE4\u9762\uFF08\u7528\u6237\u5728 IM \u91CC\u5BF9\u4F60\u8BF4\u8FD9\u4E9B\u8BCD\uFF0C\u4F60\u76F4\u63A5\u6267\u884C\uFF09\uFF1A\`\u72B6\u6001\`=\u5217\u540D\u518C\uFF08ipc_list_peers\uFF09\uFF1B\`\u8BE6\u60C5 <\u540D>\`=\u8BE5\u4F1A\u8BDD\u753B\u50CF\uFF1B\`\u63A5\u7BA1 <\u540D>\`=\u901A\u77E5\u8BE5\u4F1A\u8BDD\u7528 im_relay \u53D1\u4E0A\u4E00\u8F6E\u6B63\u6587\u5F00\u76F4\u8FDE\u901A\u9053\uFF08\u89C1\u4E0B\uFF09\uFF1B\`\u6539\u540D <\u540D> <\u65B0\u540D>\`=ipc \u901A\u77E5\u8BE5\u4F1A\u8BDD\u6267\u884C\u3002\u6CE8\u610F\uFF1A\`\u9759\u97F3 <\u540D>\`\u76EE\u524D\u6CA1\u6709\u673A\u5668\u5B9E\u73B0\uFF0C\u5982\u5B9E\u544A\u8BC9\u7528\u6237\u9700\u5728 IM \u4FA7\u81EA\u884C\u8BBE\u7F6E\u6D88\u606F\u514D\u6253\u6270\uFF0C\u4E0D\u8981\u5047\u88C5\u5DF2\u9759\u97F3\u3002
|
|
22
|
+
- \u6D3E\u6D3B\u67E5\u8868\uFF08\u8BED\u4E49\u6D3E\u6D3B\uFF0C\u6E90\u5934\u5B9A\u6B7B\u3001\u96F6\u95EE\u8BE2\uFF09\uFF1A\u63A5\u6D3B\u5148\u58F0\u660E\u4E09\u8981\u7D20\u2014\u2014\u9879\u76EE\uFF08\u54EA\u4E2A\u4ED3\u5E93\uFF09\u3001\u9886\u57DF\uFF08\u4EE3\u7801/\u6570\u636E/\u8C03\u67E5/\u5199\u4F5C\u2026\uFF09\u3001\u7D27\u6025\u5EA6\uFF1B\u7136\u540E\u6309 ipc_list_peers \u67E5\u8868\uFF1A\u2460\u9879\u76EE\u5BF9\u53E3\u7684\u7A7A\u95F2\u8005\u4F18\u5148\uFF1B\u2461\u9879\u76EE\u4E0D\u7B26\u4F46\u9886\u57DF\u5BF9\u53E3 \u2192 \u5148\u95EE\u7528\u6237\u4E00\u53E5\uFF1B\u2462\u5168\u90E8\u5728\u5FD9 \u2192 \u6392\u961F\u5E76\u544A\u77E5\u4F4D\u6B21\uFF1B\u2463\u5168\u65B0\u9886\u57DF \u2192 pie_proc \u8D77\u65B0 worker\uFF08cwd \u6307\u5411\u5BF9\u7684\u4ED3\u5E93\uFF0C\u5F53\u573A\u8D77\u540D\u5E76\u544A\u77E5\u7528\u6237\uFF09\u3002\u6D3E\u6D3B\u6D88\u606F\u5FC5\u987B\u5199\u660E"\u4E3A\u4EC0\u4E48\u6D3E\u7ED9\u5B83"\u3002\u7EDD\u4E0D\u628A\u6D3B\u6D3E\u7ED9\u9879\u76EE+\u9886\u57DF\u90FD\u4E0D\u6CBE\u8FB9\u7684\u4F1A\u8BDD\uFF0C\u54EA\u6015\u5B83\u7A7A\u95F2\u3002
|
|
23
|
+
- \u6D3E\u6D3B\u5448\u73B0\uFF1A\u6D3E\u6D3B\u65F6\u5199\u660E"\u6D3E\u7ED9\u8C01\u3001\u5E72\u4EC0\u4E48\u3001\u9884\u671F\u591A\u4E45"\uFF1Bworker \u56DE\u62A5\uFF08ipc \u5B8C\u6210\u901A\u77E5\uFF09\u5230\u4E86\u540E\u8F6C\u8FF0**\u6B63\u6587\u7EA7\u6458\u8981**\u5E76\u6CE8\u660E\u51FA\u5904\uFF08"\uFF08\u6570\u636E\u5206\u6790\uFF09\u56DE\u62A5\uFF1A\u2026"\uFF09\uFF0C\u4E0D\u590D\u8FF0\u5168\u6587\u3002
|
|
24
|
+
- \u63A5\u7BA1\u534F\u8BAE\uFF1A\u7528\u6237\u8BF4"\u63A5\u7BA1 <\u540D>"/"\u6211\u6765\u63A5\u7BA1 <\u540D>"\u65F6\uFF0Cipc_send_notify \u901A\u77E5\u8BE5\u4F1A\u8BDD\uFF1A"\u7528\u6237\u63A5\u7BA1\u76F4\u8FDE\uFF1A\u8C03\u7528 im_relay \u628A\u4F60\u4E0A\u4E00\u8F6E\u6B63\u6587\u539F\u6837\u53D1\u7ED9\u7528\u6237\uFF08root \u6D88\u606F\uFF0C\u4E0D\u5E26 replyTo\uFF09\uFF0C\u5F00\u5934\u52A0\u4E00\u884C\u4F60\u7684\u540D\u5B57\u3002"\u8BE5\u4F1A\u8BDD\u53D1\u51FA\u540E\u5373\u63A5\u7BA1\u5B8C\u6210\uFF1A\u7528\u6237\u540E\u7EED\u5728\u8BE5\u8BDD\u9898\u4E0B\u7684\u6D88\u606F\u4F1A\u76F4\u63A5\u8DEF\u7531\u7ED9\u5B83\uFF0C\u4F60\u4E0D\u518D\u63D2\u8BDD\u3002\u6CE8\u610F\uFF1A\u82E5\u76EE\u6807\u4F1A\u8BDD\u6CA1\u6709 im_relay \u5DE5\u5177\uFF08\u5982 print/one-shot \u5BBF\u4E3B\uFF09\uFF0C\u5982\u5B9E\u544A\u77E5\u7528\u6237\u63A5\u7BA1\u4E0D\u53EF\u884C\u3002
|
|
25
|
+
`;
|
|
26
|
+
var CRON_SECTION_MARKER = "## \u5B9A\u65F6\u4EFB\u52A1";
|
|
27
|
+
var CRON_SECTION = `
|
|
28
|
+
${CRON_SECTION_MARKER}
|
|
29
|
+
|
|
30
|
+
- \u4F60\u6240\u5728\u7684\u65E0\u503C\u5B88\u5BBF\u4E3B\u53EF\u4EE5\u81EA\u5DF1\u7528 cron_manage\uFF08\u65E0\u4EBA\u503C\u5B88\u4E0A\u81EA\u52A8\u6388\u6743\u5E76\u7559\u75D5\uFF0C\u4E0D\u5FC5\u7B49\u4EBA\u786E\u8BA4\uFF09\u3002\u9002\u5408\u201C\u6BCF\u5929 9 \u70B9\u7ED9\u6211\u7B80\u62A5\u201D\u8FD9\u7C7B\u56FA\u5B9A\u8282\u594F\u7684\u4E8B\uFF1B\u4E0D\u9002\u5408\u62FF\u6765\u4EE3\u66FF worker \u5E72\u6D3B\u3002
|
|
31
|
+
- \u5BBF\u4E3B\u91CD\u542F\u540E\uFF08\u5C24\u5176\u5D29\u6E83/\u65AD\u7535/OOM \u4E4B\u540E\uFF09\u7684\u7B2C\u4E00\u6B21\u5BF9\u8BDD\uFF0C\u5148\u7528 cron_manage list \u770B\u4E00\u773C\uFF1A\u82E5\u6709 blocked \u7684\u4EFB\u52A1\uFF0C\u8BF4\u660E\u4E0A\u6B21\u6267\u884C\u7ED3\u679C\u4E0D\u786E\u5B9A\uFF0C\u8981\u539F\u6837\u544A\u8BC9\u7528\u6237\u5E76\u7B49\u4ED6\u51B3\u5B9A\u662F\u5426 resume\uFF1B**\u4E0D\u8981\u81EA\u4F5C\u4E3B\u5F20 resume\uFF0C\u4E5F\u4E0D\u8981\u5220\u4E86\u91CD\u5EFA**\uFF08\u91CD\u5EFA\u4F1A\u4E22\u6389\u4E0D\u786E\u5B9A\u6267\u884C\u7684\u8BB0\u5F55\uFF09\u3002
|
|
32
|
+
`;
|
|
14
33
|
var SEED_AGENTS_MD = `# Pie Concierge\uFF08\u7BA1\u5BB6\uFF09
|
|
15
34
|
|
|
16
35
|
\u4F60\u662F\u7528\u6237\u7684\u5E38\u9A7B\u7BA1\u5BB6 pie\uFF1A\u7ED1\u5B9A IM\uFF08\u5E73\u53F0\u65E0\u5173\uFF09\uFF0C\u65E0\u4EBA\u503C\u5B88\uFF0C\u901A\u8FC7 IM \u4E0E\u7528\u6237\u5BF9\u8BDD\u3002
|
|
@@ -21,7 +40,7 @@ var SEED_AGENTS_MD = `# Pie Concierge\uFF08\u7BA1\u5BB6\uFF09
|
|
|
21
40
|
1. \u7528\u6237\u5728 IM \u76F4\u63A5\u53D1\u6D88\u606F\uFF08\u4E0D\u5F15\u7528\u3001\u4E0D\u56DE\u590D\u4EFB\u4F55\u6D88\u606F\uFF09\u6216\u7FA4\u91CC @app \u2014\u2014 \u90FD\u662F\u627E\u4F60\u3002
|
|
22
41
|
2. \u7528\u6237\u76F4\u63A5\u56DE\u590D\u67D0\u6761\u8F6C\u53D1\u6D88\u606F\u3001\u6216\u5728\u8BE5\u4F1A\u8BDD\u5F00\u542F\u7684 thread \u91CC\u53D1\u8A00 \u2014\u2014 \u56DE\u5230\u90A3\u4E2A\u4F1A\u8BDD\uFF08\u53EF\u80FD\u662F\u4F60\uFF0C\u4E5F\u53EF\u80FD\u662F\u67D0\u4E2A worker \u6216\u684C\u9762\u4F1A\u8BDD\uFF09\u3002
|
|
23
42
|
3. \u7528\u6237\u56DE\u590D\u81EA\u5DF1\u53D1\u7684\u6D88\u606F\u3001\u5F15\u7528\u522B\u4EBA\u7684\u6D88\u606F\u540E\u63D0\u95EE\u3001\u6216\u5728\u6DF1\u5C42\u63A5\u9F99\u91CC\u8BF4\u8BDD \u2014\u2014 \u8FD9\u4E9B\u5F52\u5C5E\u4E0D\u5230\u4EFB\u4F55\u4F1A\u8BDD\uFF0C\u4F1A\u88AB\u9759\u9ED8\u4E22\u5F03\uFF08IM \u4E0A\u6CA1\u6709 reaction \u5C31\u662F\u4FE1\u53F7\uFF09\u3002\u82E5\u7528\u6237\u62B1\u6028\u6CA1\u53CD\u5E94\uFF0C\u8BA9\u4ED6\uFF1A\u5728\u6D88\u606F\u5F00\u5934\u52A0 \`\u4F1A\u8BDD\u540D: \`\uFF08\u5982 \`work: \u770B\u4E0B\u8FD9\u4E2A\`\uFF09\uFF0C\u6216\u76F4\u63A5\u56DE\u590D\u67D0\u4E2A\u4F1A\u8BDD\u7684\u8F6C\u53D1\u6D88\u606F\u3002\u53EF\u7528 ipc_list_peers \u67E5\u770B\u5F53\u524D\u4F1A\u8BDD\u540D\u3002
|
|
24
|
-
4. \u6536\u5230 \`\u4F1A\u8BDD\u540D: \u6B63\u6587\` \u5F62\u5F0F\u7684\u663E\u5F0F\u5BFB\u5740\u65F6\uFF0C\u771F\u6B63\u8981\u5904\u7406\u7684\u6B63\u6587\u662F\u5192\u53F7\u540E\u9762\u90A3\u90E8\u5206\u3002
|
|
43
|
+
4. \u6536\u5230 \`\u4F1A\u8BDD\u540D: \u6B63\u6587\` \u5F62\u5F0F\u7684\u663E\u5F0F\u5BFB\u5740\u65F6\uFF0C\u771F\u6B63\u8981\u5904\u7406\u7684\u6B63\u6587\u662F\u5192\u53F7\u540E\u9762\u90A3\u90E8\u5206\u3002\u6CE8\u610F\uFF1A\u5BFB\u5740\u540D\u53EA\u8BA4\u3010\u624B\u52A8\u547D\u540D\u3011\u7684\u4F1A\u8BDD\uFF08ipc \u540D\u518C\u91CC displayName \u4E4B\u5916\u7684 routingName/manual name\uFF09\uFF1Bipc_list_peers \u663E\u793A\u7684\u5C55\u793A\u540D\uFF08derived/curated\uFF09**\u4E0D\u80FD**\u7528\u6765\u5BFB\u5740\uFF0C\u82E5\u7528\u6237\u62FF\u5C55\u793A\u540D\u5BFB\u5740\u6CA1\u6709\u53CD\u5E94\uFF0C\u5982\u5B9E\u8BF4\u660E\u9700\u8981\u624B\u52A8\u547D\u540D\uFF08/sessions/name\uFF09\u3002
|
|
25
44
|
5. \u540C\u4E00\u4E2A app \u5728\u8FD9\u53F0\u7535\u8111\u4E0A\u53EA\u6709\u4E00\u4E2A\u5E38\u9A7B\u63A5\u6536\u8005\uFF08\u4F60\uFF09\uFF1B\u684C\u9762 pie \u53EA\u63A5\u56DE\u590D\u5B83\u81EA\u5DF1\u8F6C\u53D1\u6D88\u606F\u7684\u6D88\u606F\uFF0C\u4E0D\u4F1A\u8DDF\u4F60\u62A2\u666E\u901A\u6D88\u606F\u3002
|
|
26
45
|
- \u4F60\u662F\u7528\u6237\u5728 IM \u4E0A\u7684\u552F\u4E00\u8054\u7EDC\u70B9\u3002\u9ED8\u8BA4\u6D3E\u6D3B\uFF1A\u7F16\u7801\u3001\u8C03\u67E5\u3001\u89C4\u5212\u3001\u590D\u73B0\u3001\u5BA1\u8BA1\u7B49\u4E00\u5207\u9879\u76EE\u5DE5\u4F5C\u90FD\u4EA4\u7ED9 worker \u53BB\u505A\uFF0C\u4F60\u8D1F\u8D23\u5206\u6D3E\u3001\u76D1\u7763\u3001\u6C47\u603B\u8F6C\u8FBE\u2014\u2014\u4E0D\u8981\u81EA\u5DF1\u52A8\u624B\u505A\u9879\u76EE\u5DE5\u4F5C\uFF0C\u4F60\u7684\u4E0A\u4E0B\u6587\u662F\u7A00\u7F3A\u8D44\u6E90\u3002
|
|
27
46
|
- \u53EA\u6709\u8F7B\u91CF\u7684\u64CD\u4F5C\u6027\u5C0F\u4E8B\u624D\u76F4\u63A5\u505A\uFF1A\u4E00\u6B21\u6027\u67E5\u8BE2\u3001\u8BFB\u4E2A\u6587\u4EF6\u3001\u8DD1\u4E00\u6761\u53EA\u8BFB\u547D\u4EE4\u8FD9\u7C7B\u201C\u4E0D\u6539\u52A8\u9879\u76EE\u72B6\u6001\u3001\u4E0D\u4EA7\u751F\u957F\u8F93\u51FA\u201D\u7684\u4E8B\uFF1B\u4E14\u4F18\u5148\u8D70\u6700\u7B80\u5355\u7684\u7AEF\u5230\u7AEF\u8DEF\u5F84\uFF0C\u4E0D\u4E3A\u5C0F\u4E8B\u642D\u6D41\u7A0B\u3002\u62FF\u4E0D\u51C6\u5C31\u6D3E\u6D3B\u3002
|
|
@@ -32,7 +51,7 @@ var SEED_AGENTS_MD = `# Pie Concierge\uFF08\u7BA1\u5BB6\uFF09
|
|
|
32
51
|
- \u6210\u672C\u610F\u8BC6\uFF1A\u4E0D\u5E38\u5F00\u65E0\u7528\u7684 worker\uFF1B\u4E00\u6B21\u6027\u4EFB\u52A1\u7528 pie -p\uFF0C\u9000\u51FA\u5373\u5B8C\u6210\u3002
|
|
33
52
|
- \u7528\u6237\u5728 IM \u7684\u8FFD\u95EE\u843D\u5728\u54EA\u4E2A thread\uFF0C\u5C31\u67E5\u8DEF\u7531\u8D26\u672C\u7EE7\u7EED\u6D3E\u7ED9\u540C\u4E00\u4E2A worker\uFF08session \u4EB2\u548C\uFF09\u3002
|
|
34
53
|
- \u6D88\u606F\u6CA1\u6536\u5230 reaction \u65F6\u4E0D\u8981\u8BA9\u5B83\u60AC\u7740\uFF1A\u540C\u4E00\u4EFD\u6B63\u6587\u518D\u53D1\u4E00\u6B21\u5373\u53EF\uFF08\u4E0D\u5E26\u5F15\u7528\uFF09\uFF0C\u6216\u52A0 \`\u4F1A\u8BDD\u540D:\` \u6307\u5B9A\u76EE\u6807\u3002
|
|
35
|
-
`;
|
|
54
|
+
${CRON_SECTION}${MAI_SECTION}`;
|
|
36
55
|
function workspaceDir() {
|
|
37
56
|
return path.join(os.homedir(), ".pie", "concierge");
|
|
38
57
|
}
|
|
@@ -148,7 +167,66 @@ function seedWorkspace(dir) {
|
|
|
148
167
|
const agents = path.join(dir, "AGENTS.md");
|
|
149
168
|
if (!fs.existsSync(agents)) {
|
|
150
169
|
fs.writeFileSync(agents, SEED_AGENTS_MD);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
let current;
|
|
173
|
+
try {
|
|
174
|
+
current = fs.readFileSync(agents, "utf8");
|
|
175
|
+
} catch {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
for (const section of [CRON_SECTION, MAI_SECTION]) {
|
|
179
|
+
const marker = section.split("\n").find((line) => line.startsWith("## "));
|
|
180
|
+
if (!current.includes(marker)) {
|
|
181
|
+
fs.appendFileSync(agents, section);
|
|
182
|
+
current += section;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function isTooBroadForWorkerSandbox(input) {
|
|
187
|
+
let resolved;
|
|
188
|
+
try {
|
|
189
|
+
resolved = fs.realpathSync(input);
|
|
190
|
+
} catch {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
const root = path.parse(resolved).root;
|
|
194
|
+
if (resolved === root || resolved === os.homedir()) return true;
|
|
195
|
+
const forbidden = [os.tmpdir(), "/tmp", "/var/tmp", "/private/tmp", "/private/var/tmp"];
|
|
196
|
+
for (const candidate of forbidden) {
|
|
197
|
+
try {
|
|
198
|
+
const real = fs.realpathSync(candidate);
|
|
199
|
+
if (resolved === real) return true;
|
|
200
|
+
} catch {
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
const stat = fs.statSync(resolved);
|
|
205
|
+
if ((stat.mode & 2) !== 0 && (stat.mode & 512) === 0) return true;
|
|
206
|
+
} catch {
|
|
207
|
+
return true;
|
|
151
208
|
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
function seedProcConfig(launchCwd) {
|
|
212
|
+
const root = getConfigDir();
|
|
213
|
+
const file = path.join(root, "pie-proc.json");
|
|
214
|
+
const resolved = path.resolve(launchCwd);
|
|
215
|
+
try {
|
|
216
|
+
if (fs.existsSync(file)) return { state: "exists", file, root };
|
|
217
|
+
} catch {
|
|
218
|
+
return { state: "exists", file, root };
|
|
219
|
+
}
|
|
220
|
+
if (isTooBroadForWorkerSandbox(resolved)) {
|
|
221
|
+
return { state: "too-broad", file, root };
|
|
222
|
+
}
|
|
223
|
+
fs.mkdirSync(root, { recursive: true });
|
|
224
|
+
fs.writeFileSync(
|
|
225
|
+
file,
|
|
226
|
+
`${JSON.stringify({ allowCwd: [resolved] }, null, " ")}
|
|
227
|
+
`
|
|
228
|
+
);
|
|
229
|
+
return { state: "seeded", file, root };
|
|
152
230
|
}
|
|
153
231
|
function cliEntry() {
|
|
154
232
|
return process.argv[1] ? path.resolve(process.argv[1]) : "";
|
|
@@ -254,13 +332,13 @@ function imForwardConfigured(dir) {
|
|
|
254
332
|
}
|
|
255
333
|
async function runInlineImSetup() {
|
|
256
334
|
console.log(`
|
|
257
|
-
|
|
335
|
+
No IM forwarding config found. The first binding needs the interactive wizard (pick a platform, authorize the app, choose a chat):
|
|
258
336
|
|
|
259
|
-
1)
|
|
260
|
-
2)
|
|
261
|
-
3)
|
|
337
|
+
1) run pie inside a project directory, then Ctrl+R or /tools/im-forward setup to finish the wizard;
|
|
338
|
+
2) the wizard writes user-layer config (~/.pie/im-forward.json), shared by every pie;
|
|
339
|
+
3) run pie concierge again.
|
|
262
340
|
|
|
263
|
-
|
|
341
|
+
To bind a separate app for the concierge only, put a project-layer config at ~/.pie/concierge/.pie/im-forward.json.
|
|
264
342
|
`);
|
|
265
343
|
return false;
|
|
266
344
|
}
|
|
@@ -321,7 +399,7 @@ function installService(dir, state) {
|
|
|
321
399
|
} catch {
|
|
322
400
|
}
|
|
323
401
|
execFileSync("launchctl", ["load", target]);
|
|
324
|
-
console.log(
|
|
402
|
+
console.log(`Installed launchd service: ${target} (RunAtLoad + KeepAlive)`);
|
|
325
403
|
return;
|
|
326
404
|
}
|
|
327
405
|
if (process.platform === "linux") {
|
|
@@ -354,7 +432,7 @@ WantedBy=default.target`;
|
|
|
354
432
|
"--now",
|
|
355
433
|
platformServiceName()
|
|
356
434
|
]);
|
|
357
|
-
console.log(
|
|
435
|
+
console.log(`Installed systemd user service: ${unitPath} (Restart=always)`);
|
|
358
436
|
return;
|
|
359
437
|
}
|
|
360
438
|
if (process.platform === "win32") {
|
|
@@ -372,7 +450,7 @@ WantedBy=default.target`;
|
|
|
372
450
|
"/F"
|
|
373
451
|
]);
|
|
374
452
|
console.log(
|
|
375
|
-
|
|
453
|
+
`Installed scheduled task: ${platformServiceName()} (runs at logon; set restart-on-failure in Task Scheduler)`
|
|
376
454
|
);
|
|
377
455
|
return;
|
|
378
456
|
}
|
|
@@ -398,14 +476,14 @@ function uninstallService() {
|
|
|
398
476
|
if (unloaded) {
|
|
399
477
|
try {
|
|
400
478
|
fs.rmSync(target);
|
|
401
|
-
console.log(
|
|
479
|
+
console.log(`Uninstalled launchd service: ${target}`);
|
|
402
480
|
} catch {
|
|
403
|
-
console.log("
|
|
481
|
+
console.log("No installed service found (the plist is already gone).");
|
|
404
482
|
}
|
|
405
483
|
return true;
|
|
406
484
|
}
|
|
407
485
|
console.error(
|
|
408
|
-
"launchctl unload
|
|
486
|
+
"launchctl unload failed; the service may still be loaded, so the plist and its ownership are kept."
|
|
409
487
|
);
|
|
410
488
|
return false;
|
|
411
489
|
}
|
|
@@ -429,7 +507,7 @@ function uninstallService() {
|
|
|
429
507
|
ok = !fs.existsSync(unitPath2);
|
|
430
508
|
if (!ok) {
|
|
431
509
|
console.error(
|
|
432
|
-
"systemctl disable
|
|
510
|
+
"systemctl disable failed; the service may still be running, so the unit file and its ownership are kept."
|
|
433
511
|
);
|
|
434
512
|
return false;
|
|
435
513
|
}
|
|
@@ -444,7 +522,7 @@ function uninstallService() {
|
|
|
444
522
|
try {
|
|
445
523
|
fs.rmSync(unitPath);
|
|
446
524
|
execFileSync("systemctl", ["--user", "daemon-reload"]);
|
|
447
|
-
console.log(
|
|
525
|
+
console.log(`Uninstalled systemd service.`);
|
|
448
526
|
} catch {
|
|
449
527
|
}
|
|
450
528
|
return ok;
|
|
@@ -462,7 +540,7 @@ function uninstallService() {
|
|
|
462
540
|
}
|
|
463
541
|
if (endOutcome === "error") {
|
|
464
542
|
console.error(
|
|
465
|
-
"
|
|
543
|
+
"Task termination could not be confirmed (/End failed); the registration and its ownership are kept."
|
|
466
544
|
);
|
|
467
545
|
return false;
|
|
468
546
|
}
|
|
@@ -470,7 +548,7 @@ function uninstallService() {
|
|
|
470
548
|
try {
|
|
471
549
|
execFileSync("schtasks", ["/Delete", "/TN", platformServiceName(), "/F"]);
|
|
472
550
|
registrationGone = true;
|
|
473
|
-
console.log("
|
|
551
|
+
console.log("Uninstalled scheduled task.");
|
|
474
552
|
} catch {
|
|
475
553
|
try {
|
|
476
554
|
const probe = execFileSync(
|
|
@@ -485,7 +563,7 @@ function uninstallService() {
|
|
|
485
563
|
}
|
|
486
564
|
}
|
|
487
565
|
if (!registrationGone) {
|
|
488
|
-
console.error("schtasks
|
|
566
|
+
console.error("schtasks delete/query could not confirm removal; ownership is kept.");
|
|
489
567
|
return false;
|
|
490
568
|
}
|
|
491
569
|
return true;
|
|
@@ -494,18 +572,18 @@ function uninstallService() {
|
|
|
494
572
|
}
|
|
495
573
|
async function stopConcierge(state) {
|
|
496
574
|
if (!state.pid) {
|
|
497
|
-
console.log("
|
|
575
|
+
console.log("No recorded pid; nothing to do.");
|
|
498
576
|
return 0;
|
|
499
577
|
}
|
|
500
578
|
const liveness0 = conciergeLiveness(state.pid, state);
|
|
501
579
|
if (liveness0 === "dead") {
|
|
502
580
|
writeState({ sessionId: state.sessionId });
|
|
503
|
-
console.log("
|
|
581
|
+
console.log("The process is no longer running.");
|
|
504
582
|
return 0;
|
|
505
583
|
}
|
|
506
584
|
if (liveness0 === "unknown") {
|
|
507
585
|
console.error(
|
|
508
|
-
|
|
586
|
+
`Cannot verify the identity of pid ${state.pid} (ps/wmic failed); refusing to act and keeping the recorded state. Retry later or confirm manually.`
|
|
509
587
|
);
|
|
510
588
|
return 1;
|
|
511
589
|
}
|
|
@@ -524,12 +602,12 @@ async function stopConcierge(state) {
|
|
|
524
602
|
const finalState = conciergeLiveness(state.pid, state);
|
|
525
603
|
if (finalState === "alive" || finalState === "unknown") {
|
|
526
604
|
console.error(
|
|
527
|
-
|
|
605
|
+
`Shutdown not confirmed (state: ${finalState}); the pid is kept. Retry with pie concierge stop or clean up manually.`
|
|
528
606
|
);
|
|
529
607
|
return 1;
|
|
530
608
|
}
|
|
531
609
|
writeState({ sessionId: state.sessionId });
|
|
532
|
-
console.log("
|
|
610
|
+
console.log("Stopped.");
|
|
533
611
|
return 0;
|
|
534
612
|
}
|
|
535
613
|
function startLockDir(dir) {
|
|
@@ -627,7 +705,7 @@ async function runConciergeCommand(args) {
|
|
|
627
705
|
if (sub === "status") {
|
|
628
706
|
const state = readState();
|
|
629
707
|
if (!state) {
|
|
630
|
-
console.log("
|
|
708
|
+
console.log("Not initialized (run pie concierge first).");
|
|
631
709
|
return;
|
|
632
710
|
}
|
|
633
711
|
console.log(`session: ${state.sessionId}`);
|
|
@@ -683,7 +761,7 @@ async function runConciergeCommand(args) {
|
|
|
683
761
|
await withStartLock(dir, async () => {
|
|
684
762
|
const state = readState();
|
|
685
763
|
if (!state) {
|
|
686
|
-
console.log("
|
|
764
|
+
console.log("Not initialized.");
|
|
687
765
|
process.exitCode = 1;
|
|
688
766
|
return;
|
|
689
767
|
}
|
|
@@ -708,15 +786,15 @@ async function runConciergeCommand(args) {
|
|
|
708
786
|
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
709
787
|
);
|
|
710
788
|
console.log(
|
|
711
|
-
"
|
|
789
|
+
"Stopped (launchd unload). To disable restarts, use --uninstall-service."
|
|
712
790
|
);
|
|
713
791
|
} catch (stopError) {
|
|
714
792
|
const err = stopError;
|
|
715
793
|
const text = `${String(err.stderr ?? "")} ${String(err.stdout ?? "")} ${String(err.message ?? "")}`;
|
|
716
794
|
if (/No such file|not loaded|not found/i.test(text)) {
|
|
717
|
-
console.log("
|
|
795
|
+
console.log("The service is not running (not loaded).");
|
|
718
796
|
} else {
|
|
719
|
-
console.error("launchctl unload
|
|
797
|
+
console.error("launchctl unload failed; the stop is unconfirmed, so service ownership is kept.");
|
|
720
798
|
process.exitCode = 1;
|
|
721
799
|
}
|
|
722
800
|
}
|
|
@@ -727,13 +805,13 @@ async function runConciergeCommand(args) {
|
|
|
727
805
|
"stop",
|
|
728
806
|
platformServiceName()
|
|
729
807
|
]);
|
|
730
|
-
console.log("
|
|
808
|
+
console.log("Stopped (systemctl stop).");
|
|
731
809
|
} catch (stopError) {
|
|
732
810
|
const text = `${String(stopError.stderr ?? "")} ${String(stopError.message ?? "")}`;
|
|
733
811
|
if (/not loaded|unit.*not found|unknown unit/i.test(text)) {
|
|
734
|
-
console.log("
|
|
812
|
+
console.log("The service is not running (inactive).");
|
|
735
813
|
} else {
|
|
736
|
-
console.error("systemctl stop
|
|
814
|
+
console.error("systemctl stop failed; the stop is unconfirmed, so service ownership is kept.");
|
|
737
815
|
process.exitCode = 1;
|
|
738
816
|
}
|
|
739
817
|
}
|
|
@@ -742,15 +820,15 @@ async function runConciergeCommand(args) {
|
|
|
742
820
|
execFileSync("schtasks", ["/End", "/TN", platformServiceName()], {
|
|
743
821
|
stdio: ["ignore", "pipe", "pipe"]
|
|
744
822
|
});
|
|
745
|
-
console.log("
|
|
823
|
+
console.log("Stopped (schtasks /End).");
|
|
746
824
|
} catch (endError) {
|
|
747
825
|
const err = endError;
|
|
748
826
|
const text = `${String(err.stderr ?? "")} ${String(err.stdout ?? "")} ${String(err.message ?? "")}`;
|
|
749
827
|
if (/cannot find|does not exist|not found/i.test(text)) {
|
|
750
|
-
console.log("
|
|
828
|
+
console.log("The service is not running (task not registered).");
|
|
751
829
|
} else {
|
|
752
830
|
console.error(
|
|
753
|
-
"
|
|
831
|
+
"Stopping the service failed (schtasks /End); the stop is unconfirmed, so ownership is kept."
|
|
754
832
|
);
|
|
755
833
|
process.exitCode = 1;
|
|
756
834
|
}
|
|
@@ -770,11 +848,11 @@ async function runConciergeCommand(args) {
|
|
|
770
848
|
if (state && state.service) {
|
|
771
849
|
writeState({ sessionId: state.sessionId, service: void 0 });
|
|
772
850
|
} else if (state) {
|
|
773
|
-
console.log("
|
|
851
|
+
console.log("No service-managed state detected; a manual instance, if present, is unaffected.");
|
|
774
852
|
}
|
|
775
853
|
} else {
|
|
776
854
|
console.error(
|
|
777
|
-
"
|
|
855
|
+
"Service uninstall not confirmed (the manager failed); service ownership is kept and manual takeover is not allowed."
|
|
778
856
|
);
|
|
779
857
|
process.exitCode = 1;
|
|
780
858
|
}
|
|
@@ -786,20 +864,20 @@ async function runConciergeCommand(args) {
|
|
|
786
864
|
const state = readState();
|
|
787
865
|
if (!state) {
|
|
788
866
|
console.error(
|
|
789
|
-
"
|
|
867
|
+
"Run pie concierge once to initialize (a stable session id is required)."
|
|
790
868
|
);
|
|
791
869
|
process.exitCode = 2;
|
|
792
870
|
return;
|
|
793
871
|
}
|
|
794
872
|
if (!imForwardConfigured(dir)) {
|
|
795
|
-
console.error("
|
|
873
|
+
console.error("No IM config detected; complete the first pie concierge initialization.");
|
|
796
874
|
process.exitCode = 2;
|
|
797
875
|
return;
|
|
798
876
|
}
|
|
799
877
|
const installLiveness = conciergeLiveness(state.pid, state);
|
|
800
878
|
if (installLiveness === "alive" || installLiveness === "unknown") {
|
|
801
879
|
console.log(
|
|
802
|
-
|
|
880
|
+
`A resident process is present (state: ${installLiveness}); run pie concierge stop before installing the service.`
|
|
803
881
|
);
|
|
804
882
|
process.exitCode = 2;
|
|
805
883
|
return;
|
|
@@ -810,9 +888,9 @@ async function runConciergeCommand(args) {
|
|
|
810
888
|
return;
|
|
811
889
|
}
|
|
812
890
|
if (sub && sub !== "start") {
|
|
813
|
-
console.error(
|
|
891
|
+
console.error(`Unknown subcommand: ${sub}`);
|
|
814
892
|
console.error(
|
|
815
|
-
"
|
|
893
|
+
"Usage: pie concierge [status|stop|--install-service|--uninstall-service]"
|
|
816
894
|
);
|
|
817
895
|
process.exitCode = 2;
|
|
818
896
|
return;
|
|
@@ -820,20 +898,20 @@ async function runConciergeCommand(args) {
|
|
|
820
898
|
const existing = readState();
|
|
821
899
|
if (existing?.service) {
|
|
822
900
|
console.log(
|
|
823
|
-
"
|
|
901
|
+
"The concierge is managed by a system service (launchd/systemd/scheduled task). To take over manually, run --uninstall-service first."
|
|
824
902
|
);
|
|
825
903
|
return;
|
|
826
904
|
}
|
|
827
905
|
const startLiveness = existing ? conciergeLiveness(existing.pid, existing) : "dead";
|
|
828
906
|
if (existing && (startLiveness === "alive" || startLiveness === "unknown")) {
|
|
829
907
|
console.log(
|
|
830
|
-
|
|
908
|
+
`The concierge may already be running (pid ${existing.pid ?? "-"}, state: ${startLiveness}, session ${existing.sessionId}).`
|
|
831
909
|
);
|
|
832
910
|
return;
|
|
833
911
|
}
|
|
834
912
|
if (!imForwardConfigured(dir) && !process.stdin.isTTY) {
|
|
835
913
|
console.error(
|
|
836
|
-
"
|
|
914
|
+
"No IM config found and no terminal for the wizard; run pie concierge in a TTY."
|
|
837
915
|
);
|
|
838
916
|
process.exitCode = 2;
|
|
839
917
|
return;
|
|
@@ -844,19 +922,29 @@ async function runConciergeCommand(args) {
|
|
|
844
922
|
return;
|
|
845
923
|
}
|
|
846
924
|
seedWorkspace(dir);
|
|
925
|
+
const procSeed = seedProcConfig(process.cwd());
|
|
926
|
+
if (procSeed.state === "seeded") {
|
|
927
|
+
console.log(
|
|
928
|
+
`Seeded pie-proc config: allowCwd = ${path.resolve(process.cwd())} (dispatching works now; edit ${procSeed.file} to add roots \u2014 it applies on the next spawn)`
|
|
929
|
+
);
|
|
930
|
+
} else if (procSeed.state === "too-broad") {
|
|
931
|
+
console.log(
|
|
932
|
+
`Did not seed pie-proc config (the current directory ${path.resolve(process.cwd())} is too broad). To dispatch work, write ${procSeed.file}: {"allowCwd": ["/your/project"]}`
|
|
933
|
+
);
|
|
934
|
+
}
|
|
847
935
|
let readinessReport;
|
|
848
936
|
await withStartLock(dir, async () => {
|
|
849
937
|
const lockedState = readState();
|
|
850
938
|
if (lockedState?.service) {
|
|
851
939
|
console.log(
|
|
852
|
-
"
|
|
940
|
+
"The concierge is managed by a system service (launchd/systemd/scheduled task). To take over manually, run --uninstall-service first."
|
|
853
941
|
);
|
|
854
942
|
return;
|
|
855
943
|
}
|
|
856
944
|
const lockedLiveness = lockedState ? conciergeLiveness(lockedState.pid, lockedState) : "dead";
|
|
857
945
|
if (lockedState && (lockedLiveness === "alive" || lockedLiveness === "unknown")) {
|
|
858
946
|
console.log(
|
|
859
|
-
|
|
947
|
+
`The concierge may already be running (pid ${lockedState.pid ?? "-"}, state: ${lockedLiveness}, session ${lockedState.sessionId}).`
|
|
860
948
|
);
|
|
861
949
|
return;
|
|
862
950
|
}
|
|
@@ -893,7 +981,7 @@ async function runConciergeCommand(args) {
|
|
|
893
981
|
const winnerPid = Math.min(...liveRivals);
|
|
894
982
|
writeState({ ...state, pid: winnerPid });
|
|
895
983
|
console.log(
|
|
896
|
-
|
|
984
|
+
`The concierge is already running (concurrent starts converged on pid ${winnerPid}); this start's extra instance was terminated.`
|
|
897
985
|
);
|
|
898
986
|
return;
|
|
899
987
|
}
|
|
@@ -908,14 +996,14 @@ async function runConciergeCommand(args) {
|
|
|
908
996
|
}
|
|
909
997
|
writeState({ ...winner });
|
|
910
998
|
console.log(
|
|
911
|
-
|
|
999
|
+
`Cannot arbitrate concurrent starts (the process table is unavailable); a likely running instance was detected (pid ${winner.pid}, state: ${liveness}). This start's instance was terminated \u2014 no double resident.`
|
|
912
1000
|
);
|
|
913
1001
|
process.exitCode = 1;
|
|
914
1002
|
return;
|
|
915
1003
|
}
|
|
916
1004
|
}
|
|
917
1005
|
}
|
|
918
|
-
console.log(
|
|
1006
|
+
console.log(`Starting (pid ${pid}, session ${state.sessionId})\u2026`);
|
|
919
1007
|
readinessReport = { pid, sinceOffset, sessionId: state.sessionId };
|
|
920
1008
|
});
|
|
921
1009
|
if (readinessReport) {
|
|
@@ -925,22 +1013,23 @@ async function runConciergeCommand(args) {
|
|
|
925
1013
|
const now = readState();
|
|
926
1014
|
const stillOurs = now?.pid === pid && now.sessionId === sessionId && conciergeLiveness(pid, now) === "alive";
|
|
927
1015
|
if (stillOurs) {
|
|
928
|
-
console.log(`\u2713
|
|
1016
|
+
console.log(`\u2713 Concierge ready \xB7 log ${logPath(dir)}`);
|
|
929
1017
|
console.log(
|
|
930
|
-
`
|
|
1018
|
+
` Now just talk to it in your IM app; stop: pie concierge stop; status: pie concierge status`
|
|
931
1019
|
);
|
|
932
1020
|
} else {
|
|
933
1021
|
console.log(
|
|
934
|
-
`\u26A0 agent.ready
|
|
1022
|
+
`\u26A0 agent.ready appeared, but the recorded state is no longer this start (pid ${pid} may have been stopped or replaced); confirm with pie concierge status.`
|
|
935
1023
|
);
|
|
936
1024
|
}
|
|
937
1025
|
} else {
|
|
938
1026
|
console.log(
|
|
939
|
-
`\u26A0
|
|
1027
|
+
`\u26A0 No agent.ready within 30s (pid ${pid}); check the log: ${logPath(dir)}`
|
|
940
1028
|
);
|
|
941
1029
|
}
|
|
942
1030
|
}
|
|
943
1031
|
}
|
|
944
1032
|
export {
|
|
1033
|
+
isTooBroadForWorkerSandbox,
|
|
945
1034
|
runConciergeCommand
|
|
946
1035
|
};
|
|
@@ -210,8 +210,8 @@ import {
|
|
|
210
210
|
understandFileWithModel,
|
|
211
211
|
validateTodos,
|
|
212
212
|
writeJournalNarrative
|
|
213
|
-
} from "./chunk-
|
|
214
|
-
import "./chunk-
|
|
213
|
+
} from "./chunk-PC6HUZAD.js";
|
|
214
|
+
import "./chunk-BK36Y35W.js";
|
|
215
215
|
import "./chunk-NCP264ZE.js";
|
|
216
216
|
import {
|
|
217
217
|
hashText
|
|
@@ -142,7 +142,7 @@ import {
|
|
|
142
142
|
substituteArgs,
|
|
143
143
|
validateRetainedTailEntries,
|
|
144
144
|
verifyPreparedCompactionCommit
|
|
145
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-BK36Y35W.js";
|
|
146
146
|
import "./chunk-NCP264ZE.js";
|
|
147
147
|
import "./chunk-JQRZLVPY.js";
|
|
148
148
|
import "./chunk-XXGYUYXI.js";
|