@getpochi/cli 0.5.69 → 0.5.70

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 (2) hide show
  1. package/dist/cli.js +75 -20
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -373774,7 +373774,7 @@ var {
373774
373774
  // package.json
373775
373775
  var package_default = {
373776
373776
  name: "@getpochi/cli",
373777
- version: "0.5.69",
373777
+ version: "0.5.70",
373778
373778
  type: "module",
373779
373779
  bin: {
373780
373780
  pochi: "src/cli.ts"
@@ -385428,6 +385428,41 @@ async function parseWorkflowFrontmatter(content3) {
385428
385428
  model: frontmatterData.model
385429
385429
  };
385430
385430
  }
385431
+ // ../common/src/tool-utils/notebook-utils.ts
385432
+ function validateNotebookPath(filePath) {
385433
+ if (!filePath.endsWith(".ipynb")) {
385434
+ throw new Error("File must be a Jupyter notebook (.ipynb)");
385435
+ }
385436
+ }
385437
+ function validateNotebookStructure(notebook) {
385438
+ if (!notebook || typeof notebook !== "object" || !("cells" in notebook) || !Array.isArray(notebook.cells)) {
385439
+ throw new Error("Invalid notebook format: no cells array found");
385440
+ }
385441
+ }
385442
+ function parseNotebook(content3) {
385443
+ const notebook = JSON.parse(content3);
385444
+ validateNotebookStructure(notebook);
385445
+ return notebook;
385446
+ }
385447
+ function editNotebookCell(notebook, cellId, newContent) {
385448
+ let cellFound = false;
385449
+ for (let i6 = 0;i6 < notebook.cells.length; i6++) {
385450
+ const cell = notebook.cells[i6];
385451
+ const currentCellId = cell.id;
385452
+ if (currentCellId === cellId || i6.toString() === cellId) {
385453
+ notebook.cells[i6].source = newContent;
385454
+ cellFound = true;
385455
+ break;
385456
+ }
385457
+ }
385458
+ if (!cellFound) {
385459
+ throw new Error(`Cell with ID "${cellId}" not found in notebook`);
385460
+ }
385461
+ return notebook;
385462
+ }
385463
+ function serializeNotebook(notebook) {
385464
+ return JSON.stringify(notebook, null, 2);
385465
+ }
385431
385466
  // src/lib/load-agents.ts
385432
385467
  var logger15 = getLogger("loadAgents");
385433
385468
  async function readAgentsFromDir(dir2) {
@@ -402099,7 +402134,7 @@ async function fetchTools() {
402099
402134
  }
402100
402135
 
402101
402136
  // src/mcp/initializer.ts
402102
- async function initializeMcp() {
402137
+ async function initializeMcp(program5) {
402103
402138
  const mcpHub = await createCliMcpHub();
402104
402139
  if (Object.keys(mcpHub.status.value.connections).length === 0) {
402105
402140
  return;
@@ -402112,10 +402147,12 @@ async function initializeMcp() {
402112
402147
  const connections = Object.values(status3.connections);
402113
402148
  const readyConnections = connections.filter((conn) => conn.status === "ready").length;
402114
402149
  const errorConnections = connections.filter((conn) => conn.status === "error").length;
402115
- if (connections.length > 0) {
402116
- if (readyConnections + errorConnections >= connections.length) {
402117
- break;
402118
- }
402150
+ if (errorConnections > 0) {
402151
+ spinner.fail(`Failed to initialize MCP connections after ${attempts} attempts.`);
402152
+ return program5.error("MCP initialization failed");
402153
+ }
402154
+ if (readyConnections >= connections.length) {
402155
+ break;
402119
402156
  }
402120
402157
  await new Promise((resolve11) => setTimeout(resolve11, 500));
402121
402158
  attempts++;
@@ -417483,6 +417520,23 @@ var applyDiff2 = () => async ({ path: path27, searchContent, replaceContent, exp
417483
417520
  return { success: true };
417484
417521
  };
417485
417522
 
417523
+ // src/tools/edit-notebook.ts
417524
+ import * as fs13 from "node:fs/promises";
417525
+ var editNotebook2 = () => async ({ path: filePath, cellId, content: content3 }, { cwd: cwd2 }) => {
417526
+ try {
417527
+ const absolutePath = resolvePath(filePath, cwd2);
417528
+ validateNotebookPath(absolutePath);
417529
+ const fileContent3 = await fs13.readFile(absolutePath, "utf-8");
417530
+ const notebook = parseNotebook(fileContent3);
417531
+ const updatedNotebook = editNotebookCell(notebook, cellId, content3);
417532
+ const serialized = serializeNotebook(updatedNotebook);
417533
+ await fs13.writeFile(absolutePath, serialized, "utf-8");
417534
+ return { success: true };
417535
+ } catch (error46) {
417536
+ return { success: false };
417537
+ }
417538
+ };
417539
+
417486
417540
  // src/tools/execute-command.ts
417487
417541
  import {
417488
417542
  exec as exec8
@@ -417589,15 +417643,15 @@ var listFiles3 = () => async ({ path: dirPath, recursive }, { abortSignal, cwd:
417589
417643
  };
417590
417644
 
417591
417645
  // src/tools/multi-apply-diff.ts
417592
- import * as fs13 from "node:fs/promises";
417646
+ import * as fs14 from "node:fs/promises";
417593
417647
  var multiApplyDiff2 = () => async ({ path: path28, edits }, { cwd: cwd2 }) => {
417594
417648
  const fileUri = resolvePath(path28, cwd2);
417595
417649
  await ensureFileDirectoryExists(fileUri);
417596
- const fileBuffer = await fs13.readFile(fileUri);
417650
+ const fileBuffer = await fs14.readFile(fileUri);
417597
417651
  validateTextFile(fileBuffer);
417598
417652
  const fileContent3 = fileBuffer.toString();
417599
417653
  const updatedContent = await processMultipleDiffs(fileContent3, edits);
417600
- await fs13.writeFile(fileUri, updatedContent);
417654
+ await fs14.writeFile(fileUri, updatedContent);
417601
417655
  return { success: true };
417602
417656
  };
417603
417657
 
@@ -417635,10 +417689,10 @@ var newTask = (options6) => async ({ _meta, agentType }) => {
417635
417689
  };
417636
417690
 
417637
417691
  // src/tools/read-file.ts
417638
- import * as fs14 from "node:fs/promises";
417639
- var readFile13 = () => async ({ path: path28, startLine, endLine }, { cwd: cwd2 }) => {
417692
+ import * as fs15 from "node:fs/promises";
417693
+ var readFile14 = () => async ({ path: path28, startLine, endLine }, { cwd: cwd2 }) => {
417640
417694
  const resolvedPath = resolvePath(path28, cwd2);
417641
- const fileBuffer = await fs14.readFile(resolvedPath);
417695
+ const fileBuffer = await fs15.readFile(resolvedPath);
417642
417696
  validateTextFile(fileBuffer);
417643
417697
  const fileContent3 = fileBuffer.toString();
417644
417698
  const addLineNumbers = !!process.env.VSCODE_TEST_OPTIONS;
@@ -417650,11 +417704,11 @@ var readFile13 = () => async ({ path: path28, startLine, endLine }, { cwd: cwd2
417650
417704
  };
417651
417705
 
417652
417706
  // src/tools/search-files.ts
417653
- import * as fs15 from "node:fs";
417707
+ import * as fs16 from "node:fs";
417654
417708
  var logger25 = getLogger("searchFiles");
417655
417709
  var searchFiles2 = (context15) => async ({ path: path28, regex: regex3, filePattern }, { abortSignal, cwd: cwd2 }) => {
417656
417710
  const rgPath = context15.rg;
417657
- if (!rgPath || !fs15.existsSync(rgPath)) {
417711
+ if (!rgPath || !fs16.existsSync(rgPath)) {
417658
417712
  logger25.error("Ripgrep not found at path", rgPath);
417659
417713
  throw new Error(`Ripgrep not found at path: ${rgPath}`);
417660
417714
  }
@@ -417669,23 +417723,24 @@ var todoWrite2 = (_options) => async () => {
417669
417723
  };
417670
417724
 
417671
417725
  // src/tools/write-to-file.ts
417672
- import * as fs16 from "node:fs/promises";
417726
+ import * as fs17 from "node:fs/promises";
417673
417727
  import * as nodePath from "node:path";
417674
417728
  var writeToFile2 = () => async ({ path: path28, content: content3 }, { cwd: cwd2 }) => {
417675
417729
  const filePath = resolvePath(path28, cwd2);
417676
417730
  if (!await isFileExists(filePath)) {
417677
417731
  const dirPath = nodePath.dirname(filePath);
417678
- await fs16.mkdir(dirPath, { recursive: true });
417732
+ await fs17.mkdir(dirPath, { recursive: true });
417679
417733
  }
417680
417734
  const processedContent = fixCodeGenerationOutput(content3);
417681
- await fs16.writeFile(filePath, processedContent);
417735
+ await fs17.writeFile(filePath, processedContent);
417682
417736
  return { success: true };
417683
417737
  };
417684
417738
 
417685
417739
  // src/tools/index.ts
417686
417740
  var ToolMap = {
417687
- readFile: readFile13,
417741
+ readFile: readFile14,
417688
417742
  applyDiff: applyDiff2,
417743
+ editNotebook: editNotebook2,
417689
417744
  globFiles: globFiles3,
417690
417745
  listFiles: listFiles3,
417691
417746
  multiApplyDiff: multiApplyDiff2,
@@ -418247,7 +418302,7 @@ var program5 = new Command().name("pochi").description(`${source_default.bold("P
418247
418302
  renderer.renderSubTask(runner2);
418248
418303
  };
418249
418304
  const customAgents = await loadAgents(process.cwd());
418250
- const mcpHub = options6.mcp ? await initializeMcp() : undefined;
418305
+ const mcpHub = options6.mcp ? await initializeMcp(program5) : undefined;
418251
418306
  const runner = new TaskRunner({
418252
418307
  uid,
418253
418308
  store,
@@ -418277,7 +418332,7 @@ var program5 = new Command().name("pochi").description(`${source_default.bold("P
418277
418332
  var otherOptionsGroup = "Others:";
418278
418333
  program5.optionsGroup(otherOptionsGroup).version(package_default.version, "-V, --version", "Print the version string.").addHelpOption(new Option3("-h, --help", "Print this help message.").helpGroup(otherOptionsGroup)).configureHelp({
418279
418334
  styleTitle: (title) => source_default.bold(title)
418280
- }).showHelpAfterError().showSuggestionAfterError().configureOutput({
418335
+ }).showSuggestionAfterError().configureOutput({
418281
418336
  outputError: (str, write5) => write5(source_default.red(str))
418282
418337
  });
418283
418338
  program5.hook("preAction", async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpochi/cli",
3
- "version": "0.5.69",
3
+ "version": "0.5.70",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "pochi": "dist/cli.js"