@cydm/pie 4.11.0 → 4.12.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/dist/builtin/extensions/ask-user/index.js +2 -2
- package/dist/builtin/extensions/cron/index.js +1 -1
- package/dist/builtin/extensions/im-forward/index.js +8724 -7393
- package/dist/builtin/extensions/mcp-adapter/index.js +1 -1
- package/dist/builtin/extensions/memory/index.js +171 -66
- package/dist/builtin/extensions/pie-ipc/index.js +1 -1
- package/dist/builtin/extensions/pie-proc/index.js +533 -50
- package/dist/builtin/extensions/plan-mode/index.js +2 -2
- package/dist/builtin/extensions/subagent/README.md +1 -1
- package/dist/builtin/extensions/subagent/index.js +3 -3
- package/dist/builtin/extensions/todo/index.js +2 -2
- package/dist/chunks/{auth-storage-C3FZMT7J.js → auth-storage-IJEJ2TGE.js} +1 -1
- package/dist/chunks/chunk-26ILLZKQ.js +400 -0
- package/dist/chunks/{chunk-OU33ROFD.js → chunk-3GG342QY.js} +78 -78
- package/dist/chunks/{chunk-IZKHSUNQ.js → chunk-CAPBTMLI.js} +18 -1
- package/dist/chunks/{chunk-B5GKDXVG.js → chunk-IZ4DYCJ7.js} +246 -80
- package/dist/chunks/{chunk-HK3FHIAH.js → chunk-KW46ND3S.js} +1999 -767
- package/dist/chunks/{chunk-SW2E33UL.js → chunk-LMDWWT43.js} +123 -4
- package/dist/chunks/{chunk-EWPPGYBU.js → chunk-OGGL6LUN.js} +55 -16
- package/dist/chunks/chunk-Q4NJEPIZ.js +210 -0
- package/dist/chunks/{chunk-KWK7KTSZ.js → chunk-Q5PSWX3B.js} +3 -3
- package/dist/chunks/{chunk-BTUMBUDU.js → chunk-QSXBPTOA.js} +1 -1
- package/dist/chunks/{chunk-5QMS6RQC.js → chunk-SXBX2P5R.js} +160 -5
- package/dist/chunks/{chunk-7LICWWUE.js → chunk-W37NAT3N.js} +2 -2
- package/dist/chunks/chunk-WTBLV6F5.js +476 -0
- package/dist/chunks/{chunk-BB7ETSJK.js → chunk-Y6AVNVOD.js} +150 -4
- package/dist/chunks/chunk-ZB5FVHI7.js +618 -0
- package/dist/chunks/{host-image-fallback-3TEMOQM5.js → host-image-fallback-NXY36VO2.js} +1 -1
- package/dist/chunks/{manager-cli-BXI4UFTJ.js → manager-cli-OTIMAWO6.js} +280 -299
- package/dist/chunks/{manager-upgrade-XPFXKO7A.js → manager-upgrade-DYRQ7YZ5.js} +101 -69
- package/dist/chunks/memory-git-C3S276QJ.js +19 -0
- package/dist/chunks/{model-registry-MGZO2RBN.js → model-registry-QNEPISBJ.js} +11 -3
- package/dist/chunks/{read-file-understanding-N2ZZQLTZ.js → read-file-understanding-ZCBNCQHG.js} +3 -3
- package/dist/chunks/{src-F5N6O2HR.js → src-7CU7OTQS.js} +36 -36
- package/dist/chunks/{src-3PSR2AAX.js → src-7MZZJVOG.js} +1 -1
- package/dist/cli.js +740 -512
- package/package.json +2 -2
- package/dist/chunks/chunk-L7XXKNZW.js +0 -386
- package/dist/chunks/chunk-ZPJ3BNQB.js +0 -126
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
createPlanCapability,
|
|
7
7
|
markCompletedPlanSteps,
|
|
8
8
|
restoreExecutionState
|
|
9
|
-
} from "../../../chunks/chunk-
|
|
10
|
-
import "../../../chunks/chunk-
|
|
9
|
+
} from "../../../chunks/chunk-KW46ND3S.js";
|
|
10
|
+
import "../../../chunks/chunk-SXBX2P5R.js";
|
|
11
11
|
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
12
12
|
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
13
13
|
import {
|
|
@@ -146,7 +146,7 @@ Semantics:
|
|
|
146
146
|
grows per round, and accumulated context anchors judgment — prefer a fresh
|
|
147
147
|
task for independent reviews. Report recall is a lower-context continuation,
|
|
148
148
|
not an independent review. Results include a growth warning when a session's
|
|
149
|
-
transcript passes
|
|
149
|
+
transcript passes 800,000 JSON characters (not billing tokens).
|
|
150
150
|
|
|
151
151
|
### Thinking Level
|
|
152
152
|
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
createCliRetryPolicy,
|
|
6
6
|
formatTransportLifecycle,
|
|
7
7
|
logTransportLifecycle
|
|
8
|
-
} from "../../../chunks/chunk-
|
|
8
|
+
} from "../../../chunks/chunk-W37NAT3N.js";
|
|
9
9
|
import {
|
|
10
10
|
SUBAGENT_SESSION_RECORD_VERSION,
|
|
11
11
|
createPolicyEnforcedTools,
|
|
12
12
|
createSharedFileSystemTools,
|
|
13
13
|
createSubagentCapability
|
|
14
|
-
} from "../../../chunks/chunk-
|
|
15
|
-
import "../../../chunks/chunk-
|
|
14
|
+
} from "../../../chunks/chunk-KW46ND3S.js";
|
|
15
|
+
import "../../../chunks/chunk-SXBX2P5R.js";
|
|
16
16
|
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
17
17
|
import {
|
|
18
18
|
getConfigDir
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
executeManageTodoList,
|
|
9
9
|
executionStateToTodos,
|
|
10
10
|
restoreExecutionState
|
|
11
|
-
} from "../../../chunks/chunk-
|
|
12
|
-
import "../../../chunks/chunk-
|
|
11
|
+
} from "../../../chunks/chunk-KW46ND3S.js";
|
|
12
|
+
import "../../../chunks/chunk-SXBX2P5R.js";
|
|
13
13
|
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
14
14
|
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
15
15
|
import "../../../chunks/chunk-XXGYUYXI.js";
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
redactText
|
|
4
|
+
} from "./chunk-KW46ND3S.js";
|
|
5
|
+
|
|
6
|
+
// src/commands/memory-git.ts
|
|
7
|
+
import { execFileSync } from "node:child_process";
|
|
8
|
+
import { randomBytes } from "node:crypto";
|
|
9
|
+
import * as fs from "node:fs";
|
|
10
|
+
import * as path from "node:path";
|
|
11
|
+
var REQUIRED_IGNORE_RULES = [
|
|
12
|
+
".entries.json",
|
|
13
|
+
".state.json",
|
|
14
|
+
"evidence-ledger.json",
|
|
15
|
+
".gated-patches.json",
|
|
16
|
+
".snapshots/",
|
|
17
|
+
"wiki/.meta.json",
|
|
18
|
+
"projects/*/meta.json",
|
|
19
|
+
"*.lock",
|
|
20
|
+
"*.log",
|
|
21
|
+
"*.tmp"
|
|
22
|
+
];
|
|
23
|
+
var CURATED_FIXED_FILES = [
|
|
24
|
+
".gitignore",
|
|
25
|
+
"USER.md",
|
|
26
|
+
"MEMORY.md",
|
|
27
|
+
"THREADS.md"
|
|
28
|
+
];
|
|
29
|
+
var GIT_TIMEOUT_MS = 1e4;
|
|
30
|
+
var NULL_DEVICE = process.platform === "win32" ? "NUL" : "/dev/null";
|
|
31
|
+
var STRIPPED_GIT_ENV_KEYS = [
|
|
32
|
+
"GIT_DIR",
|
|
33
|
+
"GIT_WORK_TREE",
|
|
34
|
+
"GIT_INDEX_FILE",
|
|
35
|
+
"GIT_OBJECT_DIRECTORY",
|
|
36
|
+
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
|
37
|
+
"GIT_COMMON_DIR",
|
|
38
|
+
"GIT_CONFIG_PARAMETERS",
|
|
39
|
+
"GIT_CONFIG_COUNT",
|
|
40
|
+
"GIT_CONFIG",
|
|
41
|
+
"GIT_SSH",
|
|
42
|
+
"GIT_SSH_COMMAND",
|
|
43
|
+
"GIT_ASKPASS",
|
|
44
|
+
"GIT_EDITOR",
|
|
45
|
+
"GIT_PAGER"
|
|
46
|
+
];
|
|
47
|
+
function isolatedGitEnv() {
|
|
48
|
+
const env = { ...process.env };
|
|
49
|
+
for (const key of STRIPPED_GIT_ENV_KEYS) delete env[key];
|
|
50
|
+
env.GIT_CONFIG_NOSYSTEM = "1";
|
|
51
|
+
env.GIT_CONFIG_GLOBAL = NULL_DEVICE;
|
|
52
|
+
return env;
|
|
53
|
+
}
|
|
54
|
+
function runGit(cwd, args) {
|
|
55
|
+
return execFileSync("git", args, {
|
|
56
|
+
cwd,
|
|
57
|
+
env: isolatedGitEnv(),
|
|
58
|
+
encoding: "utf8",
|
|
59
|
+
timeout: GIT_TIMEOUT_MS,
|
|
60
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
61
|
+
}).trim();
|
|
62
|
+
}
|
|
63
|
+
var SymlinkContainmentError = class extends Error {
|
|
64
|
+
constructor(message) {
|
|
65
|
+
super(message);
|
|
66
|
+
this.name = "SymlinkContainmentError";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
function assertNoSymlinkPath(memoryRoot, targetPath) {
|
|
70
|
+
const absRoot = path.resolve(memoryRoot);
|
|
71
|
+
const absTarget = path.resolve(targetPath);
|
|
72
|
+
const rel = path.relative(absRoot, absTarget);
|
|
73
|
+
if (rel.startsWith("..") || path.isAbsolute(rel)) {
|
|
74
|
+
throw new SymlinkContainmentError(`path escapes memoryRoot: ${targetPath}`);
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
if (fs.lstatSync(absRoot).isSymbolicLink()) {
|
|
78
|
+
throw new SymlinkContainmentError(`memoryRoot must not be a symlink: ${absRoot}`);
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (error instanceof SymlinkContainmentError) throw error;
|
|
82
|
+
if (error.code !== "ENOENT") throw error;
|
|
83
|
+
}
|
|
84
|
+
if (!rel) return;
|
|
85
|
+
let cursor = absRoot;
|
|
86
|
+
for (const seg of rel.split(path.sep)) {
|
|
87
|
+
if (!seg || seg === ".") continue;
|
|
88
|
+
cursor = path.join(cursor, seg);
|
|
89
|
+
try {
|
|
90
|
+
if (fs.lstatSync(cursor).isSymbolicLink()) {
|
|
91
|
+
throw new SymlinkContainmentError(`refusing symlink inside memoryRoot: ${cursor}`);
|
|
92
|
+
}
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (error instanceof SymlinkContainmentError) throw error;
|
|
95
|
+
if (error.code === "ENOENT") break;
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function ensureMemoryGitIgnore(memoryRoot) {
|
|
101
|
+
const ignorePath = path.join(memoryRoot, ".gitignore");
|
|
102
|
+
assertNoSymlinkPath(memoryRoot, memoryRoot);
|
|
103
|
+
assertNoSymlinkPath(memoryRoot, ignorePath);
|
|
104
|
+
fs.mkdirSync(memoryRoot, { recursive: true });
|
|
105
|
+
let existing = "";
|
|
106
|
+
try {
|
|
107
|
+
const stat = fs.lstatSync(ignorePath);
|
|
108
|
+
if (stat.isSymbolicLink()) {
|
|
109
|
+
throw new SymlinkContainmentError(`refusing symlinked .gitignore: ${ignorePath}`);
|
|
110
|
+
}
|
|
111
|
+
if (!stat.isFile()) {
|
|
112
|
+
throw new SymlinkContainmentError(`refusing non-regular .gitignore: ${ignorePath}`);
|
|
113
|
+
}
|
|
114
|
+
existing = fs.readFileSync(ignorePath, "utf8");
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if (error instanceof SymlinkContainmentError) throw error;
|
|
117
|
+
if (error.code !== "ENOENT") return;
|
|
118
|
+
}
|
|
119
|
+
const existingSet = new Set(existing.split(/\r?\n/).map((line) => line.trim()));
|
|
120
|
+
const missing = REQUIRED_IGNORE_RULES.filter((rule) => !existingSet.has(rule));
|
|
121
|
+
if (missing.length === 0 && existing.length > 0) return;
|
|
122
|
+
const header = existing.trim().length === 0 ? "# Pie memory runtime state \u2014 managed by MemoryStore write.lock + .snapshots/\n" : `${existing.trimEnd()}
|
|
123
|
+
|
|
124
|
+
# Pie memory runtime state
|
|
125
|
+
`;
|
|
126
|
+
const content = `${header}${missing.join("\n")}
|
|
127
|
+
`;
|
|
128
|
+
const tmp = path.join(memoryRoot, `.gitignore.${process.pid}.${randomBytes(6).toString("hex")}.tmp`);
|
|
129
|
+
try {
|
|
130
|
+
fs.writeFileSync(tmp, content, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
131
|
+
assertNoSymlinkPath(memoryRoot, ignorePath);
|
|
132
|
+
fs.renameSync(tmp, ignorePath);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
try {
|
|
135
|
+
fs.rmSync(tmp, { force: true });
|
|
136
|
+
} catch {
|
|
137
|
+
}
|
|
138
|
+
if (error instanceof SymlinkContainmentError) throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function assertNoSymlinksUnderDir(dirPath, maxEntries = 5e3) {
|
|
142
|
+
const stack = [dirPath];
|
|
143
|
+
let visited = 0;
|
|
144
|
+
while (stack.length > 0) {
|
|
145
|
+
const current = stack.pop();
|
|
146
|
+
let stat;
|
|
147
|
+
try {
|
|
148
|
+
stat = fs.lstatSync(current);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
if (error.code === "ENOENT") continue;
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
if (stat.isSymbolicLink()) {
|
|
154
|
+
throw new SymlinkContainmentError(`refusing symlink inside managed git tree: ${current}`);
|
|
155
|
+
}
|
|
156
|
+
if (!stat.isDirectory()) continue;
|
|
157
|
+
for (const entry of fs.readdirSync(current)) {
|
|
158
|
+
visited += 1;
|
|
159
|
+
if (visited > maxEntries) {
|
|
160
|
+
throw new SymlinkContainmentError(`managed git tree exceeds safe scan bound (${maxEntries} entries): ${dirPath}`);
|
|
161
|
+
}
|
|
162
|
+
stack.push(path.join(current, entry));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function assertSafeStandaloneGitDir(realRoot) {
|
|
167
|
+
const gitPath = path.join(realRoot, ".git");
|
|
168
|
+
let stat;
|
|
169
|
+
try {
|
|
170
|
+
stat = fs.lstatSync(gitPath);
|
|
171
|
+
} catch (error) {
|
|
172
|
+
if (error.code === "ENOENT") return;
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
if (stat.isSymbolicLink()) {
|
|
176
|
+
throw new SymlinkContainmentError(`refusing symlinked .git: ${gitPath}`);
|
|
177
|
+
}
|
|
178
|
+
if (!stat.isDirectory()) {
|
|
179
|
+
throw new SymlinkContainmentError(`refusing non-directory .git indirection file: ${gitPath}`);
|
|
180
|
+
}
|
|
181
|
+
assertNoSymlinksUnderDir(gitPath);
|
|
182
|
+
for (const forbidden of [
|
|
183
|
+
path.join(gitPath, "commondir"),
|
|
184
|
+
path.join(gitPath, "config.worktree"),
|
|
185
|
+
path.join(gitPath, "info", "attributes"),
|
|
186
|
+
path.join(gitPath, "objects", "info", "alternates"),
|
|
187
|
+
path.join(realRoot, ".gitattributes")
|
|
188
|
+
]) {
|
|
189
|
+
try {
|
|
190
|
+
fs.lstatSync(forbidden);
|
|
191
|
+
throw new SymlinkContainmentError(`refusing git indirection/attribute file: ${forbidden}`);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (error instanceof SymlinkContainmentError) throw error;
|
|
194
|
+
if (error.code !== "ENOENT") throw error;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const configPath = path.join(gitPath, "config");
|
|
198
|
+
if (fs.existsSync(configPath)) {
|
|
199
|
+
let parsedConfig;
|
|
200
|
+
try {
|
|
201
|
+
parsedConfig = execFileSync("git", ["config", "--file", configPath, "--no-includes", "--null", "--list"], {
|
|
202
|
+
cwd: realRoot,
|
|
203
|
+
env: isolatedGitEnv(),
|
|
204
|
+
encoding: "utf8",
|
|
205
|
+
timeout: GIT_TIMEOUT_MS,
|
|
206
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
207
|
+
});
|
|
208
|
+
} catch (error) {
|
|
209
|
+
throw new SymlinkContainmentError(
|
|
210
|
+
`refusing unreadable/invalid git config ${configPath}: ${error instanceof Error ? error.message.split("\n")[0] : String(error)}`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
const SAFE_GIT_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
214
|
+
"core.repositoryformatversion",
|
|
215
|
+
"core.filemode",
|
|
216
|
+
"core.bare",
|
|
217
|
+
"core.logallrefupdates",
|
|
218
|
+
"core.ignorecase",
|
|
219
|
+
"core.precomposeunicode",
|
|
220
|
+
"core.symlinks",
|
|
221
|
+
"core.autocrlf",
|
|
222
|
+
"core.safecrlf",
|
|
223
|
+
"core.eol",
|
|
224
|
+
"core.quotepath",
|
|
225
|
+
"core.hidedotfiles",
|
|
226
|
+
"init.defaultbranch",
|
|
227
|
+
"user.name",
|
|
228
|
+
"user.email",
|
|
229
|
+
"i18n.commitencoding",
|
|
230
|
+
"i18n.logoutputencoding"
|
|
231
|
+
]);
|
|
232
|
+
for (const entry of parsedConfig.split("\0")) {
|
|
233
|
+
if (!entry) continue;
|
|
234
|
+
const nl = entry.indexOf("\n");
|
|
235
|
+
const key = (nl >= 0 ? entry.slice(0, nl) : entry).toLowerCase();
|
|
236
|
+
const val = nl >= 0 ? entry.slice(nl + 1).trim().toLowerCase() : "";
|
|
237
|
+
if (!SAFE_GIT_CONFIG_KEYS.has(key) || key === "core.repositoryformatversion" && val !== "0" || key === "core.bare" && val !== "false") {
|
|
238
|
+
throw new SymlinkContainmentError(`refusing unsafe git config key "${key}" in ${configPath}`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
for (const sentinel of [path.join(gitPath, ".pie-no-hooks"), path.join(gitPath, ".pie-no-attrs")]) {
|
|
243
|
+
try {
|
|
244
|
+
fs.lstatSync(sentinel);
|
|
245
|
+
throw new SymlinkContainmentError(`refusing unexpected sentinel entry: ${sentinel}`);
|
|
246
|
+
} catch (error) {
|
|
247
|
+
if (error instanceof SymlinkContainmentError) throw error;
|
|
248
|
+
if (error.code !== "ENOENT") throw error;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function isMemoryGitInitialized(memoryRoot) {
|
|
253
|
+
try {
|
|
254
|
+
const stat = fs.lstatSync(path.join(memoryRoot, ".git"));
|
|
255
|
+
return !stat.isSymbolicLink() && stat.isDirectory();
|
|
256
|
+
} catch {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function collectCuratedPathspecs() {
|
|
261
|
+
return [
|
|
262
|
+
...CURATED_FIXED_FILES,
|
|
263
|
+
"wiki/**/*.md",
|
|
264
|
+
"wiki/*.md",
|
|
265
|
+
"journal/**/*.md",
|
|
266
|
+
"journal/*.md",
|
|
267
|
+
"projects/**/*.md"
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
function commitCuratedMemoryBestEffort(memoryRoot, message, options = {}) {
|
|
271
|
+
const initIfMissing = options.initIfMissing ?? true;
|
|
272
|
+
if (!initIfMissing && !isMemoryGitInitialized(memoryRoot)) {
|
|
273
|
+
return { committed: false, reason: "git-not-initialized" };
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
if (!fs.existsSync(memoryRoot)) {
|
|
277
|
+
return { committed: false, reason: "missing-root" };
|
|
278
|
+
}
|
|
279
|
+
assertNoSymlinkPath(memoryRoot, memoryRoot);
|
|
280
|
+
const realRoot = fs.realpathSync(memoryRoot);
|
|
281
|
+
assertNoSymlinkPath(realRoot, path.join(realRoot, ".gitignore"));
|
|
282
|
+
assertSafeStandaloneGitDir(realRoot);
|
|
283
|
+
runGit(realRoot, ["--version"]);
|
|
284
|
+
if (!isMemoryGitInitialized(realRoot)) {
|
|
285
|
+
runGit(realRoot, ["init", "-q"]);
|
|
286
|
+
assertSafeStandaloneGitDir(realRoot);
|
|
287
|
+
}
|
|
288
|
+
ensureMemoryGitIgnore(realRoot);
|
|
289
|
+
for (const dir of ["wiki", "journal", "projects"]) {
|
|
290
|
+
const dirPath = path.join(realRoot, dir);
|
|
291
|
+
if (fs.existsSync(dirPath)) assertNoSymlinksUnderDir(dirPath);
|
|
292
|
+
}
|
|
293
|
+
for (const file of CURATED_FIXED_FILES) {
|
|
294
|
+
assertNoSymlinkPath(realRoot, path.join(realRoot, file));
|
|
295
|
+
}
|
|
296
|
+
const repoPrefix = [
|
|
297
|
+
`--git-dir=${path.join(realRoot, ".git")}`,
|
|
298
|
+
`--work-tree=${realRoot}`,
|
|
299
|
+
"-c",
|
|
300
|
+
`core.hooksPath=${path.join(realRoot, ".git", ".pie-no-hooks")}`,
|
|
301
|
+
"-c",
|
|
302
|
+
`core.attributesFile=${path.join(realRoot, ".git", ".pie-no-attrs")}`,
|
|
303
|
+
"-c",
|
|
304
|
+
"core.fsmonitor=false",
|
|
305
|
+
"-c",
|
|
306
|
+
"maintenance.auto=false",
|
|
307
|
+
"-c",
|
|
308
|
+
"gc.auto=0",
|
|
309
|
+
"-c",
|
|
310
|
+
"gc.recentObjectsHook="
|
|
311
|
+
];
|
|
312
|
+
const pathspecs = collectCuratedPathspecs();
|
|
313
|
+
if (pathspecs.length === 0) {
|
|
314
|
+
return { committed: false, reason: "nothing-to-stage" };
|
|
315
|
+
}
|
|
316
|
+
const activeSpecs = [];
|
|
317
|
+
for (const spec of pathspecs) {
|
|
318
|
+
try {
|
|
319
|
+
runGit(realRoot, [...repoPrefix, "add", "-A", "--", spec]);
|
|
320
|
+
activeSpecs.push(spec);
|
|
321
|
+
} catch {
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (activeSpecs.length === 0) {
|
|
325
|
+
return { committed: false, reason: "nothing-to-stage" };
|
|
326
|
+
}
|
|
327
|
+
const curatedDiff = runGit(realRoot, [...repoPrefix, "status", "--porcelain", "--", ...activeSpecs]);
|
|
328
|
+
if (!curatedDiff) {
|
|
329
|
+
return { committed: false, reason: "no-changes" };
|
|
330
|
+
}
|
|
331
|
+
const redacted = redactText(message).text.replace(/\r?\n/g, " ").trim();
|
|
332
|
+
const safeMsg = redacted.slice(0, 160) || "memory: curated update";
|
|
333
|
+
runGit(realRoot, [
|
|
334
|
+
...repoPrefix,
|
|
335
|
+
"-c",
|
|
336
|
+
"user.name=pie-memory",
|
|
337
|
+
"-c",
|
|
338
|
+
"user.email=pie@local",
|
|
339
|
+
"-c",
|
|
340
|
+
"commit.gpgsign=false",
|
|
341
|
+
"commit",
|
|
342
|
+
"-q",
|
|
343
|
+
"-m",
|
|
344
|
+
safeMsg,
|
|
345
|
+
"--",
|
|
346
|
+
...activeSpecs
|
|
347
|
+
]);
|
|
348
|
+
const sha = runGit(realRoot, [...repoPrefix, "rev-parse", "--short", "HEAD"]);
|
|
349
|
+
return { committed: true, sha };
|
|
350
|
+
} catch (error) {
|
|
351
|
+
if (error instanceof SymlinkContainmentError) {
|
|
352
|
+
return { committed: false, reason: `symlink-rejected: ${error.message}` };
|
|
353
|
+
}
|
|
354
|
+
const reason = error instanceof Error ? error.message.split("\n")[0].slice(0, 160) : String(error);
|
|
355
|
+
return { committed: false, reason };
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
function readCuratedMemoryGitLog(memoryRoot, limit = 10) {
|
|
359
|
+
if (!isMemoryGitInitialized(memoryRoot)) return [];
|
|
360
|
+
try {
|
|
361
|
+
assertNoSymlinkPath(memoryRoot, memoryRoot);
|
|
362
|
+
const realRoot = fs.realpathSync(memoryRoot);
|
|
363
|
+
assertSafeStandaloneGitDir(realRoot);
|
|
364
|
+
const n = Math.min(Math.max(1, limit), 50);
|
|
365
|
+
const out = runGit(realRoot, [
|
|
366
|
+
`--git-dir=${path.join(realRoot, ".git")}`,
|
|
367
|
+
`--work-tree=${realRoot}`,
|
|
368
|
+
"-c",
|
|
369
|
+
`core.hooksPath=${path.join(realRoot, ".git", ".pie-no-hooks")}`,
|
|
370
|
+
"-c",
|
|
371
|
+
`core.attributesFile=${path.join(realRoot, ".git", ".pie-no-attrs")}`,
|
|
372
|
+
"-c",
|
|
373
|
+
"core.fsmonitor=false",
|
|
374
|
+
"-c",
|
|
375
|
+
"core.pager=cat",
|
|
376
|
+
"-c",
|
|
377
|
+
"diff.external=",
|
|
378
|
+
"-c",
|
|
379
|
+
"maintenance.auto=false",
|
|
380
|
+
"-c",
|
|
381
|
+
"gc.auto=0",
|
|
382
|
+
"-c",
|
|
383
|
+
"gc.recentObjectsHook=",
|
|
384
|
+
"log",
|
|
385
|
+
`--max-count=${n}`,
|
|
386
|
+
"--stat",
|
|
387
|
+
"--oneline"
|
|
388
|
+
]);
|
|
389
|
+
return out ? out.split("\n") : [];
|
|
390
|
+
} catch {
|
|
391
|
+
return [];
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export {
|
|
396
|
+
ensureMemoryGitIgnore,
|
|
397
|
+
isMemoryGitInitialized,
|
|
398
|
+
commitCuratedMemoryBestEffort,
|
|
399
|
+
readCuratedMemoryGitLog
|
|
400
|
+
};
|
|
@@ -1,20 +1,59 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
-
// builtin/extensions/pie-ipc/
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
// builtin/extensions/pie-ipc/im-bridge.ts
|
|
4
|
+
var DISPATCH_PREFIX = "[im-forward-dispatch]";
|
|
5
|
+
var dispatchReceiver;
|
|
6
|
+
function registerDispatchReceiver(receiver) {
|
|
7
|
+
dispatchReceiver = receiver;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function takeDispatchFrame(text) {
|
|
10
|
+
if (!dispatchReceiver) return false;
|
|
11
|
+
try {
|
|
12
|
+
return dispatchReceiver(text);
|
|
13
|
+
} catch {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
var imBinding;
|
|
18
|
+
var bindingListeners = /* @__PURE__ */ new Set();
|
|
19
|
+
function bindingChanged() {
|
|
20
|
+
for (const fn of bindingListeners) {
|
|
21
|
+
try {
|
|
22
|
+
fn();
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function onImBindingChanged(fn) {
|
|
28
|
+
bindingListeners.add(fn);
|
|
12
29
|
return () => {
|
|
13
|
-
|
|
30
|
+
bindingListeners.delete(fn);
|
|
14
31
|
};
|
|
15
32
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
33
|
+
function registerImBinding(value) {
|
|
34
|
+
const token = Symbol(value);
|
|
35
|
+
imBinding = { value, token };
|
|
36
|
+
bindingChanged();
|
|
37
|
+
return () => {
|
|
38
|
+
if (imBinding?.token === token) {
|
|
39
|
+
imBinding = void 0;
|
|
40
|
+
bindingChanged();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function currentImBinding() {
|
|
45
|
+
return imBinding?.value;
|
|
46
|
+
}
|
|
47
|
+
var turnImDriverOracle;
|
|
48
|
+
function registerTurnImDriver(oracle) {
|
|
49
|
+
turnImDriverOracle = oracle;
|
|
50
|
+
}
|
|
51
|
+
function isTurnUserImDriven() {
|
|
52
|
+
try {
|
|
53
|
+
return turnImDriverOracle?.() === true;
|
|
54
|
+
} catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
18
57
|
}
|
|
19
58
|
|
|
20
59
|
// builtin/extensions/pie-ipc/pure.ts
|
|
@@ -357,6 +396,23 @@ function assistantBodyText(message) {
|
|
|
357
396
|
return text.trim();
|
|
358
397
|
}
|
|
359
398
|
|
|
399
|
+
// builtin/extensions/pie-ipc/runtime-registry.ts
|
|
400
|
+
var runtimes = /* @__PURE__ */ new Map();
|
|
401
|
+
function key(root) {
|
|
402
|
+
const trimmed = root.replace(/[\\/]+$/, "");
|
|
403
|
+
return process.platform === "win32" ? trimmed.replace(/\//g, "\\").toLowerCase() : trimmed;
|
|
404
|
+
}
|
|
405
|
+
function registerIpcRuntime(root, runtime) {
|
|
406
|
+
const k = key(root);
|
|
407
|
+
runtimes.set(k, runtime);
|
|
408
|
+
return () => {
|
|
409
|
+
if (runtimes.get(k) === runtime) runtimes.delete(k);
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function currentIpcRuntime(root) {
|
|
413
|
+
return runtimes.get(key(root));
|
|
414
|
+
}
|
|
415
|
+
|
|
360
416
|
// builtin/extensions/pie-ipc/transport.ts
|
|
361
417
|
import * as net from "node:net";
|
|
362
418
|
import { createHmac, randomBytes as randomBytes2, randomUUID, timingSafeEqual } from "node:crypto";
|
|
@@ -628,65 +684,15 @@ var IpcTransport = class {
|
|
|
628
684
|
}
|
|
629
685
|
};
|
|
630
686
|
|
|
631
|
-
// builtin/extensions/pie-ipc/im-bridge.ts
|
|
632
|
-
var DISPATCH_PREFIX = "[im-forward-dispatch]";
|
|
633
|
-
var dispatchReceiver;
|
|
634
|
-
function registerDispatchReceiver(receiver) {
|
|
635
|
-
dispatchReceiver = receiver;
|
|
636
|
-
}
|
|
637
|
-
function takeDispatchFrame(text) {
|
|
638
|
-
if (!dispatchReceiver) return false;
|
|
639
|
-
try {
|
|
640
|
-
return dispatchReceiver(text);
|
|
641
|
-
} catch {
|
|
642
|
-
return true;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
var imBinding;
|
|
646
|
-
var bindingListeners = /* @__PURE__ */ new Set();
|
|
647
|
-
function bindingChanged() {
|
|
648
|
-
for (const fn of bindingListeners) {
|
|
649
|
-
try {
|
|
650
|
-
fn();
|
|
651
|
-
} catch {
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
function onImBindingChanged(fn) {
|
|
656
|
-
bindingListeners.add(fn);
|
|
657
|
-
return () => {
|
|
658
|
-
bindingListeners.delete(fn);
|
|
659
|
-
};
|
|
660
|
-
}
|
|
661
|
-
function registerImBinding(value) {
|
|
662
|
-
const token = Symbol(value);
|
|
663
|
-
imBinding = { value, token };
|
|
664
|
-
bindingChanged();
|
|
665
|
-
return () => {
|
|
666
|
-
if (imBinding?.token === token) {
|
|
667
|
-
imBinding = void 0;
|
|
668
|
-
bindingChanged();
|
|
669
|
-
}
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
function currentImBinding() {
|
|
673
|
-
return imBinding?.value;
|
|
674
|
-
}
|
|
675
|
-
var turnImDriverOracle;
|
|
676
|
-
function registerTurnImDriver(oracle) {
|
|
677
|
-
turnImDriverOracle = oracle;
|
|
678
|
-
}
|
|
679
|
-
function isTurnUserImDriven() {
|
|
680
|
-
try {
|
|
681
|
-
return turnImDriverOracle?.() === true;
|
|
682
|
-
} catch {
|
|
683
|
-
return false;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
|
|
687
687
|
export {
|
|
688
|
-
|
|
689
|
-
|
|
688
|
+
DISPATCH_PREFIX,
|
|
689
|
+
registerDispatchReceiver,
|
|
690
|
+
takeDispatchFrame,
|
|
691
|
+
onImBindingChanged,
|
|
692
|
+
registerImBinding,
|
|
693
|
+
currentImBinding,
|
|
694
|
+
registerTurnImDriver,
|
|
695
|
+
isTurnUserImDriven,
|
|
690
696
|
IPC_PROTOCOL_VERSION,
|
|
691
697
|
MAX_STATUS_FILE_BYTES,
|
|
692
698
|
MAX_BODY_CHARS,
|
|
@@ -705,13 +711,7 @@ export {
|
|
|
705
711
|
foldLifecycleEvent,
|
|
706
712
|
resolveIpcConfig,
|
|
707
713
|
assistantBodyText,
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
takeDispatchFrame,
|
|
712
|
-
onImBindingChanged,
|
|
713
|
-
registerImBinding,
|
|
714
|
-
currentImBinding,
|
|
715
|
-
registerTurnImDriver,
|
|
716
|
-
isTurnUserImDriven
|
|
714
|
+
registerIpcRuntime,
|
|
715
|
+
currentIpcRuntime,
|
|
716
|
+
IpcTransport
|
|
717
717
|
};
|
|
@@ -22,9 +22,26 @@ function cronActiveCount(sessionId) {
|
|
|
22
22
|
return 0;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
function cronBlockedSummary(sessionId) {
|
|
26
|
+
const bridge = activeBridge?.bridge;
|
|
27
|
+
if (!bridge) return { blockedCount: 0, memoryBlocked: false };
|
|
28
|
+
try {
|
|
29
|
+
const res = bridge.listJobs(sessionId ? { sessionId } : void 0);
|
|
30
|
+
const blocked = res.jobs.filter((j) => j.state === "blocked");
|
|
31
|
+
const mem = blocked.find((j) => j.isProcess && j.managedBy === "memory");
|
|
32
|
+
return {
|
|
33
|
+
blockedCount: blocked.length,
|
|
34
|
+
memoryBlocked: Boolean(mem),
|
|
35
|
+
...mem?.error ? { memoryError: mem.error } : {}
|
|
36
|
+
};
|
|
37
|
+
} catch {
|
|
38
|
+
return { blockedCount: 0, memoryBlocked: false };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
25
41
|
|
|
26
42
|
export {
|
|
27
43
|
registerCronPanelBridge,
|
|
28
44
|
currentCronPanelBridge,
|
|
29
|
-
cronActiveCount
|
|
45
|
+
cronActiveCount,
|
|
46
|
+
cronBlockedSummary
|
|
30
47
|
};
|