autodev-cli 1.4.109 → 1.4.111

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.
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ // ---------------------------------------------------------------------------
3
+ // Global (cross-workspace) session discovery + transcript reading across ALL
4
+ // providers (claude, grok, opencode, copilot). Unlike collectSessions() — which
5
+ // is scoped to one workspace root — this surfaces every session on the machine
6
+ // with its own cwd, so a UI (the autodev-app Sessions tab) can list and read
7
+ // them regardless of where they were started. Single source of truth: the app
8
+ // shells to `autodev sessions --all --json` and `autodev session-show`.
9
+ //
10
+ // Read-only and resilient: any missing store degrades to []; nothing throws.
11
+ // ---------------------------------------------------------------------------
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.normalizeSessionProvider = normalizeSessionProvider;
14
+ exports.collectAllSessions = collectAllSessions;
15
+ exports.readSessionTranscript = readSessionTranscript;
16
+ const claudeCliProvider_1 = require("./providers/claudeCliProvider");
17
+ const grokSessions_1 = require("./providers/grokSessions");
18
+ const opencodeDb_1 = require("./agentBackup/opencodeDb");
19
+ const copilotSessions_1 = require("./providers/copilotSessions");
20
+ /** Map a `--provider` family string onto a canonical SessionProvider, or
21
+ * undefined for "all". Accepts the fine-grained ids too (grok-tui → grok). */
22
+ function normalizeSessionProvider(p) {
23
+ if (!p) {
24
+ return undefined;
25
+ }
26
+ const s = p.toLowerCase();
27
+ if (s.startsWith('claude')) {
28
+ return 'claude';
29
+ }
30
+ if (s.startsWith('grok')) {
31
+ return 'grok';
32
+ }
33
+ if (s.startsWith('opencode')) {
34
+ return 'opencode';
35
+ }
36
+ if (s.startsWith('copilot')) {
37
+ return 'copilot';
38
+ }
39
+ return undefined;
40
+ }
41
+ /** List sessions across ALL workspaces for every provider (or one family when
42
+ * `provider` is given), newest first. */
43
+ function collectAllSessions(provider) {
44
+ const out = [];
45
+ const want = (p) => !provider || provider === p;
46
+ if (want('claude')) {
47
+ for (const s of (0, claudeCliProvider_1.listAllClaudeSessions)()) {
48
+ out.push({ provider: 'claude', id: s.id, name: s.name, cwd: s.cwd, updated: s.updated, file: s.file, msgs: s.msgs });
49
+ }
50
+ }
51
+ if (want('grok')) {
52
+ for (const s of (0, grokSessions_1.listAllGrokSessions)()) {
53
+ out.push({ provider: 'grok', id: s.id, name: s.title || '(untitled)', cwd: s.cwd, updated: s.updated });
54
+ }
55
+ }
56
+ if (want('opencode')) {
57
+ for (const s of (0, opencodeDb_1.listAllOpenCodeSessions)()) {
58
+ out.push({ provider: 'opencode', id: s.id, name: s.title || '(untitled)', cwd: s.cwd, updated: s.updated });
59
+ }
60
+ }
61
+ if (want('copilot')) {
62
+ for (const s of (0, copilotSessions_1.listAllCopilotSessions)()) {
63
+ out.push({ provider: 'copilot', id: s.id, name: s.name, cwd: s.cwd, updated: s.updated });
64
+ }
65
+ }
66
+ return out.sort((a, b) => b.updated - a.updated);
67
+ }
68
+ /** Read a session's transcript as a normalized message array. `file`/`cwd` are
69
+ * optional hints that let claude/grok resolve the store faster. Capped at
70
+ * `limit` (default 400) messages. */
71
+ function readSessionTranscript(provider, id, opts = {}) {
72
+ const limit = opts.limit ?? 400;
73
+ switch (provider) {
74
+ case 'claude': return (0, claudeCliProvider_1.readClaudeTranscript)(id, opts.file, limit);
75
+ case 'grok': return (0, grokSessions_1.readGrokTranscript)(id, opts.cwd, limit);
76
+ case 'opencode': return (0, opencodeDb_1.readOpenCodeTranscript)(id, limit);
77
+ case 'copilot': return (0, copilotSessions_1.readCopilotTranscript)(id, limit);
78
+ default: return [];
79
+ }
80
+ }
81
+ //# sourceMappingURL=sessionsGlobal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionsGlobal.js","sourceRoot":"","sources":["../src/sessionsGlobal.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAC/E,6EAA6E;AAC7E,8EAA8E;AAC9E,wEAAwE;AACxE,EAAE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AAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;AACnD,CAAC;AAED;;sCAEsC;AACtC,SAAgB,qBAAqB,CACnC,QAAyB,EACzB,EAAU,EACV,OAAwD,EAAE;IAE1D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC;IAChC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ,CAAC,CAAG,OAAO,IAAA,wCAAoB,EAAC,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACnE,KAAK,MAAM,CAAC,CAAK,OAAO,IAAA,iCAAkB,EAAC,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAChE,KAAK,UAAU,CAAC,CAAC,OAAO,IAAA,mCAAsB,EAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAC1D,KAAK,SAAS,CAAC,CAAE,OAAO,IAAA,uCAAqB,EAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACzD,OAAO,CAAC,CAAS,OAAO,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC"}
package/out/taskLoop.js CHANGED
@@ -449,6 +449,29 @@ class TaskLoopRunner {
449
449
  this._setState('idle');
450
450
  return;
451
451
  }
452
+ // Loop agents default to resumeSession=true. A continuous loop wants ONE
453
+ // evolving session; running with resume off makes every turn start a fresh
454
+ // provider session. For opencode especially that means a brand-new row in the
455
+ // shared opencode.db each turn — an autonomous loop silently accumulated
456
+ // 55k+ throwaway sessions (660 MB) this way. resumeSession defaults to false
457
+ // (fine for one-shot `send`), so here — at loop start only — we flip it to
458
+ // true UNLESS the user set it explicitly (an explicit `false` is honored, so
459
+ // a deliberately-stateless loop still works). Persisted so the per-turn
460
+ // dispatcher reload (loadSettingsForRoot reads disk) sees it. grok-cli/grok-tui
461
+ // keep their own forced statelessness/resume in the dispatcher regardless.
462
+ if (!(0, settingsLoader_1.hasExplicitSetting)(root, 'resumeSession')) {
463
+ settings.resumeSession = true;
464
+ try {
465
+ const file = (0, settingsLoader_1.settingsWritePath)(root);
466
+ const onDisk = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : {};
467
+ if (onDisk.resumeSession !== true) {
468
+ onDisk.resumeSession = true;
469
+ fs.writeFileSync(file, JSON.stringify(onDisk, null, 2) + '\n', 'utf8');
470
+ callbacks.log('🔁 Loop mode: defaulting resumeSession=true (one evolving session; set it false in settings to run stateless).');
471
+ }
472
+ }
473
+ catch { /* non-fatal: in-memory default still applies for this run */ }
474
+ }
452
475
  this._settings = settings;
453
476
  this._workspaceRoot = root;
454
477
  this._completedCount = 0;