@cydm/pie 4.0.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/README.md +8 -9
- package/dist/builtin/extensions/im-forward/index.js +670 -149
- package/dist/builtin/extensions/memory/index.js +3 -3
- package/dist/builtin/extensions/pie-ipc/index.js +12 -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-PIOGXKDR.js → concierge-cli-R3RIBGJL.js} +148 -52
- 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 +90 -16
- 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,12 +14,34 @@ 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
|
|
17
36
|
|
|
18
37
|
## \u89D2\u8272\u51C6\u5219
|
|
19
38
|
|
|
39
|
+
- \u6D88\u606F\u8DEF\u7531\u89C4\u5219\uFF08\u8DEF\u7531\u7531\u7CFB\u7EDF\u786E\u5B9A\u6027\u6267\u884C\uFF0C\u4E0D\u9760\u4F60\u731C\uFF1B\u4F60\u53EA\u7BA1\u56DE\u590D\u548C\u6D3E\u6D3B\uFF09\uFF1A
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
20
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
|
|
21
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
|
|
22
47
|
- \u6D3E\u6D3B\u4F18\u5148\u7EA7\uFF1A\u684C\u9762\u5DF2\u5F00\u7684\u7A7A\u95F2 pie\uFF08ipc_list_peers \u89C1 idle\uFF09\u2192 \u65B0\u5F00 worker\uFF08pie_proc spawn\uFF09\u3002
|
|
@@ -25,7 +50,8 @@ var SEED_AGENTS_MD = `# Pie Concierge\uFF08\u7BA1\u5BB6\uFF09
|
|
|
25
50
|
- \u4F60\u65E0\u4EBA\u503C\u5B88\uFF1A\u6CA1\u6709\u4EBA\u5728\u7EC8\u7AEF\u65C1\u3002\u9700\u8981\u7528\u6237\u51B3\u7B56\u65F6\u628A\u95EE\u9898\u539F\u6837\u53D1\u5230 IM\uFF0C\u4E0D\u8981\u5047\u8BBE\u7B54\u6848\u3002
|
|
26
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
|
|
27
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
|
|
28
|
-
|
|
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
|
|
54
|
+
${CRON_SECTION}${MAI_SECTION}`;
|
|
29
55
|
function workspaceDir() {
|
|
30
56
|
return path.join(os.homedir(), ".pie", "concierge");
|
|
31
57
|
}
|
|
@@ -141,7 +167,66 @@ function seedWorkspace(dir) {
|
|
|
141
167
|
const agents = path.join(dir, "AGENTS.md");
|
|
142
168
|
if (!fs.existsSync(agents)) {
|
|
143
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;
|
|
144
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 };
|
|
145
230
|
}
|
|
146
231
|
function cliEntry() {
|
|
147
232
|
return process.argv[1] ? path.resolve(process.argv[1]) : "";
|
|
@@ -247,13 +332,13 @@ function imForwardConfigured(dir) {
|
|
|
247
332
|
}
|
|
248
333
|
async function runInlineImSetup() {
|
|
249
334
|
console.log(`
|
|
250
|
-
|
|
335
|
+
No IM forwarding config found. The first binding needs the interactive wizard (pick a platform, authorize the app, choose a chat):
|
|
251
336
|
|
|
252
|
-
1)
|
|
253
|
-
2)
|
|
254
|
-
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.
|
|
255
340
|
|
|
256
|
-
|
|
341
|
+
To bind a separate app for the concierge only, put a project-layer config at ~/.pie/concierge/.pie/im-forward.json.
|
|
257
342
|
`);
|
|
258
343
|
return false;
|
|
259
344
|
}
|
|
@@ -314,7 +399,7 @@ function installService(dir, state) {
|
|
|
314
399
|
} catch {
|
|
315
400
|
}
|
|
316
401
|
execFileSync("launchctl", ["load", target]);
|
|
317
|
-
console.log(
|
|
402
|
+
console.log(`Installed launchd service: ${target} (RunAtLoad + KeepAlive)`);
|
|
318
403
|
return;
|
|
319
404
|
}
|
|
320
405
|
if (process.platform === "linux") {
|
|
@@ -347,7 +432,7 @@ WantedBy=default.target`;
|
|
|
347
432
|
"--now",
|
|
348
433
|
platformServiceName()
|
|
349
434
|
]);
|
|
350
|
-
console.log(
|
|
435
|
+
console.log(`Installed systemd user service: ${unitPath} (Restart=always)`);
|
|
351
436
|
return;
|
|
352
437
|
}
|
|
353
438
|
if (process.platform === "win32") {
|
|
@@ -365,7 +450,7 @@ WantedBy=default.target`;
|
|
|
365
450
|
"/F"
|
|
366
451
|
]);
|
|
367
452
|
console.log(
|
|
368
|
-
|
|
453
|
+
`Installed scheduled task: ${platformServiceName()} (runs at logon; set restart-on-failure in Task Scheduler)`
|
|
369
454
|
);
|
|
370
455
|
return;
|
|
371
456
|
}
|
|
@@ -391,14 +476,14 @@ function uninstallService() {
|
|
|
391
476
|
if (unloaded) {
|
|
392
477
|
try {
|
|
393
478
|
fs.rmSync(target);
|
|
394
|
-
console.log(
|
|
479
|
+
console.log(`Uninstalled launchd service: ${target}`);
|
|
395
480
|
} catch {
|
|
396
|
-
console.log("
|
|
481
|
+
console.log("No installed service found (the plist is already gone).");
|
|
397
482
|
}
|
|
398
483
|
return true;
|
|
399
484
|
}
|
|
400
485
|
console.error(
|
|
401
|
-
"launchctl unload
|
|
486
|
+
"launchctl unload failed; the service may still be loaded, so the plist and its ownership are kept."
|
|
402
487
|
);
|
|
403
488
|
return false;
|
|
404
489
|
}
|
|
@@ -422,7 +507,7 @@ function uninstallService() {
|
|
|
422
507
|
ok = !fs.existsSync(unitPath2);
|
|
423
508
|
if (!ok) {
|
|
424
509
|
console.error(
|
|
425
|
-
"systemctl disable
|
|
510
|
+
"systemctl disable failed; the service may still be running, so the unit file and its ownership are kept."
|
|
426
511
|
);
|
|
427
512
|
return false;
|
|
428
513
|
}
|
|
@@ -437,7 +522,7 @@ function uninstallService() {
|
|
|
437
522
|
try {
|
|
438
523
|
fs.rmSync(unitPath);
|
|
439
524
|
execFileSync("systemctl", ["--user", "daemon-reload"]);
|
|
440
|
-
console.log(
|
|
525
|
+
console.log(`Uninstalled systemd service.`);
|
|
441
526
|
} catch {
|
|
442
527
|
}
|
|
443
528
|
return ok;
|
|
@@ -455,7 +540,7 @@ function uninstallService() {
|
|
|
455
540
|
}
|
|
456
541
|
if (endOutcome === "error") {
|
|
457
542
|
console.error(
|
|
458
|
-
"
|
|
543
|
+
"Task termination could not be confirmed (/End failed); the registration and its ownership are kept."
|
|
459
544
|
);
|
|
460
545
|
return false;
|
|
461
546
|
}
|
|
@@ -463,7 +548,7 @@ function uninstallService() {
|
|
|
463
548
|
try {
|
|
464
549
|
execFileSync("schtasks", ["/Delete", "/TN", platformServiceName(), "/F"]);
|
|
465
550
|
registrationGone = true;
|
|
466
|
-
console.log("
|
|
551
|
+
console.log("Uninstalled scheduled task.");
|
|
467
552
|
} catch {
|
|
468
553
|
try {
|
|
469
554
|
const probe = execFileSync(
|
|
@@ -478,7 +563,7 @@ function uninstallService() {
|
|
|
478
563
|
}
|
|
479
564
|
}
|
|
480
565
|
if (!registrationGone) {
|
|
481
|
-
console.error("schtasks
|
|
566
|
+
console.error("schtasks delete/query could not confirm removal; ownership is kept.");
|
|
482
567
|
return false;
|
|
483
568
|
}
|
|
484
569
|
return true;
|
|
@@ -487,18 +572,18 @@ function uninstallService() {
|
|
|
487
572
|
}
|
|
488
573
|
async function stopConcierge(state) {
|
|
489
574
|
if (!state.pid) {
|
|
490
|
-
console.log("
|
|
575
|
+
console.log("No recorded pid; nothing to do.");
|
|
491
576
|
return 0;
|
|
492
577
|
}
|
|
493
578
|
const liveness0 = conciergeLiveness(state.pid, state);
|
|
494
579
|
if (liveness0 === "dead") {
|
|
495
580
|
writeState({ sessionId: state.sessionId });
|
|
496
|
-
console.log("
|
|
581
|
+
console.log("The process is no longer running.");
|
|
497
582
|
return 0;
|
|
498
583
|
}
|
|
499
584
|
if (liveness0 === "unknown") {
|
|
500
585
|
console.error(
|
|
501
|
-
|
|
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.`
|
|
502
587
|
);
|
|
503
588
|
return 1;
|
|
504
589
|
}
|
|
@@ -517,12 +602,12 @@ async function stopConcierge(state) {
|
|
|
517
602
|
const finalState = conciergeLiveness(state.pid, state);
|
|
518
603
|
if (finalState === "alive" || finalState === "unknown") {
|
|
519
604
|
console.error(
|
|
520
|
-
|
|
605
|
+
`Shutdown not confirmed (state: ${finalState}); the pid is kept. Retry with pie concierge stop or clean up manually.`
|
|
521
606
|
);
|
|
522
607
|
return 1;
|
|
523
608
|
}
|
|
524
609
|
writeState({ sessionId: state.sessionId });
|
|
525
|
-
console.log("
|
|
610
|
+
console.log("Stopped.");
|
|
526
611
|
return 0;
|
|
527
612
|
}
|
|
528
613
|
function startLockDir(dir) {
|
|
@@ -620,7 +705,7 @@ async function runConciergeCommand(args) {
|
|
|
620
705
|
if (sub === "status") {
|
|
621
706
|
const state = readState();
|
|
622
707
|
if (!state) {
|
|
623
|
-
console.log("
|
|
708
|
+
console.log("Not initialized (run pie concierge first).");
|
|
624
709
|
return;
|
|
625
710
|
}
|
|
626
711
|
console.log(`session: ${state.sessionId}`);
|
|
@@ -676,7 +761,7 @@ async function runConciergeCommand(args) {
|
|
|
676
761
|
await withStartLock(dir, async () => {
|
|
677
762
|
const state = readState();
|
|
678
763
|
if (!state) {
|
|
679
|
-
console.log("
|
|
764
|
+
console.log("Not initialized.");
|
|
680
765
|
process.exitCode = 1;
|
|
681
766
|
return;
|
|
682
767
|
}
|
|
@@ -701,15 +786,15 @@ async function runConciergeCommand(args) {
|
|
|
701
786
|
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
702
787
|
);
|
|
703
788
|
console.log(
|
|
704
|
-
"
|
|
789
|
+
"Stopped (launchd unload). To disable restarts, use --uninstall-service."
|
|
705
790
|
);
|
|
706
791
|
} catch (stopError) {
|
|
707
792
|
const err = stopError;
|
|
708
793
|
const text = `${String(err.stderr ?? "")} ${String(err.stdout ?? "")} ${String(err.message ?? "")}`;
|
|
709
794
|
if (/No such file|not loaded|not found/i.test(text)) {
|
|
710
|
-
console.log("
|
|
795
|
+
console.log("The service is not running (not loaded).");
|
|
711
796
|
} else {
|
|
712
|
-
console.error("launchctl unload
|
|
797
|
+
console.error("launchctl unload failed; the stop is unconfirmed, so service ownership is kept.");
|
|
713
798
|
process.exitCode = 1;
|
|
714
799
|
}
|
|
715
800
|
}
|
|
@@ -720,13 +805,13 @@ async function runConciergeCommand(args) {
|
|
|
720
805
|
"stop",
|
|
721
806
|
platformServiceName()
|
|
722
807
|
]);
|
|
723
|
-
console.log("
|
|
808
|
+
console.log("Stopped (systemctl stop).");
|
|
724
809
|
} catch (stopError) {
|
|
725
810
|
const text = `${String(stopError.stderr ?? "")} ${String(stopError.message ?? "")}`;
|
|
726
811
|
if (/not loaded|unit.*not found|unknown unit/i.test(text)) {
|
|
727
|
-
console.log("
|
|
812
|
+
console.log("The service is not running (inactive).");
|
|
728
813
|
} else {
|
|
729
|
-
console.error("systemctl stop
|
|
814
|
+
console.error("systemctl stop failed; the stop is unconfirmed, so service ownership is kept.");
|
|
730
815
|
process.exitCode = 1;
|
|
731
816
|
}
|
|
732
817
|
}
|
|
@@ -735,15 +820,15 @@ async function runConciergeCommand(args) {
|
|
|
735
820
|
execFileSync("schtasks", ["/End", "/TN", platformServiceName()], {
|
|
736
821
|
stdio: ["ignore", "pipe", "pipe"]
|
|
737
822
|
});
|
|
738
|
-
console.log("
|
|
823
|
+
console.log("Stopped (schtasks /End).");
|
|
739
824
|
} catch (endError) {
|
|
740
825
|
const err = endError;
|
|
741
826
|
const text = `${String(err.stderr ?? "")} ${String(err.stdout ?? "")} ${String(err.message ?? "")}`;
|
|
742
827
|
if (/cannot find|does not exist|not found/i.test(text)) {
|
|
743
|
-
console.log("
|
|
828
|
+
console.log("The service is not running (task not registered).");
|
|
744
829
|
} else {
|
|
745
830
|
console.error(
|
|
746
|
-
"
|
|
831
|
+
"Stopping the service failed (schtasks /End); the stop is unconfirmed, so ownership is kept."
|
|
747
832
|
);
|
|
748
833
|
process.exitCode = 1;
|
|
749
834
|
}
|
|
@@ -763,11 +848,11 @@ async function runConciergeCommand(args) {
|
|
|
763
848
|
if (state && state.service) {
|
|
764
849
|
writeState({ sessionId: state.sessionId, service: void 0 });
|
|
765
850
|
} else if (state) {
|
|
766
|
-
console.log("
|
|
851
|
+
console.log("No service-managed state detected; a manual instance, if present, is unaffected.");
|
|
767
852
|
}
|
|
768
853
|
} else {
|
|
769
854
|
console.error(
|
|
770
|
-
"
|
|
855
|
+
"Service uninstall not confirmed (the manager failed); service ownership is kept and manual takeover is not allowed."
|
|
771
856
|
);
|
|
772
857
|
process.exitCode = 1;
|
|
773
858
|
}
|
|
@@ -779,20 +864,20 @@ async function runConciergeCommand(args) {
|
|
|
779
864
|
const state = readState();
|
|
780
865
|
if (!state) {
|
|
781
866
|
console.error(
|
|
782
|
-
"
|
|
867
|
+
"Run pie concierge once to initialize (a stable session id is required)."
|
|
783
868
|
);
|
|
784
869
|
process.exitCode = 2;
|
|
785
870
|
return;
|
|
786
871
|
}
|
|
787
872
|
if (!imForwardConfigured(dir)) {
|
|
788
|
-
console.error("
|
|
873
|
+
console.error("No IM config detected; complete the first pie concierge initialization.");
|
|
789
874
|
process.exitCode = 2;
|
|
790
875
|
return;
|
|
791
876
|
}
|
|
792
877
|
const installLiveness = conciergeLiveness(state.pid, state);
|
|
793
878
|
if (installLiveness === "alive" || installLiveness === "unknown") {
|
|
794
879
|
console.log(
|
|
795
|
-
|
|
880
|
+
`A resident process is present (state: ${installLiveness}); run pie concierge stop before installing the service.`
|
|
796
881
|
);
|
|
797
882
|
process.exitCode = 2;
|
|
798
883
|
return;
|
|
@@ -803,9 +888,9 @@ async function runConciergeCommand(args) {
|
|
|
803
888
|
return;
|
|
804
889
|
}
|
|
805
890
|
if (sub && sub !== "start") {
|
|
806
|
-
console.error(
|
|
891
|
+
console.error(`Unknown subcommand: ${sub}`);
|
|
807
892
|
console.error(
|
|
808
|
-
"
|
|
893
|
+
"Usage: pie concierge [status|stop|--install-service|--uninstall-service]"
|
|
809
894
|
);
|
|
810
895
|
process.exitCode = 2;
|
|
811
896
|
return;
|
|
@@ -813,20 +898,20 @@ async function runConciergeCommand(args) {
|
|
|
813
898
|
const existing = readState();
|
|
814
899
|
if (existing?.service) {
|
|
815
900
|
console.log(
|
|
816
|
-
"
|
|
901
|
+
"The concierge is managed by a system service (launchd/systemd/scheduled task). To take over manually, run --uninstall-service first."
|
|
817
902
|
);
|
|
818
903
|
return;
|
|
819
904
|
}
|
|
820
905
|
const startLiveness = existing ? conciergeLiveness(existing.pid, existing) : "dead";
|
|
821
906
|
if (existing && (startLiveness === "alive" || startLiveness === "unknown")) {
|
|
822
907
|
console.log(
|
|
823
|
-
|
|
908
|
+
`The concierge may already be running (pid ${existing.pid ?? "-"}, state: ${startLiveness}, session ${existing.sessionId}).`
|
|
824
909
|
);
|
|
825
910
|
return;
|
|
826
911
|
}
|
|
827
912
|
if (!imForwardConfigured(dir) && !process.stdin.isTTY) {
|
|
828
913
|
console.error(
|
|
829
|
-
"
|
|
914
|
+
"No IM config found and no terminal for the wizard; run pie concierge in a TTY."
|
|
830
915
|
);
|
|
831
916
|
process.exitCode = 2;
|
|
832
917
|
return;
|
|
@@ -837,19 +922,29 @@ async function runConciergeCommand(args) {
|
|
|
837
922
|
return;
|
|
838
923
|
}
|
|
839
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
|
+
}
|
|
840
935
|
let readinessReport;
|
|
841
936
|
await withStartLock(dir, async () => {
|
|
842
937
|
const lockedState = readState();
|
|
843
938
|
if (lockedState?.service) {
|
|
844
939
|
console.log(
|
|
845
|
-
"
|
|
940
|
+
"The concierge is managed by a system service (launchd/systemd/scheduled task). To take over manually, run --uninstall-service first."
|
|
846
941
|
);
|
|
847
942
|
return;
|
|
848
943
|
}
|
|
849
944
|
const lockedLiveness = lockedState ? conciergeLiveness(lockedState.pid, lockedState) : "dead";
|
|
850
945
|
if (lockedState && (lockedLiveness === "alive" || lockedLiveness === "unknown")) {
|
|
851
946
|
console.log(
|
|
852
|
-
|
|
947
|
+
`The concierge may already be running (pid ${lockedState.pid ?? "-"}, state: ${lockedLiveness}, session ${lockedState.sessionId}).`
|
|
853
948
|
);
|
|
854
949
|
return;
|
|
855
950
|
}
|
|
@@ -886,7 +981,7 @@ async function runConciergeCommand(args) {
|
|
|
886
981
|
const winnerPid = Math.min(...liveRivals);
|
|
887
982
|
writeState({ ...state, pid: winnerPid });
|
|
888
983
|
console.log(
|
|
889
|
-
|
|
984
|
+
`The concierge is already running (concurrent starts converged on pid ${winnerPid}); this start's extra instance was terminated.`
|
|
890
985
|
);
|
|
891
986
|
return;
|
|
892
987
|
}
|
|
@@ -901,14 +996,14 @@ async function runConciergeCommand(args) {
|
|
|
901
996
|
}
|
|
902
997
|
writeState({ ...winner });
|
|
903
998
|
console.log(
|
|
904
|
-
|
|
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.`
|
|
905
1000
|
);
|
|
906
1001
|
process.exitCode = 1;
|
|
907
1002
|
return;
|
|
908
1003
|
}
|
|
909
1004
|
}
|
|
910
1005
|
}
|
|
911
|
-
console.log(
|
|
1006
|
+
console.log(`Starting (pid ${pid}, session ${state.sessionId})\u2026`);
|
|
912
1007
|
readinessReport = { pid, sinceOffset, sessionId: state.sessionId };
|
|
913
1008
|
});
|
|
914
1009
|
if (readinessReport) {
|
|
@@ -918,22 +1013,23 @@ async function runConciergeCommand(args) {
|
|
|
918
1013
|
const now = readState();
|
|
919
1014
|
const stillOurs = now?.pid === pid && now.sessionId === sessionId && conciergeLiveness(pid, now) === "alive";
|
|
920
1015
|
if (stillOurs) {
|
|
921
|
-
console.log(`\u2713
|
|
1016
|
+
console.log(`\u2713 Concierge ready \xB7 log ${logPath(dir)}`);
|
|
922
1017
|
console.log(
|
|
923
|
-
`
|
|
1018
|
+
` Now just talk to it in your IM app; stop: pie concierge stop; status: pie concierge status`
|
|
924
1019
|
);
|
|
925
1020
|
} else {
|
|
926
1021
|
console.log(
|
|
927
|
-
`\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.`
|
|
928
1023
|
);
|
|
929
1024
|
}
|
|
930
1025
|
} else {
|
|
931
1026
|
console.log(
|
|
932
|
-
`\u26A0
|
|
1027
|
+
`\u26A0 No agent.ready within 30s (pid ${pid}); check the log: ${logPath(dir)}`
|
|
933
1028
|
);
|
|
934
1029
|
}
|
|
935
1030
|
}
|
|
936
1031
|
}
|
|
937
1032
|
export {
|
|
1033
|
+
isTooBroadForWorkerSandbox,
|
|
938
1034
|
runConciergeCommand
|
|
939
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";
|