@cortexkit/opencode-magic-context 0.19.0 → 0.21.0

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 (103) hide show
  1. package/README.md +2 -2
  2. package/dist/config/index.d.ts +18 -0
  3. package/dist/config/index.d.ts.map +1 -1
  4. package/dist/features/magic-context/dreamer/lease.d.ts +1 -0
  5. package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
  6. package/dist/features/magic-context/dreamer/runner.d.ts.map +1 -1
  7. package/dist/features/magic-context/git-commits/indexer.d.ts +2 -3
  8. package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -1
  9. package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts +1 -0
  10. package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts.map +1 -1
  11. package/dist/features/magic-context/key-files/aft-availability.d.ts +11 -0
  12. package/dist/features/magic-context/key-files/aft-availability.d.ts.map +1 -0
  13. package/dist/features/magic-context/key-files/identify-key-files.d.ts +45 -0
  14. package/dist/features/magic-context/key-files/identify-key-files.d.ts.map +1 -1
  15. package/dist/features/magic-context/key-files/project-key-files.d.ts +42 -0
  16. package/dist/features/magic-context/key-files/project-key-files.d.ts.map +1 -0
  17. package/dist/features/magic-context/key-files/read-history.d.ts +26 -0
  18. package/dist/features/magic-context/key-files/read-history.d.ts.map +1 -0
  19. package/dist/features/magic-context/memory/embedding-backfill.d.ts +1 -0
  20. package/dist/features/magic-context/memory/embedding-backfill.d.ts.map +1 -1
  21. package/dist/features/magic-context/memory/embedding-local.d.ts +6 -0
  22. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  23. package/dist/features/magic-context/memory/embedding.d.ts +2 -0
  24. package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
  25. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +1 -0
  26. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -1
  27. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  28. package/dist/features/magic-context/overflow-detection.d.ts +1 -1
  29. package/dist/features/magic-context/project-embedding-registry.d.ts +44 -0
  30. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -0
  31. package/dist/features/magic-context/search.d.ts.map +1 -1
  32. package/dist/features/magic-context/sidekick/agent.d.ts.map +1 -1
  33. package/dist/features/magic-context/storage-db.d.ts +1 -0
  34. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  35. package/dist/features/magic-context/storage-meta-persisted.d.ts +56 -0
  36. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  37. package/dist/features/magic-context/storage-meta-shared.d.ts +2 -0
  38. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  39. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  40. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  41. package/dist/features/magic-context/storage.d.ts +1 -1
  42. package/dist/features/magic-context/storage.d.ts.map +1 -1
  43. package/dist/features/magic-context/types.d.ts +2 -0
  44. package/dist/features/magic-context/types.d.ts.map +1 -1
  45. package/dist/hooks/auto-update-checker/cache.d.ts.map +1 -1
  46. package/dist/hooks/magic-context/auto-search-runner.d.ts +6 -4
  47. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/boundary-execution.d.ts +24 -0
  49. package/dist/hooks/magic-context/boundary-execution.d.ts.map +1 -0
  50. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  51. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  52. package/dist/hooks/magic-context/compartment-runner-types.d.ts +1 -0
  53. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/event-handler.d.ts +4 -0
  55. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  56. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  57. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/key-files-block.d.ts +27 -0
  59. package/dist/hooks/magic-context/key-files-block.d.ts.map +1 -0
  60. package/dist/hooks/magic-context/note-nudger.d.ts +7 -1
  61. package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
  62. package/dist/hooks/magic-context/read-session-db.d.ts +2 -0
  63. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  64. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  65. package/dist/hooks/magic-context/text-complete.d.ts.map +1 -1
  66. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +1 -0
  67. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/transform-context-state.d.ts +5 -2
  69. package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
  70. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +2 -3
  71. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  72. package/dist/hooks/magic-context/transform.d.ts +4 -3
  73. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +2530 -1164
  76. package/dist/plugin/dream-timer.d.ts +5 -4
  77. package/dist/plugin/dream-timer.d.ts.map +1 -1
  78. package/dist/plugin/embedding-bootstrap-helpers.d.ts +35 -0
  79. package/dist/plugin/embedding-bootstrap-helpers.d.ts.map +1 -0
  80. package/dist/plugin/embedding-bootstrap.d.ts +3 -0
  81. package/dist/plugin/embedding-bootstrap.d.ts.map +1 -0
  82. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  83. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  84. package/dist/plugin/tool-registry.d.ts.map +1 -1
  85. package/dist/shared/models-dev-cache.d.ts +8 -7
  86. package/dist/shared/models-dev-cache.d.ts.map +1 -1
  87. package/dist/shared/rpc-types.d.ts +1 -0
  88. package/dist/shared/rpc-types.d.ts.map +1 -1
  89. package/dist/shared/transcript.d.ts +2 -2
  90. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  91. package/dist/tools/ctx-memory/types.d.ts +3 -2
  92. package/dist/tools/ctx-memory/types.d.ts.map +1 -1
  93. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  94. package/dist/tools/ctx-search/types.d.ts +3 -2
  95. package/dist/tools/ctx-search/types.d.ts.map +1 -1
  96. package/dist/tui/data/context-db.d.ts.map +1 -1
  97. package/package.json +2 -2
  98. package/src/shared/models-dev-cache.test.ts +5 -10
  99. package/src/shared/models-dev-cache.ts +15 -45
  100. package/src/shared/rpc-types.ts +1 -0
  101. package/src/shared/transcript.ts +2 -2
  102. package/src/tui/data/context-db.ts +1 -0
  103. package/src/tui/slots/sidebar-content.tsx +15 -1
