@cydm/pie 1.0.24 → 1.0.25

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.
Files changed (31) hide show
  1. package/README.md +23 -5
  2. package/dist/builtin/extensions/ask-user/index.js +3 -4
  3. package/dist/builtin/extensions/ask-user/package.json +16 -0
  4. package/dist/builtin/extensions/changelog/index.js +65 -65
  5. package/dist/builtin/extensions/changelog/package.json +11 -0
  6. package/dist/builtin/extensions/deploy/package.json +11 -0
  7. package/dist/builtin/extensions/document-attachments/package.json +11 -0
  8. package/dist/builtin/extensions/files/package.json +14 -0
  9. package/dist/builtin/extensions/init/index.js +33 -33
  10. package/dist/builtin/extensions/init/package.json +11 -0
  11. package/dist/builtin/extensions/kimi-attachments/index.js +1 -1
  12. package/dist/builtin/extensions/kimi-attachments/package.json +11 -0
  13. package/dist/builtin/extensions/plan-mode/index.js +5 -34
  14. package/dist/builtin/extensions/plan-mode/package.json +11 -0
  15. package/dist/builtin/extensions/subagent/index.js +4 -5
  16. package/dist/builtin/extensions/subagent/package.json +14 -0
  17. package/dist/builtin/extensions/todo/index.js +3 -4
  18. package/dist/builtin/extensions/todo/package.json +11 -0
  19. package/dist/chunks/{chunk-X44YTB6R.js → chunk-4B42ZU4B.js} +1 -1
  20. package/dist/chunks/{chunk-HAAYC2N5.js → chunk-64XJIKVK.js} +334 -99
  21. package/dist/chunks/{chunk-QYYRJ7JW.js → chunk-BEWVRLCP.js} +375 -252
  22. package/dist/chunks/{chunk-XWNIIJ3X.js → chunk-O4DPFYYP.js} +7511 -6681
  23. package/dist/chunks/{src-PENSDHBM.js → src-27UD2ZBZ.js} +2 -2
  24. package/dist/chunks/{test-stream-PRUYMLXQ.js → test-stream-ZNGAUUVH.js} +6 -2
  25. package/dist/cli.js +2215 -1698
  26. package/dist/{chunks/typescript-GSKWJIO4.js → code-intel-worker.cjs} +2507 -2031
  27. package/models.schema.json +38 -13
  28. package/package.json +10 -6
  29. package/dist/chunks/chunk-J4P2LP7K.js +0 -3846
  30. package/dist/chunks/chunk-QMIIW75M.js +0 -95
  31. package/dist/session-preview-worker.js +0 -159
