loopgraph 0.2.0 → 0.2.1

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.
@@ -1,4 +1,4 @@
1
- import type { ImplementationFact, SignalKind } from "../../adapters/agenthub/extract.js";
1
+ import type { Adapter, ImplementationFact, SignalKind } from "../../adapters/types.js";
2
2
  import { type Inv1CheckResult } from "../../validate/inv1/check.js";
3
3
  import type { T0Result } from "../../validate/types.js";
4
4
  export declare const SNAPSHOT_SCHEMA_VERSION: 1;
@@ -98,6 +98,8 @@ export interface SnapshotOptions {
98
98
  repoRoot?: string | undefined;
99
99
  /** Machine cache dir for facts (B3); null disables. Default: the shared cache. */
100
100
  cacheDir?: string | null | undefined;
101
+ /** The adapter supplying the facts (default: agenthub). Threaded to runFacts. */
102
+ adapter?: Adapter | undefined;
101
103
  /** Injected for reproducibility; defaults to now. */
102
104
  generatedAt?: string | undefined;
103
105
  /** Injected for tests; defaults to `git rev-parse HEAD` of repoRoot. */
Binary file
package/dist/cli/run.js CHANGED
@@ -48,6 +48,27 @@ function readStringFlag(flags, name) {
48
48
  return { value: raw };
49
49
  return { value: undefined, error: `--${name} requires a value` };
50
50
  }
51
+ /**
52
+ * Resolve `--adapter <name>` for the fact-extracting commands (facts /
53
+ * reconcile / snapshot). Returns `{}` (no `adapter` key) when the flag is absent
54
+ * — the caller then falls back to the default adapter — or `{ error: true }`
55
+ * after reporting a malformed flag / unknown adapter name.
56
+ */
57
+ function resolveAdapterFlag(flags, io) {
58
+ const f = readStringFlag(flags, "adapter");
59
+ if (f.error) {
60
+ io.error(`${f.error}. ${USAGE}`);
61
+ return { error: true };
62
+ }
63
+ if (f.value === undefined)
64
+ return {}; // no --adapter → caller uses the default
65
+ const adapter = getAdapter(f.value);
66
+ if (!adapter) {
67
+ io.error(`unknown adapter "${f.value}" (available: ${adapterNames().join(", ")})`);
68
+ return { error: true };
69
+ }
70
+ return { adapter };
71
+ }
51
72
  /**
52
73
  * Core dispatch, factored out of the process entry point so tests can
53
74
  * drive it in-process (real filesystem via temp dirs, no subprocess
@@ -217,22 +238,12 @@ export async function run(argv, io) {
217
238
  // root, defaulting to cwd). `--no-cache` disables the B3 content cache.
218
239
  // `--adapter <name>` selects the target stack's adapter (default agenthub).
219
240
  const repo = positionals[0] ?? process.cwd();
220
- const adapterFlag = readStringFlag(flags, "adapter");
221
- if (adapterFlag.error) {
222
- io.error(`${adapterFlag.error}. ${USAGE}`);
241
+ const factsAdapter = resolveAdapterFlag(flags, io);
242
+ if ("error" in factsAdapter)
223
243
  return 1;
224
- }
225
- let adapter;
226
- if (adapterFlag.value !== undefined) {
227
- adapter = getAdapter(adapterFlag.value);
228
- if (!adapter) {
229
- io.error(`unknown adapter "${adapterFlag.value}" (available: ${adapterNames().join(", ")})`);
230
- return 1;
231
- }
232
- }
233
244
  const result = await runFacts(repo, {
234
245
  ...(flags["no-cache"] === true ? { cacheDir: null } : {}),
235
- ...(adapter ? { adapter } : {}),
246
+ ...(factsAdapter.adapter ? { adapter: factsAdapter.adapter } : {}),
236
247
  });
237
248
  if (!result.ran) {
238
249
  io.log(`⚠ facts extraction skipped: ${result.skippedReason}`);
@@ -264,8 +275,14 @@ export async function run(argv, io) {
264
275
  io.error(`reconcile needs --repo-root <repo>. ${USAGE}`);
265
276
  return 1;
266
277
  }
278
+ const reconcileAdapter = resolveAdapterFlag(flags, io);
279
+ if ("error" in reconcileAdapter)
280
+ return 1;
267
281
  const model = await loadModel(`${targetDir}/model`);
268
- const factsResult = await runFacts(repoRootFlag.value, flags["no-cache"] === true ? { cacheDir: null } : {});
282
+ const factsResult = await runFacts(repoRootFlag.value, {
283
+ ...(flags["no-cache"] === true ? { cacheDir: null } : {}),
284
+ ...(reconcileAdapter.adapter ? { adapter: reconcileAdapter.adapter } : {}),
285
+ });
269
286
  if (!factsResult.ran) {
270
287
  io.log(`⚠ reconcile skipped: ${factsResult.skippedReason}`);
271
288
  return 0;
@@ -297,9 +314,13 @@ export async function run(argv, io) {
297
314
  return 1;
298
315
  }
299
316
  }
317
+ const snapshotAdapter = resolveAdapterFlag(flags, io);
318
+ if ("error" in snapshotAdapter)
319
+ return 1;
300
320
  const snapshot = await runSnapshot(targetDir, {
301
321
  repoRoot: repoRootFlag.value,
302
322
  ...(flags["no-cache"] === true ? { cacheDir: null } : {}),
323
+ ...(snapshotAdapter.adapter ? { adapter: snapshotAdapter.adapter } : {}),
303
324
  });
304
325
  io.log(renderSnapshotSummary(snapshot));
305
326
  if (driftFlag.value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopgraph",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Model-driven engineering control system: behavioral model as spec source of truth, code/tests/observability as projections and evidence.",
5
5
  "type": "module",
6
6
  "license": "MIT",