@@ -1,4 +1,5 @@
1
- import type { DreamerConfig, EmbeddingConfig } from "../config/schema/magic-context";
1
+ import type { DreamerConfig } from "../config/schema/magic-context";
2
+ import type { Database } from "../shared/sqlite";
2
3
  import type { PluginContext } from "./types";
3
4
  /**
4
5
  * Per-project work registered with the timer. The timer is a process-wide
@@ -8,10 +9,9 @@ import type { PluginContext } from "./types";
8
9
  */
9
10
  interface ProjectRegistration {
10
11
  directory: string;
12
+ projectIdentity: string;
11
13
  client: PluginContext["client"];
12
14
  dreamerConfig?: DreamerConfig;
13
- embeddingConfig: EmbeddingConfig;
14
- memoryEnabled: boolean;
15
15
  experimentalUserMemories?: {
16
16
  enabled: boolean;
17
17
  promotionThreshold: number;
@@ -26,6 +26,7 @@ interface ProjectRegistration {
26
26
  since_days: number;
27
27
  max_commits: number;
28
28
  };
29
+ ensureRegistered: (directory: string, db: Database) => Promise<void>;
29
30
  }
30
31
  /**
31
32
  * Register the calling project with the process-wide dream + maintenance
@@ -38,6 +39,6 @@ interface ProjectRegistration {
38
39
  * Returns a cleanup that removes this project's registration. The timer
39
40
  * itself stops only when the last project unregisters.
40
41
  */
41
- export declare function startDreamScheduleTimer(args: ProjectRegistration): (() => void) | undefined;
42
+ export declare function startDreamScheduleTimer(args: ProjectRegistration): Promise<(() => void) | undefined>;
42
43
  export {};
43
44
  //# sourceMappingURL=dream-timer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dream-timer.d.ts","sourceRoot":"","sources":["../../src/plugin/dream-timer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAWrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAK7C;;;;;GAKG;AACH,UAAU,mBAAmB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,eAAe,EAAE,eAAe,CAAC;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,wBAAwB,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5E,uBAAuB,CAAC,EAAE;QACtB,OAAO,EAAE,OAAO,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,iBAAiB,CAAC,EAAE;QAChB,OAAO,EAAE,OAAO,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACvB,CAAC;CACL;AAQD;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAuD3F"}
1
+ {"version":3,"file":"dream-timer.d.ts","sourceRoot":"","sources":["../../src/plugin/dream-timer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAapE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAK7C;;;;;GAKG;AACH,UAAU,mBAAmB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,wBAAwB,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5E,uBAAuB,CAAC,EAAE;QACtB,OAAO,EAAE,OAAO,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,iBAAiB,CAAC,EAAE;QAChB,OAAO,EAAE,OAAO,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE;AAQD;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CACzC,IAAI,EAAE,mBAAmB,GAC1B,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC,CA0DnC"}
@@ -0,0 +1,35 @@
1
+ import type { EmbeddingConfig } from "../config/schema/magic-context";
2
+ import type { Database } from "../shared/sqlite";
3
+ export type LoadOutcome = "ok" | "project-file-parse-error" | "project-file-io-error" | "schema-recovery" | "substitution-failure";
4
+ export interface EmbeddingLoadResultDetailed<TConfig extends {
5
+ embedding: EmbeddingConfig;
6
+ }> {
7
+ config: TConfig;
8
+ loadOutcome: LoadOutcome;
9
+ sources: {
10
+ userConfig: LoadOutcome;
11
+ projectConfig: LoadOutcome;
12
+ };
13
+ substitutionFailures: Array<{
14
+ keyPath: string;
15
+ source: "user" | "project";
16
+ message: string;
17
+ }>;
18
+ recoveredTopLevelKeys: string[];
19
+ }
20
+ export declare const EMBEDDING_AFFECTING_KEYS: Set<string>;
21
+ export declare const EMBEDDING_AFFECTING_TOP_LEVEL_KEYS: Set<string>;
22
+ export declare function isConfigLoadUntrusted(detailed: EmbeddingLoadResultDetailed<{
23
+ embedding: EmbeddingConfig;
24
+ }>): boolean;
25
+ export declare function describeFailure(detailed: EmbeddingLoadResultDetailed<{
26
+ embedding: EmbeddingConfig;
27
+ }>): string;
28
+ export declare function logConfigFailureOnce(projectIdentity: string, detailed: EmbeddingLoadResultDetailed<{
29
+ embedding: EmbeddingConfig;
30
+ }>): void;
31
+ export declare function handleUntrustedLoad(db: Database, projectIdentity: string, directory: string, detailed: EmbeddingLoadResultDetailed<{
32
+ embedding: EmbeddingConfig;
33
+ }>): boolean;
34
+ export declare function _resetEmbeddingConfigFailureLogsForTests(): void;
35
+ //# sourceMappingURL=embedding-bootstrap-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embedding-bootstrap-helpers.d.ts","sourceRoot":"","sources":["../../src/plugin/embedding-bootstrap-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAMtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,WAAW,GACjB,IAAI,GACJ,0BAA0B,GAC1B,uBAAuB,GACvB,iBAAiB,GACjB,sBAAsB,CAAC;AAE7B,MAAM,WAAW,2BAA2B,CAAC,OAAO,SAAS;IAAE,SAAS,EAAE,eAAe,CAAA;CAAE;IACvF,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE;QACL,UAAU,EAAE,WAAW,CAAC;QACxB,aAAa,EAAE,WAAW,CAAC;KAC9B,CAAC;IACF,oBAAoB,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9F,qBAAqB,EAAE,MAAM,EAAE,CAAC;CACnC;AAED,eAAO,MAAM,wBAAwB,aAKnC,CAAC;AAEH,eAAO,MAAM,kCAAkC,aAAmD,CAAC;AAcnG,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,2BAA2B,CAAC;IAAE,SAAS,EAAE,eAAe,CAAA;CAAE,CAAC,GACtE,OAAO,CA0BT;AAED,wBAAgB,eAAe,CAC3B,QAAQ,EAAE,2BAA2B,CAAC;IAAE,SAAS,EAAE,eAAe,CAAA;CAAE,CAAC,GACtE,MAAM,CAkBR;AAED,wBAAgB,oBAAoB,CAChC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,2BAA2B,CAAC;IAAE,SAAS,EAAE,eAAe,CAAA;CAAE,CAAC,GACtE,IAAI,CAiBN;AAED,wBAAgB,mBAAmB,CAC/B,EAAE,EAAE,QAAQ,EACZ,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,2BAA2B,CAAC;IAAE,SAAS,EAAE,eAAe,CAAA;CAAE,CAAC,GACtE,OAAO,CAeT;AAED,wBAAgB,wCAAwC,IAAI,IAAI,CAE/D"}
@@ -0,0 +1,3 @@
1
+ import type { Database } from "../shared/sqlite";
2
+ export declare function ensureProjectRegisteredFromOpenCodeDirectory(directory: string, db: Database): Promise<void>;
3
+ //# sourceMappingURL=embedding-bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embedding-bootstrap.d.ts","sourceRoot":"","sources":["../../src/plugin/embedding-bootstrap.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,wBAAsB,4CAA4C,CAC9D,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,QAAQ,GACb,OAAO,CAAC,IAAI,CAAC,CAqBf"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAU7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;IACvC,gBAAgB,EAAE,gBAAgB,CAAC;CACtC;;;;;;qBAqDyvJ,CAAC;;;;;;;;;;;;qBAAh2C,CAAC;mBAAyB,CAAC;iBAAuB,CAAC;iBAAuB,CAAC;0BAAc,CAAC;uBAAiB,CAAC;;;;;;0BAAuttB,CAAC;;;;;;EAD9t0B"}
1
+ {"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAU7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;IACvC,gBAAgB,EAAE,gBAAgB,CAAC;CACtC;;;;;;qBAqDsjJ,CAAC;;;;;;;;;;;;qBAAvmC,CAAC;mBAAyB,CAAC;iBAAuB,CAAC;iBAAuB,CAAC;0BAAc,CAAC;uBAAiB,CAAC;;;;;;0BAA4utB,CAAC;;;;;;EADzy0B"}
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-handlers.d.ts","sourceRoot":"","sources":["../../src/plugin/rpc-handlers.ts"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ACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;CAC1C,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CA8GjC"}
1
+ {"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../src/plugin/tool-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAe1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;CAC1C,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAyEjC"}
@@ -15,8 +15,9 @@
15
15
  * code path that cannot reach the SDK client.
16
16
  *
17
17
  * The public getter (`getModelsDevContextLimit()`) is synchronous: it checks
18
- * the API cache first, then the file cache. The plugin warms and refreshes
19
- * the API cache from `src/index.ts` at startup and on a timer.
18
+ * the API cache first, then the file cache. The plugin warms the API cache
19
+ * once from `src/index.ts` at startup. Runtime retries are reserved for the
20
+ * issue #77 cache-regression recovery path.
20
21
  */
21
22
  interface OpencodeClientLike {
22
23
  config: {
@@ -30,11 +31,11 @@ interface OpencodeClientLike {
30
31
  /**
31
32
  * Asynchronously refresh the API-layer cache from OpenCode's SDK.
32
33
  *
33
- * Call this at plugin startup and periodically (e.g. every 5 minutes) from
34
- * `src/index.ts`. OpenCode's `/config/providers` endpoint returns every
35
- * provider with full model metadata — including `limit.context` — resolved
36
- * through the same path OpenCode itself uses (live cache + compiled-in
37
- * snapshot + opencode.json overrides + derived experimental modes).
34
+ * Call this at plugin startup and from the issue #77 regression-recovery path.
35
+ * OpenCode's `/config/providers` endpoint returns every provider with full
36
+ * model metadata — including `limit.context` — resolved through the same path
37
+ * OpenCode itself uses (live cache + compiled-in snapshot + opencode.json
38
+ * overrides + derived experimental modes).
38
39
  *
39
40
  * Safe to call concurrently; only overwrites the cache on success.
40
41
  */
@@ -1 +1 @@
1
- {"version":3,"file":"models-dev-cache.d.ts","sourceRoot":"","sources":["../../src/shared/models-dev-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAUH,UAAU,kBAAkB;IACxB,MAAM,EAAE;QACJ,SAAS,EAAE,MAAM,OAAO,CAAC;YAAE,IAAI,CAAC,EAAE;gBAAE,SAAS,CAAC,EAAE,OAAO,CAAA;aAAE,CAAA;SAAE,CAAC,CAAC;KAChE,CAAC;CACL;AA2MD;;;;;;;;;;GAUG;AACH,wBAAsB,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmEzF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAchG;AAED,4CAA4C;AAC5C,wBAAgB,mBAAmB,IAAI,IAAI,CAO1C;AAED,oDAAoD;AACpD,wBAAgB,sBAAsB,IAAI;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACrB,CAOA"}
1
+ {"version":3,"file":"models-dev-cache.d.ts","sourceRoot":"","sources":["../../src/shared/models-dev-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAUH,UAAU,kBAAkB;IACxB,MAAM,EAAE;QACJ,SAAS,EAAE,MAAM,OAAO,CAAC;YAAE,IAAI,CAAC,EAAE;gBAAE,SAAS,CAAC,EAAE,OAAO,CAAA;aAAE,CAAA;SAAE,CAAC,CAAC;KAChE,CAAC;CACL;AA+LD;;;;;;;;;;GAUG;AACH,wBAAsB,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkDzF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAchG;AAED,4CAA4C;AAC5C,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C;AAED,oDAAoD;AACpD,wBAAgB,sBAAsB,IAAI;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACrB,CAOA"}
@@ -6,6 +6,7 @@ export interface SidebarSnapshot {
6
6
  sessionId: string;
7
7
  usagePercentage: number;
8
8
  inputTokens: number;
9
+ contextLimit: number;
9
10
  systemPromptTokens: number;
10
11
  compartmentCount: number;
11
12
  factCount: number;
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-types.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,eAAe,EAAE,MAAM,GAAG,IAAI,CAA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CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,oBAAoB,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC9C;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,EAAE,MAAM,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,sBAAsB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
@@ -22,7 +22,7 @@
22
22
  * 3. Lets the shared transform code (tagging, stripping, drops)
23
23
  * operate on `TranscriptPart` interface instances without caring
24
24
  * whether they're wrapping `Part` from `@opencode-ai/sdk` or
25
- * `TextContent | ToolCall | ThinkingContent` from `@mariozechner/pi-ai`.
25
+ * `TextContent | ToolCall | ThinkingContent` from `@earendil-works/pi-ai`.
26
26
  *
27
27
  * What this interface deliberately does NOT do:
28
28
  *
@@ -169,7 +169,7 @@ export interface TranscriptMessage {
169
169
  * messages-transform.ts, Pi's context-event handler). The shared
170
170
  * transform code receives a Transcript and operates only through this
171
171
  * interface — it never imports from `@opencode-ai/sdk` or
172
- * `@mariozechner/pi-ai`.
172
+ * `@earendil-works/pi-ai`.
173
173
  */
174
174
  export interface Transcript {
175
175
  /** Ordered messages in the current pass. */
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-memory/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAsBhE,OAAO,EAIH,KAAK,iBAAiB,EACzB,MAAM,SAAS,CAAC;AA8djB,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-memory/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAyBhE,OAAO,EAIH,KAAK,iBAAiB,EACzB,MAAM,SAAS,CAAC;AA+djB,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
@@ -14,6 +14,7 @@ export interface CtxMemoryArgs {
14
14
  }
15
15
  export interface CtxMemoryToolDeps {
16
16
  db: Database;
17
+ ensureProjectRegistered?: (directory: string, db: Database) => Promise<void>;
17
18
  /**
18
19
  * Resolve the project identity for the active session's directory.
19
20
  *
@@ -26,8 +27,8 @@ export interface CtxMemoryToolDeps {
26
27
  * directory's project.
27
28
  */
28
29
  resolveProjectPath: (directory: string) => string;
29
- memoryEnabled: boolean;
30
- embeddingEnabled: boolean;
30
+ memoryEnabled?: boolean;
31
+ embeddingEnabled?: boolean;
31
32
  allowedActions?: CtxMemoryAction[];
32
33
  sourceType?: MemorySourceType;
33
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-memory/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,eAAO,MAAM,kBAAkB,8BAA+B,CAAC;AAE/D,eAAO,MAAM,0BAA0B,oEAM7B,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAC9B,EAAE,EAAE,QAAQ,CAAC;IACb;;;;;;;;;;OAUG;IACH,kBAAkB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IAClD,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,eAAe,EAAE,CAAC;IACnC,UAAU,CAAC,EAAE,gBAAgB,CAAC;CACjC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-memory/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,KAAK,EAA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"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-search/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAahE,OAAO,KAAK,EAAkC,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAiKjF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAI5F"}
@@ -11,6 +11,7 @@ export interface CtxSearchArgs {
11
11
  }
12
12
  export interface CtxSearchToolDeps {
13
13
  db: Database;
14
+ ensureProjectRegistered?: (directory: string, db: Database) => Promise<void>;
14
15
  /**
15
16
  * Resolve the project identity for the session's directory at call time.
16
17
  * See CtxMemoryToolDeps.resolveProjectPath for why this is a function:
@@ -18,8 +19,8 @@ export interface CtxSearchToolDeps {
18
19
  * session's working directory.
19
20
  */
20
21
  resolveProjectPath: (directory: string) => string;
21
- memoryEnabled: boolean;
22
- embeddingEnabled: boolean;
22
+ memoryEnabled?: boolean;
23
+ embeddingEnabled?: boolean;
23
24
  /** When true, ctx_search surfaces indexed git commits as a 3rd source. */
24
25
  gitCommitsEnabled?: boolean;
25
26
  /** Override message reader for testing (avoids opening OpenCode DB in CI). */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-search/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;iEAEiE;AACjE,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,GAAG,YAAY,CAAC;AAElE,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAC9B,EAAE,EAAE,QAAQ,CAAC;IACb;;;;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 {"version":3,"file":"context-db.d.ts","sourceRoot":"","sources":["../../../src/tui/data/context-db.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAA0B,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEpG,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AAc9C,2DAA2D;AAC3D,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAGrD;AAED,+BAA+B;AAC/B,wBAAgB,QAAQ,IAAI,IAAI,CAI/B;AAuFD,sDAAsD;AACtD,wBAAsB,mBAAmB,CACrC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,CAAC,CA4B1B;AAED,wDAAwD;AACxD,wBAAsB,gBAAgB,CAClC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,YAAY,CAAC,CA4CvB;AAED,qCAAqC;AACrC,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ5E;AAED,6CAA6C;AAC7C,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQvE;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,yDAAyD;AACzD,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAqBhE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "README.md"
30
30
  ],
31
31
  "scripts": {
32
- "build": "bun build src/index.ts --outdir dist --target node --format esm --external @opencode-ai/plugin --external @huggingface/transformers --external better-sqlite3 --external bun:sqlite && tsc --emitDeclarationOnly",
32
+ "build": "bun build src/index.ts --outdir dist --target node --format esm --external @opencode-ai/plugin --external @huggingface/transformers --external onnxruntime-web --external better-sqlite3 --external bun:sqlite && tsc --emitDeclarationOnly",
33
33
  "typecheck": "tsc --noEmit && tsc -p tsconfig.scripts.json",
34
34
  "test": "bun test",
35
35
  "lint": "biome check .",
@@ -299,11 +299,11 @@ describe("models-dev-cache", () => {
299
299
  expect(getModelsDevCacheState().apiLoaded).toBe(false);
300
300
  });
301
301
 
302
- test("suppresses repeated logs when API count oscillates between known sizes", async () => {
303
- // Simulates github-copilot's /models endpoint returning different model sets
304
- // between calls. We want first sighting of each new size to log, but once a
305
- // size has been seen before, further flips between known sizes should be
306
- // silent (with one "oscillating" notice).
302
+ test("repeated manual API refreshes replace cache state without corruption", async () => {
303
+ // Simulates the issue #77 recovery path manually retrying provider metadata
304
+ // after a bad cache value. Normal startup no longer schedules periodic
305
+ // refreshes, but explicit refresh calls should still replace cache state
306
+ // cleanly even when provider counts alternate.
307
307
  const sizeA = {
308
308
  data: {
309
309
  providers: [
@@ -335,23 +335,18 @@ describe("models-dev-cache", () => {
335
335
  const clientA = { config: { providers: async () => sizeA } };
336
336
  const clientB = { config: { providers: async () => sizeB } };
337
337
 
338
- // First sighting of size 3 → logs "loaded 3 entries".
339
338
  await refreshModelLimitsFromApi(clientA);
340
339
  expect(getModelsDevCacheState().apiCount).toBe(3);
341
340
 
342
- // First sighting of size 2 → logs "loaded 2 entries (was 3)".
343
341
  await refreshModelLimitsFromApi(clientB);
344
342
  expect(getModelsDevCacheState().apiCount).toBe(2);
345
343
 
346
- // Second sighting of size 3 → logs the "oscillating" notice once.
347
344
  await refreshModelLimitsFromApi(clientA);
348
345
  expect(getModelsDevCacheState().apiCount).toBe(3);
349
346
 
350
- // Second sighting of size 2 → silent (no new log expected).
351
347
  await refreshModelLimitsFromApi(clientB);
352
348
  expect(getModelsDevCacheState().apiCount).toBe(2);
353
349
 
354
- // Third sighting of size 3 → still silent.
355
350
  await refreshModelLimitsFromApi(clientA);
356
351
  expect(getModelsDevCacheState().apiCount).toBe(3);
357
352
 
@@ -15,8 +15,9 @@
15
15
  * code path that cannot reach the SDK client.
16
16
  *
17
17
  * The public getter (`getModelsDevContextLimit()`) is synchronous: it checks
18
- * the API cache first, then the file cache. The plugin warms and refreshes
19
- * the API cache from `src/index.ts` at startup and on a timer.
18
+ * the API cache first, then the file cache. The plugin warms the API cache
19
+ * once from `src/index.ts` at startup. Runtime retries are reserved for the
20
+ * issue #77 cache-regression recovery path.
20
21
  */
21
22
 
22
23
  import { createHash } from "node:crypto";
@@ -33,10 +34,9 @@ interface OpencodeClientLike {
33
34
  };
34
35
  }
35
36
 
36
- // File-cache fallback only. The primary `models.json` API refresh is driven
37
- // by `setInterval(refreshModelLimitsFromApi, ...)` in `index.ts` at a 1-hour
38
- // cadence; this 5-minute interval governs the on-disk-cache fallback path
39
- // when the API loader hasn't run yet (e.g. during plugin warmup).
37
+ // File-cache fallback only. The primary API refresh is one-shot at startup;
38
+ // this 5-minute interval governs the on-disk-cache fallback path when the API
39
+ // loader hasn't run yet (e.g. during plugin warmup).
40
40
  const RELOAD_INTERVAL_MS = 5 * 60 * 1000;
41
41
 
42
42
  interface CachedModelMetadata {
@@ -46,17 +46,6 @@ interface CachedModelMetadata {
46
46
  /** Populated async from OpenCode SDK. Primary source of truth when available. */
47
47
  let apiCache: Map<string, CachedModelMetadata> | null = null;
48
48
  let apiLoadedAt = 0;
49
- /**
50
- * Recently-seen API cache sizes, used to detect oscillation between two
51
- * stable values (typically caused by upstream provider plugins like
52
- * github-copilot whose `/models` endpoint returns slightly different model
53
- * sets between calls based on `model_picker_enabled` toggles). Once the
54
- * same size has been observed before, we stop logging count changes —
55
- * the count is a function of upstream behavior we can't control, and
56
- * repeated logs only add noise.
57
- */
58
- const recentlySeenApiSizes = new Set<number>();
59
- let oscillationLogged = false;
60
49
 
61
50
  /** Populated sync from disk as fallback. */
62
51
  let fileCache: Map<string, CachedModelMetadata> | null = null;
@@ -237,11 +226,11 @@ function loadModelsDevMetadataFromFile(): Map<string, CachedModelMetadata> {
237
226
  /**
238
227
  * Asynchronously refresh the API-layer cache from OpenCode's SDK.
239
228
  *
240
- * Call this at plugin startup and periodically (e.g. every 5 minutes) from
241
- * `src/index.ts`. OpenCode's `/config/providers` endpoint returns every
242
- * provider with full model metadata — including `limit.context` — resolved
243
- * through the same path OpenCode itself uses (live cache + compiled-in
244
- * snapshot + opencode.json overrides + derived experimental modes).
229
+ * Call this at plugin startup and from the issue #77 regression-recovery path.
230
+ * OpenCode's `/config/providers` endpoint returns every provider with full
231
+ * model metadata — including `limit.context` — resolved through the same path
232
+ * OpenCode itself uses (live cache + compiled-in snapshot + opencode.json
233
+ * overrides + derived experimental modes).
245
234
  *
246
235
  * Safe to call concurrently; only overwrites the cache on success.
247
236
  */
@@ -277,33 +266,16 @@ export async function refreshModelLimitsFromApi(client: OpencodeClientLike): Pro
277
266
  apiCache = map;
278
267
  apiLoadedAt = Date.now();
279
268
 
280
- // Log policy:
281
- // - Always log the first successful load.
282
- // - Log a count change once per new size we haven't seen before.
283
- // - When the count returns to a previously-seen size, log an
284
- // "oscillation" message exactly once explaining the cause, then
285
- // stay silent on further flips between known sizes.
286
269
  if (previousSize === null) {
287
- recentlySeenApiSizes.add(map.size);
288
270
  sessionLog(
289
271
  "global",
290
272
  `models-dev-cache: API layer loaded ${map.size} model metadata entries`,
291
273
  );
292
274
  } else if (previousSize !== map.size) {
293
- const sizeAlreadySeen = recentlySeenApiSizes.has(map.size);
294
- recentlySeenApiSizes.add(map.size);
295
- if (!sizeAlreadySeen) {
296
- sessionLog(
297
- "global",
298
- `models-dev-cache: API layer loaded ${map.size} model metadata entries (was ${previousSize})`,
299
- );
300
- } else if (!oscillationLogged) {
301
- oscillationLogged = true;
302
- sessionLog(
303
- "global",
304
- `models-dev-cache: API count oscillating between ${[...recentlySeenApiSizes].sort((a, b) => a - b).join(" ↔ ")} — likely upstream provider plugin returning slightly different model sets between calls (e.g. github-copilot's /models endpoint toggling model_picker_enabled). Suppressing further size-change logs.`,
305
- );
306
- }
275
+ sessionLog(
276
+ "global",
277
+ `models-dev-cache: API layer loaded ${map.size} model metadata entries (was ${previousSize})`,
278
+ );
307
279
  }
308
280
  } catch (error) {
309
281
  sessionLog(
@@ -345,8 +317,6 @@ export function getModelsDevContextLimit(providerID: string, modelID: string): n
345
317
  export function clearModelsDevCache(): void {
346
318
  apiCache = null;
347
319
  apiLoadedAt = 0;
348
- recentlySeenApiSizes.clear();
349
- oscillationLogged = false;
350
320
  fileCache = null;
351
321
  fileLastAttempt = 0;
352
322
  }
@@ -7,6 +7,7 @@ export interface SidebarSnapshot {
7
7
  sessionId: string;
8
8
  usagePercentage: number;
9
9
  inputTokens: number;
10
+ contextLimit: number;
10
11
  systemPromptTokens: number;
11
12
  compartmentCount: number;
12
13
  factCount: number;
@@ -22,7 +22,7 @@
22
22
  * 3. Lets the shared transform code (tagging, stripping, drops)
23
23
  * operate on `TranscriptPart` interface instances without caring
24
24
  * whether they're wrapping `Part` from `@opencode-ai/sdk` or
25
- * `TextContent | ToolCall | ThinkingContent` from `@mariozechner/pi-ai`.
25
+ * `TextContent | ToolCall | ThinkingContent` from `@earendil-works/pi-ai`.
26
26
  *
27
27
  * What this interface deliberately does NOT do:
28
28
  *
@@ -181,7 +181,7 @@ export interface TranscriptMessage {
181
181
  * messages-transform.ts, Pi's context-event handler). The shared
182
182
  * transform code receives a Transcript and operates only through this
183
183
  * interface — it never imports from `@opencode-ai/sdk` or
184
- * `@mariozechner/pi-ai`.
184
+ * `@earendil-works/pi-ai`.
185
185
  */
186
186
  export interface Transcript {
187
187
  /** Ordered messages in the current pass. */
@@ -38,6 +38,7 @@ const EMPTY_SNAPSHOT: SidebarSnapshot = {
38
38
  sessionId: "",
39
39
  usagePercentage: 0,
40
40
  inputTokens: 0,
41
+ contextLimit: 0,
41
42
  systemPromptTokens: 0,
42
43
  compartmentCount: 0,
43
44
  factCount: 0,
@@ -317,6 +317,12 @@ const SidebarContent = (props: {
317
317
  )
318
318
 
319
319
  const s = createMemo(() => snapshot())
320
+ const contextSummaryColor = createMemo(() => {
321
+ const usage = s()?.usagePercentage ?? 0
322
+ if (usage >= 80) return props.theme.error
323
+ if (usage >= 65) return props.theme.warning
324
+ return props.theme.accent
325
+ })
320
326
 
321
327
  return (
322
328
  <box
@@ -341,7 +347,15 @@ const SidebarContent = (props: {
341
347
 
342
348
  {/* Token breakdown bar */}
343
349
  {s() && s()!.inputTokens > 0 && (
344
- <box marginTop={1}>
350
+ <box marginTop={1} flexDirection="column">
351
+ {(s()?.contextLimit ?? 0) > 0 && (
352
+ <box width="100%" flexDirection="row" justifyContent="space-between">
353
+ <text fg={props.theme.textMuted}>Context</text>
354
+ <text fg={contextSummaryColor()}>
355
+ <b>{s()!.usagePercentage.toFixed(1)}%</b> · {compactTokens(s()!.inputTokens)} / {compactTokens(s()!.contextLimit)} tokens
356
+ </text>
357
+ </box>
358
+ )}
345
359
  <TokenBreakdown theme={props.theme} snapshot={s()!} />
346
360
  </box>
347
361
  )}