@@ -1,95 +0,0 @@
1
- import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
-
3
- // src/session-preview-worker-protocol.ts
4
- var SESSION_PREVIEW_WORKER_PROTOCOL_VERSION = 1;
5
- var SESSION_PREVIEW_WORKER_INPUT_BYTES = 32 * 1024;
6
- var SESSION_PREVIEW_WORKER_OUTPUT_BYTES = 4 * 1024;
7
- var SESSION_PREVIEW_WORKER_TIMEOUT_MS = 6e4;
8
- var DURABLE_ROLES = /* @__PURE__ */ new Set(["main", "backup", "previous"]);
9
- function isFiniteNumber(value) {
10
- return typeof value === "number" && Number.isFinite(value);
11
- }
12
- function isSessionPreviewWorkerRequest(value) {
13
- if (!value || typeof value !== "object") return false;
14
- const request = value;
15
- if (request.version !== SESSION_PREVIEW_WORKER_PROTOCOL_VERSION || !Array.isArray(request.files)) return false;
16
- if (request.files.length < 1 || request.files.length > 3) return false;
17
- const seenRoles = /* @__PURE__ */ new Set();
18
- for (const candidate of request.files) {
19
- if (!candidate || typeof candidate !== "object") return false;
20
- const file = candidate;
21
- if (!DURABLE_ROLES.has(file.role) || seenRoles.has(file.role)) return false;
22
- seenRoles.add(file.role);
23
- if (typeof file.path !== "string" || file.path.length === 0) return false;
24
- if (!isFiniteNumber(file.size) || file.size < 0) return false;
25
- for (const key of ["mtimeMs", "ctimeMs", "dev", "ino"]) {
26
- if (!isFiniteNumber(file[key])) return false;
27
- }
28
- }
29
- return true;
30
- }
31
- function isSessionPreviewWorkerResponse(value) {
32
- if (!value || typeof value !== "object") return false;
33
- const response = value;
34
- return response.version === SESSION_PREVIEW_WORKER_PROTOCOL_VERSION && (response.preview === null || typeof response.preview === "string");
35
- }
36
-
37
- // src/session-preview-utils.ts
38
- var MAX_SESSION_PREVIEW_ENTRIES = 50;
39
- var MAX_SESSION_PREVIEW_LENGTH = 120;
40
- function extractTextFromSessionContent(content) {
41
- if (typeof content === "string") return content;
42
- if (Array.isArray(content)) {
43
- const parts = [];
44
- for (const block of content) {
45
- if (block && typeof block === "object" && block.type === "text") {
46
- parts.push(block.text || "");
47
- }
48
- }
49
- return parts.join(" ");
50
- }
51
- return "";
52
- }
53
- function normalizeSessionPreview(text) {
54
- let normalized = "";
55
- let pendingSpace = false;
56
- for (let index = 0; index < text.length; index += 1) {
57
- const char = text[index];
58
- if (/\s/.test(char)) {
59
- if (normalized) pendingSpace = true;
60
- continue;
61
- }
62
- if (pendingSpace) {
63
- normalized += " ";
64
- pendingSpace = false;
65
- if (normalized.length > MAX_SESSION_PREVIEW_LENGTH) break;
66
- }
67
- normalized += char;
68
- if (normalized.length > MAX_SESSION_PREVIEW_LENGTH) break;
69
- }
70
- if (!normalized) return null;
71
- const preview = normalized.length > MAX_SESSION_PREVIEW_LENGTH ? `${normalized.slice(0, MAX_SESSION_PREVIEW_LENGTH)}...` : normalized;
72
- return Buffer.from(preview, "utf-8").toString("utf-8");
73
- }
74
- function extractPreviewFromSessionData(data) {
75
- if (!Array.isArray(data.entries)) return null;
76
- for (const entry of data.entries.slice(0, MAX_SESSION_PREVIEW_ENTRIES)) {
77
- if (entry?.type !== "message" || entry.message?.role !== "user") continue;
78
- const preview = normalizeSessionPreview(extractTextFromSessionContent(entry.message.content));
79
- if (preview) return preview;
80
- }
81
- return null;
82
- }
83
-
84
- export {
85
- SESSION_PREVIEW_WORKER_PROTOCOL_VERSION,
86
- SESSION_PREVIEW_WORKER_INPUT_BYTES,
87
- SESSION_PREVIEW_WORKER_OUTPUT_BYTES,
88
- SESSION_PREVIEW_WORKER_TIMEOUT_MS,
89
- isSessionPreviewWorkerRequest,
90
- isSessionPreviewWorkerResponse,
91
- MAX_SESSION_PREVIEW_ENTRIES,
92
- extractTextFromSessionContent,
93
- normalizeSessionPreview,
94
- extractPreviewFromSessionData
95
- };
@@ -1,159 +0,0 @@
1
- import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
- import {
3
- SESSION_PREVIEW_WORKER_INPUT_BYTES,
4
- SESSION_PREVIEW_WORKER_OUTPUT_BYTES,
5
- SESSION_PREVIEW_WORKER_PROTOCOL_VERSION,
6
- extractPreviewFromSessionData,
7
- isSessionPreviewWorkerRequest
8
- } from "./chunks/chunk-QMIIW75M.js";
9
- import {
10
- decodePersistedSessionContent
11
- } from "./chunks/chunk-J4P2LP7K.js";
12
- import "./chunks/chunk-HAAYC2N5.js";
13
- import "./chunks/chunk-TG2EQLX2.js";
14
-
15
- // src/session-preview-exact.ts
16
- import { promises as fs } from "node:fs";
17
- var EXACT_SESSION_PREVIEW_CANDIDATE_BYTES = 16 * 1024 * 1024;
18
- async function readExactCandidate(file) {
19
- if (file.size > EXACT_SESSION_PREVIEW_CANDIDATE_BYTES) return { status: "candidate-too-large" };
20
- let handle;
21
- try {
22
- handle = await fs.open(file.path, "r");
23
- const stat = await handle.stat();
24
- if (stat.size <= 0) return { status: "invalid" };
25
- if (stat.size > EXACT_SESSION_PREVIEW_CANDIDATE_BYTES) return { status: "candidate-too-large" };
26
- const buffer = Buffer.alloc(stat.size);
27
- let offset = 0;
28
- while (offset < buffer.length) {
29
- const { bytesRead } = await handle.read(buffer, offset, buffer.length - offset, offset);
30
- if (bytesRead <= 0) return { status: "invalid" };
31
- offset += bytesRead;
32
- }
33
- const extra = Buffer.alloc(1);
34
- if ((await handle.read(extra, 0, 1, buffer.length)).bytesRead > 0) return { status: "invalid" };
35
- const decoded = decodePersistedSessionContent(buffer.toString("utf-8"));
36
- return {
37
- status: "valid",
38
- candidate: {
39
- preview: extractPreviewFromSessionData(decoded.data),
40
- content: decoded.content,
41
- updatedAt: Number.isFinite(decoded.updatedAt) ? decoded.updatedAt : 0,
42
- role: file.role
43
- }
44
- };
45
- } catch {
46
- return { status: "invalid" };
47
- } finally {
48
- if (handle) await handle.close().catch(() => {
49
- });
50
- }
51
- }
52
- async function compareExactCandidateContent(file, expectedContent) {
53
- const read = await readExactCandidate(file);
54
- if (read.status === "candidate-too-large") return read.status;
55
- return read.status === "valid" && read.candidate.content === expectedContent ? "equal" : "different-or-invalid";
56
- }
57
- async function readRecoveryCandidate(file) {
58
- const read = await readExactCandidate(file);
59
- if (read.status !== "valid") return read;
60
- if (read.candidate.role === "main") return { status: "invalid" };
61
- return {
62
- status: "valid",
63
- candidate: {
64
- preview: read.candidate.preview,
65
- updatedAt: read.candidate.updatedAt,
66
- role: read.candidate.role
67
- }
68
- };
69
- }
70
- function chooseRecoveryPreview(backup, previous) {
71
- if (!backup) return previous?.preview ?? null;
72
- if (!previous || backup.updatedAt >= previous.updatedAt) return backup.preview;
73
- return previous.preview;
74
- }
75
- async function resolveExactSessionPreview(files) {
76
- const byRole = new Map(files.map((file) => [file.role, file]));
77
- const mainFile = byRole.get("main");
78
- const backupFile = byRole.get("backup");
79
- const previousFile = byRole.get("previous");
80
- const mainRead = mainFile ? await readExactCandidate(mainFile) : { status: "invalid" };
81
- if (mainRead.status === "candidate-too-large") return null;
82
- if (mainRead.status === "valid") {
83
- if (!backupFile || !previousFile) return mainRead.candidate.preview;
84
- const previousComparison = await compareExactCandidateContent(previousFile, mainRead.candidate.content);
85
- if (previousComparison === "candidate-too-large") return null;
86
- if (previousComparison !== "equal") return mainRead.candidate.preview;
87
- const backupRead = await readExactCandidate(backupFile);
88
- if (backupRead.status === "candidate-too-large") return null;
89
- if (backupRead.status !== "valid") return mainRead.candidate.preview;
90
- return backupRead.candidate.content !== mainRead.candidate.content && backupRead.candidate.updatedAt >= mainRead.candidate.updatedAt ? backupRead.candidate.preview : mainRead.candidate.preview;
91
- }
92
- let backup;
93
- if (backupFile) {
94
- const read = await readRecoveryCandidate(backupFile);
95
- if (read.status === "candidate-too-large") return null;
96
- if (read.status === "valid") backup = read.candidate;
97
- }
98
- let previous;
99
- if (previousFile) {
100
- const read = await readRecoveryCandidate(previousFile);
101
- if (read.status === "candidate-too-large") return null;
102
- if (read.status === "valid") previous = read.candidate;
103
- }
104
- return chooseRecoveryPreview(backup, previous);
105
- }
106
-
107
- // src/session-preview-worker.ts
108
- async function readBoundedStdin() {
109
- const chunks = [];
110
- let bytes = 0;
111
- for await (const value of process.stdin) {
112
- const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value);
113
- bytes += chunk.length;
114
- if (bytes > SESSION_PREVIEW_WORKER_INPUT_BYTES) throw new Error("session preview worker input exceeded limit");
115
- chunks.push(chunk);
116
- }
117
- return Buffer.concat(chunks, bytes).toString("utf-8");
118
- }
119
- async function writeBoundedResponse(response) {
120
- const output = JSON.stringify(response);
121
- if (Buffer.byteLength(output, "utf-8") > SESSION_PREVIEW_WORKER_OUTPUT_BYTES) {
122
- throw new Error("session preview worker output exceeded limit");
123
- }
124
- await new Promise((resolve, reject) => {
125
- process.stdout.write(output, "utf-8", (error) => error ? reject(error) : resolve());
126
- });
127
- }
128
- async function main() {
129
- const rawRequest = await readBoundedStdin();
130
- const parsed = JSON.parse(rawRequest);
131
- if (!isSessionPreviewWorkerRequest(parsed)) throw new Error("invalid session preview worker request");
132
- const preview = await resolveExactSessionPreview(parsed.files);
133
- await writeBoundedResponse({
134
- version: SESSION_PREVIEW_WORKER_PROTOCOL_VERSION,
135
- preview
136
- });
137
- }
138
- var completed = false;
139
- var handleParentDisconnect = () => {
140
- if (!completed) process.exit(1);
141
- };
142
- if (typeof process.send === "function") {
143
- if (process.connected) process.once("disconnect", handleParentDisconnect);
144
- else handleParentDisconnect();
145
- }
146
- function finishWorker(exitCode) {
147
- completed = true;
148
- if (exitCode !== void 0) process.exitCode = exitCode;
149
- process.removeListener("disconnect", handleParentDisconnect);
150
- if (!process.connected || typeof process.disconnect !== "function") return;
151
- try {
152
- process.disconnect();
153
- } catch {
154
- }
155
- }
156
- main().then(
157
- () => finishWorker(),
158
- () => finishWorker(1)
159
- );