pi-ui-extend 0.1.28 → 0.1.31

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 (34) hide show
  1. package/dist/app/app.d.ts +2 -0
  2. package/dist/app/app.js +31 -8
  3. package/dist/app/cli/update.d.ts +5 -0
  4. package/dist/app/cli/update.js +29 -1
  5. package/dist/app/model/model-usage-status.d.ts +2 -0
  6. package/dist/app/model/model-usage-status.js +90 -20
  7. package/dist/app/session/session-event-controller.d.ts +17 -1
  8. package/dist/app/session/session-event-controller.js +28 -0
  9. package/dist/app/session/tabs-controller.d.ts +10 -0
  10. package/dist/app/session/tabs-controller.js +65 -28
  11. package/external/pi-tools-suite/package.json +0 -3
  12. package/external/pi-tools-suite/src/async-subagents/commands.ts +1 -1
  13. package/external/pi-tools-suite/src/async-subagents/core/tool-guard.ts +1 -1
  14. package/external/pi-tools-suite/src/async-subagents/index.ts +1 -1
  15. package/external/pi-tools-suite/src/async-subagents/render.ts +1 -1
  16. package/external/pi-tools-suite/src/async-subagents/tools/cleanup.ts +2 -2
  17. package/external/pi-tools-suite/src/async-subagents/tools/result.ts +2 -2
  18. package/external/pi-tools-suite/src/async-subagents/tools/spawn.ts +3 -3
  19. package/external/pi-tools-suite/src/async-subagents/tools/status.ts +3 -3
  20. package/external/pi-tools-suite/src/async-subagents/tools/stop.ts +2 -2
  21. package/external/pi-tools-suite/src/async-subagents/tools/subagents.ts +3 -3
  22. package/external/pi-tools-suite/src/async-subagents/tools/wait.ts +2 -2
  23. package/external/pi-tools-suite/src/async-subagents/ui.ts +1 -1
  24. package/external/pi-tools-suite/src/dcp/commands.ts +2 -2
  25. package/external/pi-tools-suite/src/dcp/compress-tool.ts +1 -1
  26. package/external/pi-tools-suite/src/dcp/index.ts +1 -1
  27. package/external/pi-tools-suite/src/lsp/constants.ts +1 -0
  28. package/external/pi-tools-suite/src/lsp/manager.ts +120 -71
  29. package/external/pi-tools-suite/src/model-tools/apply-patch.ts +1 -1
  30. package/external/pi-tools-suite/src/model-tools/index.ts +1 -1
  31. package/external/pi-tools-suite/src/todo/tool/response-envelope.ts +2 -2
  32. package/external/pi-tools-suite/src/tool-descriptions.ts +2 -2
  33. package/external/pi-tools-suite/src/usage/lib/google.ts +39 -4
  34. package/package.json +4 -7
