kankaku 0.1.0 → 0.4.5

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/src/extension.ts CHANGED
@@ -2,7 +2,10 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  import { detectRole, loadConfig } from "./config.ts";
3
3
  import { WorkTracker } from "./domain/work-tracker.ts";
4
4
  import { LazyJsonlWorkLog } from "./adapters/lazy-jsonl-work-log.ts";
5
+ import { LazyFileInflightStore } from "./adapters/lazy-file-inflight-store.ts";
5
6
  import { createPiTracker } from "./adapters/pi-tracker.ts";
7
+ import { LazyProjectClientSource } from "./adapters/project-config.ts";
8
+ import { LazyExportWriter } from "./adapters/export-writer.ts";
6
9
 
7
10
  export default function kankaku(pi: ExtensionAPI): void {
8
11
  const config = loadConfig();
@@ -12,15 +15,24 @@ export default function kankaku(pi: ExtensionAPI): void {
12
15
  clock: { now: () => Date.now() },
13
16
  interactiveTools: config.interactiveTools,
14
17
  subagentTool: config.subagentTool,
18
+ segmentRules: config.segmentRules,
15
19
  });
16
20
 
17
21
  const log = new LazyJsonlWorkLog(config.dir);
22
+ const inflight = new LazyFileInflightStore(config.dir, process.pid);
23
+
24
+ const projectClient = new LazyProjectClientSource(config.dir);
25
+ const exportWriter = new LazyExportWriter(config.dir);
18
26
 
19
27
  createPiTracker(pi, {
20
28
  tracker,
21
29
  log,
30
+ inflight,
22
31
  role,
23
32
  pid: process.pid,
24
33
  parentPid: process.ppid,
34
+ ...(config.client !== undefined ? { envClient: config.client } : {}),
35
+ resolveProjectClient: () => projectClient.read(),
36
+ writeExportFile: (name, content) => exportWriter.write(name, content),
25
37
  });
26
38
  }
@@ -0,0 +1,16 @@
1
+ import type { WorkRecord } from "../domain/work-record.ts";
2
+
3
+ /**
4
+ * Crash-recovery checkpoint store: one process periodically saves the
5
+ * record its {@link WorkTracker} would produce right now, so a hard crash
6
+ * (kill -9, power loss) still leaves a record behind — recovered as
7
+ * `interrupted` on the next pi start rather than lost entirely.
8
+ */
9
+ export interface InflightStore {
10
+ /** Upsert this process's checkpoint. */
11
+ save(record: WorkRecord): void;
12
+ /** Remove this process's checkpoint (normal settle/shutdown). */
13
+ clear(): void;
14
+ /** Return and delete every checkpoint whose owning pid is no longer alive. */
15
+ recoverStale(isAlive: (pid: number) => boolean): WorkRecord[];
16
+ }