@cydm/pie 1.0.5 → 1.0.6

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.
@@ -1,10 +1,7 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
- }) : x)(function(x) {
5
- if (typeof require !== "undefined") return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
2
+ import {
3
+ __require
4
+ } from "../../../chunks/chunk-TG2EQLX2.js";
8
5
 
9
6
  // builtin/extensions/changelog/index.ts
10
7
  function getRecentCommits(cwd, count = 10) {
@@ -47,7 +44,6 @@ async function readChangelog(cwd) {
47
44
  }
48
45
  function changelogExtension(ctx) {
49
46
  ctx.log("Changelog extension loaded");
50
- ctx.ui.notify("\u{1F4DD} Changelog extension loaded", "info");
51
47
  ctx.registerCommand({
52
48
  path: ["tools", "changelog"],
53
49
  description: "Smart changelog management with gap detection",
@@ -193,7 +189,6 @@ ${changelog ? "\n```\n" + changelog.slice(0, 2e3) + "\n...\n```" : "(\u6587\u4EF
193
189
  }
194
190
  });
195
191
  ctx.log("Changelog extension ready");
196
- ctx.ui.notify(" Changelog extension loaded", "info");
197
192
  }
198
193
  export {
199
194
  changelogExtension as default
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import "../../../chunks/chunk-TG2EQLX2.js";
2
3
 
3
4
  // builtin/extensions/deploy/index.ts
4
5
  function deployExtension(ctx) {
5
6
  ctx.log("Deploy extension loaded");
6
- ctx.ui.notify("\u{1F680} Deploy extension loaded", "info");
7
7
  ctx.log("Deploy extension ready");
8
8
  }
9
9
  export {
@@ -1,4 +1,5 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import "../../../chunks/chunk-TG2EQLX2.js";
2
3
 
3
4
  // builtin/extensions/document-attachments/index.ts
4
5
  import * as fs from "node:fs";
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import "../../../chunks/chunk-TG2EQLX2.js";
2
3
 
3
4
  // builtin/extensions/files/index.ts
4
5
  function filesExtension(ctx) {
5
6
  ctx.log("Files extension loaded");
6
- ctx.ui.notify("\u{1F4C1} Files extension loaded", "info");
7
7
  }
8
8
  export {
9
9
  filesExtension as default
@@ -1,4 +1,5 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import "../../../chunks/chunk-TG2EQLX2.js";
2
3
 
3
4
  // builtin/extensions/init/index.ts
4
5
  async function loadExistingKnowledge(cwd) {
@@ -100,14 +101,11 @@ async function initExtension(ctx) {
100
101
  if (cachedKnowledge) {
101
102
  const firstLine = cachedKnowledge.split("\n")[0] || "";
102
103
  const projectName = firstLine.replace(/^#\s*/, "").trim() || "\u9879\u76EE";
103
- ctx.ui.notify(`\u{1F4DA} \u5DF2\u52A0\u8F7D ${projectName} \u77E5\u8BC6\u6587\u6863`, "info");
104
104
  ctx.log(`Pre-loaded agents.md (${cachedKnowledge.length} chars)`);
105
105
  } else {
106
- ctx.ui.notify("\u{1F4DA} Init extension loaded (no existing knowledge)", "info");
107
106
  ctx.log("No existing agents.md found");
108
107
  }
109
108
  } catch (err) {
110
- ctx.ui.notify("\u{1F4DA} Init extension loaded", "info");
111
109
  ctx.log(`Failed to pre-load agents.md: ${err}`);
112
110
  }
113
111
  ctx.registerCommand({
@@ -1,4 +1,5 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import "../../../chunks/chunk-TG2EQLX2.js";
2
3
 
3
4
  // builtin/extensions/kimi-attachments/index.ts
4
5
  function isKimiProvider(provider) {
@@ -1,96 +1,23 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ PLAN_MODE_TOOL_NAMES,
4
+ createPlanCapability,
5
+ extractPlanTodoItems,
6
+ isPlanModeSafeCommand,
7
+ markCompletedPlanSteps
8
+ } from "../../../chunks/chunk-TBJ25UWB.js";
9
+ import "../../../chunks/chunk-MWFBYJOI.js";
10
+ import "../../../chunks/chunk-RID3574D.js";
11
+ import "../../../chunks/chunk-TG2EQLX2.js";
2
12
 
3
13
  // builtin/extensions/plan-mode/index.ts
4
- function extractTodoItems(text) {
5
- const items = [];
6
- const planMatch = text.match(/Plan:\s*\n?([\s\S]*?)(?=\n\n|\n[A-Z]|$)/i);
7
- if (!planMatch) return items;
8
- const planSection = planMatch[1];
9
- const lines = planSection.split("\n");
10
- for (const line of lines) {
11
- const trimmed = line.trim();
12
- const match = trimmed.match(/^(?:\d+[.):\s]+|[\-*]\s+)(.+)$/);
13
- if (match) {
14
- items.push({
15
- step: items.length + 1,
16
- text: match[1].trim(),
17
- completed: false
18
- });
19
- }
20
- }
21
- return items;
22
- }
23
- function isSafeCommand(command) {
24
- const trimmed = command.trim();
25
- const safePrefixes = [
26
- "cat ",
27
- "ls ",
28
- "find ",
29
- "grep ",
30
- "head ",
31
- "tail ",
32
- "echo ",
33
- "pwd",
34
- "cd ",
35
- "which ",
36
- "git status",
37
- "git log",
38
- "git diff",
39
- "git show",
40
- "git branch -a",
41
- "git remote -v",
42
- "git config --list",
43
- "npm list",
44
- "npm view"
45
- ];
46
- const dangerousPatterns = [
47
- /\brm\s+-[rf]*/i,
48
- />[\s]*\/dev\//,
49
- /\|.*\brm\b/,
50
- /git\s+push/i,
51
- /git\s+reset/i,
52
- /git\s+checkout\s+-/,
53
- /git\s+revert/i,
54
- /npm\s+publish/i,
55
- /npm\s+uninstall/i,
56
- /npm\s+rm/i
57
- ];
58
- for (const pattern of dangerousPatterns) {
59
- if (pattern.test(trimmed)) {
60
- return false;
61
- }
62
- }
63
- for (const prefix of safePrefixes) {
64
- if (trimmed.startsWith(prefix)) {
65
- return true;
66
- }
67
- }
68
- if (/^[a-z]+$/.test(trimmed)) {
69
- return ["pwd", "ls", "clear", "whoami"].includes(trimmed);
70
- }
71
- return false;
72
- }
73
- function markCompletedSteps(text, todoItems2) {
74
- let markedCount = 0;
75
- const doneMatches = text.matchAll(/\[DONE:\s*(\d+)\]/gi);
76
- for (const match of doneMatches) {
77
- const stepNum = parseInt(match[1], 10);
78
- const item = todoItems2.find((t) => t.step === stepNum);
79
- if (item && !item.completed) {
80
- item.completed = true;
81
- markedCount++;
82
- }
83
- }
84
- return markedCount;
85
- }
86
- var PLAN_MODE_TOOLS = ["read", "bash", "grep", "find", "ls", "questionnaire"];
87
- var NORMAL_MODE_TOOLS = ["read", "bash", "edit", "write", "grep", "find", "ls", "questionnaire"];
88
14
  var SESSION_METADATA_KEY = "planModeEnabled";
89
15
  var planModeEnabled = false;
90
16
  var executionMode = false;
91
17
  var todoItems = [];
92
18
  function planModeExtension(ctx) {
93
19
  ctx.log("Plan mode extension loaded");
20
+ const capability = createPlanCapability();
94
21
  function readPersistedPlanMode() {
95
22
  return ctx.getSessionMetadata()?.[SESSION_METADATA_KEY] === true;
96
23
  }
@@ -102,6 +29,13 @@ function planModeExtension(ctx) {
102
29
  ctx.ui.notify("\u23F8\uFE0F Plan mode active (read-only)", "info");
103
30
  }
104
31
  }
32
+ function getNormalModeTools() {
33
+ const allToolNames = ctx.getAllTools?.()?.map((tool) => tool?.name).filter((name) => typeof name === "string" && name.length > 0);
34
+ if (allToolNames && allToolNames.length > 0) {
35
+ return allToolNames;
36
+ }
37
+ return ["read", "bash", "edit", "write", "grep", "find", "ls", "ask_user_multi", "manage_todo_list"];
38
+ }
105
39
  function togglePlanMode() {
106
40
  planModeEnabled = !planModeEnabled;
107
41
  executionMode = false;
@@ -109,10 +43,10 @@ function planModeExtension(ctx) {
109
43
  ctx.setSessionMetadata(SESSION_METADATA_KEY, planModeEnabled);
110
44
  ctx.setPlanMode(planModeEnabled);
111
45
  if (planModeEnabled) {
112
- ctx.setActiveTools(PLAN_MODE_TOOLS);
113
- ctx.ui.notify(`Plan mode enabled. Available tools: ${PLAN_MODE_TOOLS.join(", ")}`);
46
+ ctx.setActiveTools([...PLAN_MODE_TOOL_NAMES]);
47
+ ctx.ui.notify(`Plan mode enabled. Available tools: ${PLAN_MODE_TOOL_NAMES.join(", ")}`);
114
48
  } else {
115
- ctx.setActiveTools(NORMAL_MODE_TOOLS);
49
+ ctx.setActiveTools(getNormalModeTools());
116
50
  ctx.ui.notify("Plan mode disabled. Full access restored.");
117
51
  }
118
52
  updateStatus();
@@ -122,17 +56,17 @@ function planModeExtension(ctx) {
122
56
  executionMode = false;
123
57
  todoItems = [];
124
58
  ctx.setPlanMode(enabled, { forcePromptInjection: options.forcePromptInjection });
125
- ctx.setActiveTools(enabled ? PLAN_MODE_TOOLS : NORMAL_MODE_TOOLS);
59
+ ctx.setActiveTools(enabled ? [...PLAN_MODE_TOOL_NAMES] : getNormalModeTools());
126
60
  if (options.notify) {
127
61
  ctx.ui.notify(
128
- enabled ? `Plan mode enabled. Available tools: ${PLAN_MODE_TOOLS.join(", ")}` : "Plan mode disabled. Full access restored."
62
+ enabled ? `Plan mode enabled. Available tools: ${PLAN_MODE_TOOL_NAMES.join(", ")}` : "Plan mode disabled. Full access restored."
129
63
  );
130
64
  }
131
65
  updateStatus();
132
66
  }
133
67
  ctx.registerCommand({
134
- path: ["tools", "plan"],
135
- description: "Toggle plan mode (read-only exploration)",
68
+ path: capability.commands?.[0]?.path ?? ["tools", "plan"],
69
+ description: capability.commands?.[0]?.description ?? "Toggle plan mode (read-only exploration)",
136
70
  handler: async (_ctx) => {
137
71
  togglePlanMode();
138
72
  }
@@ -146,7 +80,7 @@ function planModeExtension(ctx) {
146
80
  ctx.on("tool:call", async (event) => {
147
81
  if (!planModeEnabled || event.toolName !== "bash") return;
148
82
  const command = event.args?.command;
149
- if (command && !isSafeCommand(command)) {
83
+ if (command && !isPlanModeSafeCommand(command)) {
150
84
  ctx.ui.notify(
151
85
  `Plan mode: Command blocked (not allowlisted). Use /plan to disable plan mode first.
152
86
  Command: ${command}`,
@@ -173,7 +107,7 @@ Command: ${command}`,
173
107
  const message = event.message;
174
108
  if (message?.role === "assistant" && Array.isArray(message.content)) {
175
109
  const text = message.content.filter((c) => c.type === "text").map((c) => c.text).join("\n");
176
- if (markCompletedSteps(text, todoItems) > 0) {
110
+ if (markCompletedPlanSteps(text, todoItems) > 0) {
177
111
  updateStatus();
178
112
  }
179
113
  }
@@ -187,7 +121,7 @@ Command: ${command}`,
187
121
  ${completedList}`, "info");
188
122
  executionMode = false;
189
123
  todoItems = [];
190
- ctx.setActiveTools(NORMAL_MODE_TOOLS);
124
+ ctx.setActiveTools(getNormalModeTools());
191
125
  }
192
126
  return;
193
127
  }
@@ -198,7 +132,7 @@ ${completedList}`, "info");
198
132
  );
199
133
  if (lastAssistant) {
200
134
  const text = lastAssistant.content.filter((c) => c.type === "text").map((c) => c.text).join("\n");
201
- const extracted = extractTodoItems(text);
135
+ const extracted = extractPlanTodoItems(text);
202
136
  if (extracted.length > 0) {
203
137
  todoItems = extracted;
204
138
  }
@@ -217,7 +151,7 @@ ${todoListText}`, "info");
217
151
  executionMode = todoItems.length > 0;
218
152
  ctx.setSessionMetadata(SESSION_METADATA_KEY, false);
219
153
  ctx.setPlanMode(false);
220
- ctx.setActiveTools(NORMAL_MODE_TOOLS);
154
+ ctx.setActiveTools(getNormalModeTools());
221
155
  updateStatus();
222
156
  const execMessage = todoItems.length > 0 ? `Execute the plan. Start with: ${todoItems[0].text}. Mark completed steps with [DONE:n] in your response.` : "Execute the plan you just created.";
223
157
  ctx.sendUserMessage(execMessage);
@@ -229,7 +163,6 @@ ${todoListText}`, "info");
229
163
  }
230
164
  }
231
165
  });
232
- ctx.ui.notify("\u23F8\uFE0F Plan mode extension loaded", "info");
233
166
  }
234
167
  export {
235
168
  planModeExtension as default