@@ -250,10 +250,10 @@ export const TODO_TOOL_DESCRIPTION: ToolDescription = {
250
250
  name: "todo",
251
251
  label: "Todo",
252
252
  description: "Track and keep in sync non-trivial multi-step work as todos. Actions: create, update, batch_create, batch_update, list, get, delete, clear, export, import. Supports parent/subtask hierarchy, blockers, deferred out-of-scope items, dependencies, and replace:true on create/batch_create/import for intentionally replacing an obsolete plan; skip trivial or chat-only requests. Resynchronize the plan when requirements are added, canceled, or become obsolete, whether from user input or discovered facts. For multi-step plans, include a final user-facing report todo in the initial create/batch_create plan when possible. Keep exactly one task in_progress and complete it only after verification.",
253
- promptSnippet: "Track/sync non-trivial multi-step work; include final report item; resync when requirements change; keep one task in_progress",
253
+ promptSnippet: "Track/sync non-trivial multi-step work; include final report item and close it before sending the report; resync when requirements change; keep one task in_progress",
254
254
  promptGuidelines: [
255
255
  "Use `todo` for complex work with 3+ steps, explicit user task lists, or new non-trivial requirements. Skip single trivial tasks and purely conversational requests.",
256
- "For any multi-step implementation/debugging plan, include a final todo item in the initial create/batch_create plan for the user-facing final report. Treat it like any other todo item: as soon as that step is finished, mark it completed immediately. Give it explicit description/acceptance criteria covering changed files/behavior, verification commands/results, remaining manual actions, and never substitute a compression/housekeeping note for the final report.",
256
+ "For any multi-step implementation/debugging plan, include a final todo item in the initial create/batch_create plan for the user-facing final report. Give it explicit description/acceptance criteria covering changed files/behavior, verification commands/results, remaining manual actions, and never substitute a compression/housekeeping note for the final report. Close that report todo immediately before sending the final report to the user.",
257
257
  "When the user adds, removes, cancels, reprioritizes, or changes the goal, scope, requirements, constraints, or chosen approach, use `todo` before continuing to synchronize the plan: update still-relevant tasks, defer or delete obsolete tasks, add new required tasks, and adjust dependencies/order.",
258
258
  "When your own investigation or verification discovers new facts that make the current todo plan stale, incomplete, impossible, unsafe, or no longer the best approach, use `todo` to revise the plan immediately instead of following outdated tasks.",
259
259
  "Update todos as part of the workflow, not as end-of-task cleanup: whenever you start, finish, block, split, abandon, or materially change a step, call `todo` immediately before continuing.",
@@ -52,6 +52,7 @@ type PiAntigravityCredential = {
52
52
  type?: string;
53
53
  refresh?: string;
54
54
  email?: string;
55
+ activeIndex?: number;
55
56
  clientId?: string;
56
57
  clientSecret?: string;
57
58
  googleClientId?: string;
@@ -62,6 +63,8 @@ type PiAntigravityCredential = {
62
63
 
63
64
  type GoogleOAuthClientCredentials = { clientId: string; clientSecret?: string };
64
65
 
66
+ type PreparedAccount = AntigravityAccount & { originalIndex: number };
67
+
65
68
  // ============================================================================
66
69
  // 常量
67
70
  // ============================================================================
@@ -149,10 +152,10 @@ async function readAntigravityAccounts(): Promise<AntigravityAccount[]> {
149
152
 
150
153
  if (!credential) return [];
151
154
  const credentialClient = getGoogleOAuthClientCredentials(credential);
152
- const accounts = Array.isArray(credential.accounts)
155
+ const accounts: PreparedAccount[] = Array.isArray(credential.accounts)
153
156
  ? credential.accounts
154
157
  .filter((account) => getAccountRefreshToken(account))
155
- .map((account) => ({ ...credentialClient, ...account }))
158
+ .map((account, originalIndex) => ({ ...credentialClient, ...account, originalIndex }))
156
159
  : [];
157
160
  const primaryAccount =
158
161
  credential.type === "oauth" && credential.refresh
@@ -161,16 +164,48 @@ async function readAntigravityAccounts(): Promise<AntigravityAccount[]> {
161
164
  if (primaryAccount) {
162
165
  primaryAccount.email = credential.email;
163
166
  Object.assign(primaryAccount, credentialClient);
164
- accounts.unshift(primaryAccount);
167
+ const matchIndex = accounts.findIndex((account) =>
168
+ (primaryAccount.email && account.email === primaryAccount.email)
169
+ || (primaryAccount.refreshToken && getAccountRefreshToken(account) === primaryAccount.refreshToken),
170
+ );
171
+ if (matchIndex >= 0) {
172
+ accounts[matchIndex] = { ...accounts[matchIndex], ...primaryAccount };
173
+ } else {
174
+ accounts.unshift({ ...primaryAccount, originalIndex: -1 });
175
+ }
165
176
  }
166
177
 
167
178
  const seen = new Set<string>();
168
- return accounts.filter((account) => {
179
+ const deduped = accounts.filter((account) => {
169
180
  const key = account.email || account.refreshToken;
170
181
  if (!key || seen.has(key)) return false;
171
182
  seen.add(key);
172
183
  return true;
173
184
  });
185
+
186
+ const fallbackActiveIndex = deduped.findIndex((account) =>
187
+ (credential.email && account.email === credential.email)
188
+ || (primaryAccount?.refreshToken && getAccountRefreshToken(account) === primaryAccount.refreshToken),
189
+ );
190
+ const activeIndex = Number.isInteger(credential.activeIndex)
191
+ ? credential.activeIndex as number
192
+ : fallbackActiveIndex;
193
+ const mostRecentLastUsed = deduped.reduce(
194
+ (best, account, index) => (account.lastUsed > best.lastUsed ? { index, lastUsed: account.lastUsed } : best),
195
+ { index: -1, lastUsed: 0 },
196
+ ).index;
197
+ const priorityIndex = mostRecentLastUsed >= 0 ? mostRecentLastUsed : activeIndex;
198
+
199
+ return deduped
200
+ .map((account, index) => ({ account, index }))
201
+ .sort((a, b) => {
202
+ const aPriority = a.index === priorityIndex ? 1 : 0;
203
+ const bPriority = b.index === priorityIndex ? 1 : 0;
204
+ if (aPriority !== bPriority) return bPriority - aPriority;
205
+ if (a.account.lastUsed !== b.account.lastUsed) return b.account.lastUsed - a.account.lastUsed;
206
+ return a.account.originalIndex - b.account.originalIndex;
207
+ })
208
+ .map(({ account }) => account);
174
209
  } catch (error) {
175
210
  if ((error as NodeJS.ErrnoException).code === "ENOENT") return [];
176
211
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-ui-extend",
3
- "version": "0.1.28",
3
+ "version": "0.1.31",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -61,12 +61,9 @@
61
61
  "prepublishOnly": "npm run check && npm run build:pix && npm run generate-schemas"
62
62
  },
63
63
  "dependencies": {
64
- "@earendil-works/pi-tui": "0.79.1",
65
- "@earendil-works/pi-ai": "0.79.1",
66
- "@earendil-works/pi-coding-agent": "0.79.1",
67
- "@mariozechner/pi-ai": "npm:@earendil-works/pi-ai@0.79.1",
68
- "@mariozechner/pi-coding-agent": "npm:@earendil-works/pi-coding-agent@0.79.1",
69
- "@mariozechner/pi-tui": "npm:@earendil-works/pi-tui@0.79.1",
64
+ "@earendil-works/pi-ai": "0.79.3",
65
+ "@earendil-works/pi-coding-agent": "0.79.3",
66
+ "@earendil-works/pi-tui": "0.79.3",
70
67
  "@mariozechner/clipboard": "^0.3.9",
71
68
  "jsonc-parser": "3.3.1",
72
69
  "typebox": "1.1.38",