pi-context 1.1.3 → 1.1.4

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/package.json +2 -2
  2. package/src/index.ts +10 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-context",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Agentic Context Management for the Pi",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "devDependencies": {
26
26
  "@sinclair/typebox": "^0.34.13",
27
27
  "typescript": "^5.7.2",
28
- "@mariozechner/pi-coding-agent": "latest"
28
+ "@earendil-works/pi-coding-agent": "latest"
29
29
  },
30
30
  "pi": {
31
31
  "extensions": [
package/src/index.ts CHANGED
@@ -82,11 +82,18 @@ export default function (pi: ExtensionAPI) {
82
82
  });
83
83
 
84
84
  // Helper: Check if a tag name already exists in the tree
85
+ // Iterative DFS to avoid call stack overflows on deep histories.
86
+ // Push children in reverse order to preserve left-to-right pre-order semantics.
85
87
  const findTagInTree = (sm: SessionManager, nodes: SessionTreeNode[], tagName: string): string | null => {
86
- for (const n of nodes) {
88
+ const stack: SessionTreeNode[] = [...nodes].reverse();
89
+ while (stack.length > 0) {
90
+ const n = stack.pop()!;
87
91
  if (sm.getLabel(n.entry.id) === tagName) return n.entry.id;
88
- const r = findTagInTree(sm, n.children, tagName);
89
- if (r) return r;
92
+ if (n.children?.length) {
93
+ for (let i = n.children.length - 1; i >= 0; i--) {
94
+ stack.push(n.children[i]);
95
+ }
96
+ }
90
97
  }
91
98
  return null;
92
99
  };