co-maintainer 0.4.12 → 0.4.13

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.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "co-maintainer",
3
- "version": "0.4.12",
3
+ "version": "0.4.13",
4
4
  "description": "Analyzes a GitHub repository and writes repository-specific contribution guidance.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -15,6 +15,7 @@ import { readState, writeState } from "../store/skill_state.js";
15
15
  import { cacheSet } from "../store/cache_db.js";
16
16
  import { log, timed, withLogSink } from "../util/log.js";
17
17
  import { enqueue, registerHandler } from "./jobs.js";
18
+ import { closeAppDb, isAppDbOpen, openAppDb } from "../store/app_db.js";
18
19
  import { getRepo, markKnowledgeBuilt } from "../store/repos.js";
19
20
  import { nowIso } from "../util/time.js";
20
21
  import { mkdir, readTextFile, remove } from "../util/runtime.js";
@@ -116,6 +117,18 @@ function addReviewLink(markdown, documents) {
116
117
  return `${markdown.trimEnd()}\n\n## Pull request review guides\n\n- Read [PR_REVIEW_GUIDE.md](PR_REVIEW_GUIDE.md).${detailedLink}\n`;
117
118
  }
118
119
  export async function runInitOrRemake(options) {
120
+ const openedAppDb = !isAppDbOpen();
121
+ if (openedAppDb)
122
+ await openAppDb();
123
+ try {
124
+ await initOrRemake(options);
125
+ }
126
+ finally {
127
+ if (openedAppDb)
128
+ await closeAppDb();
129
+ }
130
+ }
131
+ async function initOrRemake(options) {
119
132
  const operationStarted = performance.now();
120
133
  const aiMetrics = emptyAiMetrics();
121
134
  const previous = await readState(options.repo);
@@ -3,8 +3,10 @@ export declare function appDbDir(): string;
3
3
  /** `CM_APP_DB` overrides the path — tests point it at a temp file. */
4
4
  export declare function appDbPath(): string;
5
5
  export declare function releaseLock(): Promise<void>;
6
+ export declare function isAppDbOpen(): boolean;
6
7
  /** Opens (creating and migrating if needed) the single shared `app.db`
7
- * connection every store module reuses. Call once at `serve` startup. */
8
+ * connection every store module reuses. `serve` opens it for the process.
9
+ * `init` and `remake` open it for the run when it is not already open. */
8
10
  export declare function openAppDb(): Promise<Database>;
9
11
  export declare function getAppDb(): Database;
10
12
  export declare function closeAppDb(): Promise<void>;
@@ -59,8 +59,12 @@ function migrate(database) {
59
59
  }
60
60
  }
61
61
  let db;
62
+ export function isAppDbOpen() {
63
+ return db !== undefined;
64
+ }
62
65
  /** Opens (creating and migrating if needed) the single shared `app.db`
63
- * connection every store module reuses. Call once at `serve` startup. */
66
+ * connection every store module reuses. `serve` opens it for the process.
67
+ * `init` and `remake` open it for the run when it is not already open. */
64
68
  export async function openAppDb() {
65
69
  if (db)
66
70
  return db;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "co-maintainer",
3
- "version": "0.4.12",
3
+ "version": "0.4.13",
4
4
  "description": "Analyzes a GitHub repository and writes repository-specific contribution guidance.",
5
5
  "license": "MIT",
6
6
  "repository": {