@productbrain/cli 0.1.0-beta.71 → 0.1.0-beta.72

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 (80) hide show
  1. package/dist/__tests__/audit.test.js +44 -44
  2. package/dist/__tests__/capture.test.js +37 -37
  3. package/dist/__tests__/constellation.test.js +14 -14
  4. package/dist/__tests__/context-strategy.test.js +8 -8
  5. package/dist/__tests__/fields.test.js +20 -20
  6. package/dist/__tests__/ingest.test.js +28 -28
  7. package/dist/__tests__/orient.test.js +8 -8
  8. package/dist/__tests__/promote.test.js +15 -15
  9. package/dist/__tests__/proposals.test.js +18 -18
  10. package/dist/__tests__/relate.test.js +14 -14
  11. package/dist/__tests__/session-touch.test.js +11 -11
  12. package/dist/__tests__/session.test.js +2 -2
  13. package/dist/__tests__/setup.test.js +7 -7
  14. package/dist/__tests__/update.test.js +21 -21
  15. package/dist/__tests__/workspace.test.js +20 -20
  16. package/dist/commands/accept.js +4 -4
  17. package/dist/commands/admin/cockpit.d.ts +4 -2
  18. package/dist/commands/admin/cockpit.d.ts.map +1 -1
  19. package/dist/commands/admin/cockpit.js +213 -6
  20. package/dist/commands/admin/cockpit.js.map +1 -1
  21. package/dist/commands/admin/index.d.ts.map +1 -1
  22. package/dist/commands/admin/index.js +2 -0
  23. package/dist/commands/admin/index.js.map +1 -1
  24. package/dist/commands/admin/inspect.d.ts +9 -0
  25. package/dist/commands/admin/inspect.d.ts.map +1 -1
  26. package/dist/commands/admin/inspect.js +19 -0
  27. package/dist/commands/admin/inspect.js.map +1 -1
  28. package/dist/commands/admin/inspect.test.js +20 -1
  29. package/dist/commands/admin/inspect.test.js.map +1 -1
  30. package/dist/commands/admin/manage.d.ts +8 -0
  31. package/dist/commands/admin/manage.d.ts.map +1 -0
  32. package/dist/commands/admin/manage.js +76 -0
  33. package/dist/commands/admin/manage.js.map +1 -0
  34. package/dist/commands/audit.js +4 -4
  35. package/dist/commands/brief.js +4 -4
  36. package/dist/commands/capture.js +6 -6
  37. package/dist/commands/chain-walk.js +2 -2
  38. package/dist/commands/changes.js +2 -2
  39. package/dist/commands/codex-prep.js +2 -2
  40. package/dist/commands/collections.js +5 -5
  41. package/dist/commands/constellation.js +2 -2
  42. package/dist/commands/context.js +2 -2
  43. package/dist/commands/cross-cut.js +2 -2
  44. package/dist/commands/doctor.js +3 -3
  45. package/dist/commands/doctor.test.js +1 -1
  46. package/dist/commands/fields.js +2 -2
  47. package/dist/commands/get.js +3 -3
  48. package/dist/commands/handshake.js +5 -5
  49. package/dist/commands/ingest.js +6 -6
  50. package/dist/commands/init.d.ts +1 -1
  51. package/dist/commands/init.js +1 -1
  52. package/dist/commands/orient.js +2 -2
  53. package/dist/commands/promote.js +4 -4
  54. package/dist/commands/proposals.js +2 -2
  55. package/dist/commands/reject.js +2 -2
  56. package/dist/commands/relate.js +3 -3
  57. package/dist/commands/search.js +2 -2
  58. package/dist/commands/session.js +7 -7
  59. package/dist/commands/setup.js +5 -5
  60. package/dist/commands/update.js +3 -3
  61. package/dist/commands/usage.d.ts +1 -1
  62. package/dist/commands/usage.js +4 -4
  63. package/dist/commands/verify.js +2 -2
  64. package/dist/commands/workspace.js +4 -4
  65. package/dist/generators/chain-rules.d.ts +3 -3
  66. package/dist/generators/chain-rules.js +3 -3
  67. package/dist/generators/chain-rules.test.js +2 -2
  68. package/dist/generators/portable-knowledge.js +1 -1
  69. package/dist/index.js +1 -1
  70. package/dist/index.js.map +1 -1
  71. package/dist/lib/activation.js +2 -2
  72. package/dist/lib/activation.test.js +3 -3
  73. package/dist/lib/client.d.ts +4 -4
  74. package/dist/lib/client.js +8 -8
  75. package/dist/lib/client.js.map +1 -1
  76. package/dist/lib/onboarding-path-b.js +8 -8
  77. package/dist/lib/onboarding-shared.js +2 -2
  78. package/dist/lib/onboarding.js +4 -4
  79. package/dist/lib/workspace-probe.js +2 -2
  80. package/package.json +1 -1
@@ -8,7 +8,7 @@
8
8
  * WP-319 S3: Pre-write grounding via chain.suggestLinksForCapture (advisory, fail-open).
9
9
  */
10
10
  import { getConfigOrGuide } from '../lib/config.js';
11
- import { convexCallWithSession } from '../lib/client.js';
11
+ import { kernelCallWithSession } from '../lib/client.js';
12
12
  import { readSession, addCapturedEntry } from '../lib/session.js';
13
13
  import { isJsonMode } from '../lib/runner.js';
14
14
  import { formatCaptureReceipt } from '../formatters/capture.js';
@@ -202,7 +202,7 @@ export async function runCapture(options) {
202
202
  const skipGrounding = process.env.PB_GROUNDING_MODE === 'off';
203
203
  let groundingResult = null;
204
204
  const groundingPromise = (!skipGrounding && (entryName || entryDescription))
205
- ? convexCallWithSession('chain.suggestLinksForCapture', {
205
+ ? kernelCallWithSession('chain.suggestLinksForCapture', {
206
206
  entries: [{ name: entryName, description: entryDescription, collectionHint: options.collection ?? '' }],
207
207
  limit: 5,
208
208
  threshold: 2,
@@ -222,7 +222,7 @@ export async function runCapture(options) {
222
222
  else {
223
223
  if (!json)
224
224
  progress('Classifying...');
225
- classification = await convexCallWithSession('chain.resolveCollection', {
225
+ classification = await kernelCallWithSession('chain.resolveCollection', {
226
226
  entryName,
227
227
  entryDescription,
228
228
  });
@@ -284,7 +284,7 @@ export async function runCapture(options) {
284
284
  if (datedCollections.includes(collectionSlug) && inferredSourceDate) {
285
285
  data.date = inferredSourceDate;
286
286
  }
287
- const result = await convexCallWithSession('chain.createEntry', {
287
+ const result = await kernelCallWithSession('chain.createEntry', {
288
288
  collectionSlug,
289
289
  name: entryName,
290
290
  status: 'draft',
@@ -300,7 +300,7 @@ export async function runCapture(options) {
300
300
  // WP-319 S3: Record grounding outcome for observability (STD-155, done-when 5).
301
301
  // Fire-and-forget — never block capture on observability failure.
302
302
  if (!skipGrounding && groundingStart > 0) {
303
- void convexCallWithSession('chain.recordGroundingOutcome', {
303
+ void kernelCallWithSession('chain.recordGroundingOutcome', {
304
304
  surface: 'cli',
305
305
  promptShown: (groundingResult?.governance?.length ?? 0) > 0,
306
306
  highestRatio: Math.max(...(groundingResult?.duplicates?.map((d) => d.overlapRatio) ?? []), ...(groundingResult?.related?.map((r) => r.overlapRatio) ?? []), 0),
@@ -334,7 +334,7 @@ export async function runCapture(options) {
334
334
  const linkTarget = options.link.trim();
335
335
  const relationType = options.type ?? 'surfaces_tension_in';
336
336
  if (linkTarget) {
337
- await convexCallWithSession('chain.createEntryRelation', {
337
+ await kernelCallWithSession('chain.createEntryRelation', {
338
338
  fromEntryId: result.entryId,
339
339
  toEntryId: linkTarget,
340
340
  type: relationType,
@@ -6,7 +6,7 @@
6
6
  * Chain: DEC-299 (agent-native, JSON-default), STD-65 (structured, parseable, minimal)
7
7
  */
8
8
  import { getConfigOrGuide } from '../lib/config.js';
9
- import { convexCall } from '../lib/client.js';
9
+ import { kernelCall } from '../lib/client.js';
10
10
  import { runCliCommand } from '../lib/runner.js';
11
11
  import { formatChainWalk } from '../formatters/chain-walk.js';
12
12
  import { CLIError, ErrorCode } from '../lib/errors.js';
@@ -26,7 +26,7 @@ export async function runChainWalk(options) {
26
26
  // Validate depth
27
27
  const clampedDepth = Math.max(1, Math.min(4, depth));
28
28
  await runCliCommand({
29
- fn: () => convexCall('chain.deepChainWalk', {
29
+ fn: () => kernelCall('chain.deepChainWalk', {
30
30
  entryId,
31
31
  direction,
32
32
  maxHops: clampedDepth,
@@ -6,7 +6,7 @@
6
6
  * Chain: DEC-299 (agent-native, JSON-default), STD-65 (structured, parseable, minimal)
7
7
  */
8
8
  import { getConfigOrGuide } from '../lib/config.js';
9
- import { convexCall } from '../lib/client.js';
9
+ import { kernelCall } from '../lib/client.js';
10
10
  import { runCliCommand } from '../lib/runner.js';
11
11
  import { formatChanges } from '../formatters/changes.js';
12
12
  import { CLIError, ErrorCode } from '../lib/errors.js';
@@ -37,7 +37,7 @@ export async function runChanges(options) {
37
37
  }
38
38
  const sinceTimestamp = Date.now() - durationMs;
39
39
  await runCliCommand({
40
- fn: () => convexCall('chain.changeDetection', {
40
+ fn: () => kernelCall('chain.changeDetection', {
41
41
  since: sinceTimestamp,
42
42
  }),
43
43
  formatPretty: (result) => formatChanges(result, options.since),
@@ -5,7 +5,7 @@
5
5
  import { mkdirSync, writeFileSync } from 'fs';
6
6
  import { join } from 'path';
7
7
  import { getConfigOrGuide } from '../lib/config.js';
8
- import { convexCall } from '../lib/client.js';
8
+ import { kernelCall } from '../lib/client.js';
9
9
  import { CLIError, ErrorCode } from '../lib/errors.js';
10
10
  export async function runCodexPrep(options) {
11
11
  const config = await getConfigOrGuide(() => runCodexPrep(options));
@@ -21,7 +21,7 @@ export async function runCodexPrep(options) {
21
21
  });
22
22
  }
23
23
  process.stderr.write(`Fetching governance context for: "${task}"...\n`);
24
- const orientView = await convexCall('chain.getOrientView', { task });
24
+ const orientView = await kernelCall('chain.getOrientView', { task });
25
25
  const content = formatCodexTaskContext(orientView, task);
26
26
  if (options.dryRun) {
27
27
  process.stdout.write(content);
@@ -9,7 +9,7 @@
9
9
  * pb collections audit — health report: classification, icon, displayHints, schema gaps
10
10
  */
11
11
  import { getConfigOrGuide } from '../lib/config.js';
12
- import { convexCall } from '../lib/client.js';
12
+ import { kernelCall } from '../lib/client.js';
13
13
  import { runCliCommand } from '../lib/runner.js';
14
14
  import { formatCollectionList, formatCollectionDescribe, formatCollectionAudit, } from '../formatters/collections.js';
15
15
  import { CLIError, ErrorCode } from '../lib/errors.js';
@@ -19,7 +19,7 @@ export async function runCollectionsList() {
19
19
  return;
20
20
  await runCliCommand({
21
21
  fn: async () => {
22
- const rawCollections = await convexCall('chain.listCollections', {});
22
+ const rawCollections = await kernelCall('chain.listCollections', {});
23
23
  const collections = (rawCollections ?? []).map((c) => ({
24
24
  slug: c.slug,
25
25
  name: c.name,
@@ -38,7 +38,7 @@ export async function runCollectionsGet(options) {
38
38
  return;
39
39
  await runCliCommand({
40
40
  fn: async () => {
41
- const result = await convexCall('chain.getCollection', { slug: options.slug });
41
+ const result = await kernelCall('chain.getCollection', { slug: options.slug });
42
42
  if (!result) {
43
43
  throw new CLIError(`Collection '${options.slug}' not found.`, {
44
44
  code: ErrorCode.VALIDATION_FAILED,
@@ -56,7 +56,7 @@ export async function runCollectionsAudit() {
56
56
  if (!config)
57
57
  return;
58
58
  await runCliCommand({
59
- fn: () => convexCall('chain.auditCollections', {}),
59
+ fn: () => kernelCall('chain.auditCollections', {}),
60
60
  formatPretty: (result) => formatCollectionAudit(result),
61
61
  });
62
62
  }
@@ -70,7 +70,7 @@ export async function runCollectionsExport() {
70
70
  if (!config)
71
71
  return;
72
72
  await runCliCommand({
73
- fn: () => convexCall('chain.exportDefinitions', {}),
73
+ fn: () => kernelCall('chain.exportDefinitions', {}),
74
74
  formatPretty: (result) => JSON.stringify(result, null, 2),
75
75
  });
76
76
  }
@@ -6,7 +6,7 @@
6
6
  * ARCH-25 (orient view model pattern), DEC-99 (ALLOWED_RELATION_TYPES as SSOT)
7
7
  */
8
8
  import { getConfigOrGuide } from '../lib/config.js';
9
- import { convexCall } from '../lib/client.js';
9
+ import { kernelCall } from '../lib/client.js';
10
10
  import { runCliCommand } from '../lib/runner.js';
11
11
  import { formatConstellation } from '../formatters/constellation.js';
12
12
  import { CLIError, ErrorCode } from '../lib/errors.js';
@@ -15,7 +15,7 @@ export async function runConstellation(options) {
15
15
  if (!config)
16
16
  return;
17
17
  await runCliCommand({
18
- fn: () => convexCall('chain.getConstellation', {
18
+ fn: () => kernelCall('chain.getConstellation', {
19
19
  entryId: options.entryId,
20
20
  }),
21
21
  formatPretty: (result) => {
@@ -4,7 +4,7 @@
4
4
  * Previously: pipe-friendly via process.stdout.isTTY — now delegated to runner.
5
5
  */
6
6
  import { getConfigOrGuide } from '../lib/config.js';
7
- import { convexCall } from '../lib/client.js';
7
+ import { kernelCall } from '../lib/client.js';
8
8
  import { runCliCommand, isJsonMode } from '../lib/runner.js';
9
9
  import { formatContext } from '../formatters/context.js';
10
10
  import { CLIError, ErrorCode } from '../lib/errors.js';
@@ -13,7 +13,7 @@ export async function runContext(options) {
13
13
  if (!config)
14
14
  return;
15
15
  await runCliCommand({
16
- fn: () => convexCall('chain.gatherContext', {
16
+ fn: () => kernelCall('chain.gatherContext', {
17
17
  entryId: options.entryId,
18
18
  maxHops: 2,
19
19
  }),
@@ -6,7 +6,7 @@
6
6
  * Chain: DEC-299 (agent-native, JSON-default), STD-65 (structured, parseable, minimal)
7
7
  */
8
8
  import { getConfigOrGuide } from '../lib/config.js';
9
- import { convexCall } from '../lib/client.js';
9
+ import { kernelCall } from '../lib/client.js';
10
10
  import { runCliCommand } from '../lib/runner.js';
11
11
  import { formatCrossCut } from '../formatters/cross-cut.js';
12
12
  export async function runCrossCut(options) {
@@ -14,7 +14,7 @@ export async function runCrossCut(options) {
14
14
  if (!config)
15
15
  return;
16
16
  await runCliCommand({
17
- fn: () => convexCall('chain.structuralAggregation', {
17
+ fn: () => kernelCall('chain.structuralAggregation', {
18
18
  relationType: options.type,
19
19
  }),
20
20
  formatPretty: (result) => formatCrossCut(result, options.type),
@@ -120,13 +120,13 @@ function checkEnvironment(resolvedSiteUrl) {
120
120
  detail: `${env} \u2192 API ${siteUrl} · connect redeem ${connectRedeem}`,
121
121
  };
122
122
  }
123
- /** Check 4: Server reachability via convexCall */
123
+ /** Check 4: Server reachability via kernelCall */
124
124
  async function checkReachability() {
125
125
  try {
126
126
  // Dynamic import to avoid module-load side effects when testing
127
- const { convexCall } = await import('../lib/client.js');
127
+ const { kernelCall } = await import('../lib/client.js');
128
128
  const start = Date.now();
129
- await convexCall('chain.getOrientView', {});
129
+ await kernelCall('chain.getOrientView', {});
130
130
  const elapsed = Date.now() - start;
131
131
  return {
132
132
  status: 'pass',
@@ -34,7 +34,7 @@ vi.mock('../lib/profiles.js', () => ({
34
34
  // Mock client — controls reachability
35
35
  const mockMcpCall = vi.fn();
36
36
  vi.mock('../lib/client.js', () => ({
37
- convexCall: (...args) => mockMcpCall(...args),
37
+ kernelCall: (...args) => mockMcpCall(...args),
38
38
  }));
39
39
  // Mock fs for config file check and fix actions
40
40
  const mockMkdirSync = vi.fn();
@@ -4,7 +4,7 @@
4
4
  * Chain: BET-181, STD-101 (SSOT — fields derive from collection doc, no hardcoded lists)
5
5
  */
6
6
  import { getConfigOrGuide } from '../lib/config.js';
7
- import { convexCall } from '../lib/client.js';
7
+ import { kernelCall } from '../lib/client.js';
8
8
  import { runCliCommand } from '../lib/runner.js';
9
9
  import { formatFields } from '../formatters/fields.js';
10
10
  import { CLIError, ErrorCode } from '../lib/errors.js';
@@ -14,7 +14,7 @@ export async function runFields(options) {
14
14
  return;
15
15
  await runCliCommand({
16
16
  fn: async () => {
17
- const result = await convexCall('chain.getCollectionFields', { slug: options.collectionSlug });
17
+ const result = await kernelCall('chain.getCollectionFields', { slug: options.collectionSlug });
18
18
  if (!result) {
19
19
  throw new CLIError(`Collection '${options.collectionSlug}' not found.`, {
20
20
  code: ErrorCode.VALIDATION_FAILED,
@@ -3,7 +3,7 @@
3
3
  * BET-108 Slice 3. BET-181 Slice 0: routes through runCliCommand for JSON-default output.
4
4
  */
5
5
  import { getConfigOrGuide } from '../lib/config.js';
6
- import { convexCall } from '../lib/client.js';
6
+ import { kernelCall } from '../lib/client.js';
7
7
  import { runCliCommand, isJsonMode } from '../lib/runner.js';
8
8
  import { formatEntry } from '../formatters/entry.js';
9
9
  import { stripConvexInternals } from '../lib/strip.js';
@@ -14,7 +14,7 @@ export async function runGet(options) {
14
14
  return;
15
15
  await runCliCommand({
16
16
  fn: async () => {
17
- const entry = await convexCall('chain.getEntry', { entryId: options.entryId });
17
+ const entry = await kernelCall('chain.getEntry', { entryId: options.entryId });
18
18
  if (!entry) {
19
19
  throw new CLIError(`Entry '${options.entryId}' not found.`, {
20
20
  code: ErrorCode.VALIDATION_FAILED,
@@ -42,7 +42,7 @@ export async function runGetMany(options) {
42
42
  guidance: 'Usage: pb get-many <id1> <id2> ...',
43
43
  });
44
44
  }
45
- const results = await Promise.all(options.entryIds.map((id) => convexCall('chain.getEntry', { entryId: id }).then((entry) => ({ id, entry, error: null }), (err) => ({ id, entry: null, error: err instanceof Error ? err.message : String(err) }))));
45
+ const results = await Promise.all(options.entryIds.map((id) => kernelCall('chain.getEntry', { entryId: id }).then((entry) => ({ id, entry, error: null }), (err) => ({ id, entry: null, error: err instanceof Error ? err.message : String(err) }))));
46
46
  const json = isJsonMode();
47
47
  if (json) {
48
48
  const output = results.map((result) => {
@@ -8,7 +8,7 @@ import { homedir } from 'os';
8
8
  import { fileURLToPath } from 'url';
9
9
  import { getConfigOrGuide } from '../lib/config.js';
10
10
  import { select as promptSelect } from '../lib/prompts.js';
11
- import { convexCall } from '../lib/client.js';
11
+ import { kernelCall } from '../lib/client.js';
12
12
  import { detectRepo, extractWorkspaceProfile } from '../lib/repo-detect.js';
13
13
  import { generateContextMd } from '../generators/context-md.js';
14
14
  import { generateBriefingMd } from '../generators/briefing-md.js';
@@ -308,9 +308,9 @@ export async function runHandshake(options = {}) {
308
308
  let orientView = null;
309
309
  let workspaceProfile = null;
310
310
  try {
311
- const workspaceReadinessPromise = convexCall('chain.workspaceReadiness', {}).catch(() => null);
311
+ const workspaceReadinessPromise = kernelCall('chain.workspaceReadiness', {}).catch(() => null);
312
312
  const [orientResult, readinessRaw] = await Promise.all([
313
- convexCall('chain.getOrientView', {}).catch((err) => {
313
+ kernelCall('chain.getOrientView', {}).catch((err) => {
314
314
  logErr(`Warning: could not fetch workspace context — ${err instanceof Error ? err.message : err}`);
315
315
  logErr('Continuing with limited context (Chain search + portable knowledge only).');
316
316
  return null;
@@ -344,7 +344,7 @@ export async function runHandshake(options = {}) {
344
344
  let matchedEntries = [];
345
345
  if (uniqueQueries.length > 0) {
346
346
  log(`Searching Chain for: ${uniqueQueries.join(', ')}...`);
347
- const searchResults = await Promise.all(uniqueQueries.map((q) => convexCall('chain.searchEntries', { query: q }).catch(() => [])));
347
+ const searchResults = await Promise.all(uniqueQueries.map((q) => kernelCall('chain.searchEntries', { query: q }).catch(() => [])));
348
348
  matchedEntries = deduplicateEntries(searchResults.flat());
349
349
  }
350
350
  // 5. Read canonical skills & rules from .productbrain/
@@ -357,7 +357,7 @@ export async function runHandshake(options = {}) {
357
357
  let allRules = manualRules;
358
358
  if (generate) {
359
359
  log('Generating Chain-derived rules...');
360
- const chainResult = await generateChainRules(convexCall, manualRules);
360
+ const chainResult = await generateChainRules(kernelCall, manualRules);
361
361
  if (chainResult.sentinel) {
362
362
  // MCP unavailable — inject sentinel rule and warn
363
363
  allRules = [...manualRules, chainResult.sentinel];
@@ -10,7 +10,7 @@ import { resolve } from 'path';
10
10
  import { globSync } from 'glob';
11
11
  import { randomUUID } from 'crypto';
12
12
  import { getConfigOrGuide } from '../lib/config.js';
13
- import { convexCall } from '../lib/client.js';
13
+ import { kernelCall } from '../lib/client.js';
14
14
  import { isJsonMode } from '../lib/runner.js';
15
15
  import { stripConvexInternals } from '../lib/strip.js';
16
16
  import { CLIError, ErrorCode } from '../lib/errors.js';
@@ -58,7 +58,7 @@ export async function runIngest(options) {
58
58
  }
59
59
  const ingestionRunId = randomUUID();
60
60
  // Resolve workspace + keyId — startSession requires apiKeyId (MCP server passes it; CLI gets from resolveWorkspace)
61
- const workspace = await convexCall('resolveWorkspace', {});
61
+ const workspace = await kernelCall('resolveWorkspace', {});
62
62
  if (!workspace?.keyId) {
63
63
  throw new CLIError('API key has no keyId.', {
64
64
  code: ErrorCode.AUTH_INVALID,
@@ -69,7 +69,7 @@ export async function runIngest(options) {
69
69
  // --resume: filter out files whose sourceRef is already committed in staging
70
70
  let resumeSkipped = 0;
71
71
  if (resume) {
72
- const committedRefs = await convexCall('staging.getCommittedSourceRefs', {});
72
+ const committedRefs = await kernelCall('staging.getCommittedSourceRefs', {});
73
73
  const committedSet = new Set(committedRefs ?? []);
74
74
  const originalCount = files.length;
75
75
  files = files.filter((f) => !committedSet.has(f));
@@ -87,7 +87,7 @@ export async function runIngest(options) {
87
87
  return;
88
88
  }
89
89
  }
90
- const startRes = await convexCall('agent.startSession', {
90
+ const startRes = await kernelCall('agent.startSession', {
91
91
  workspaceId: workspace._id,
92
92
  apiKeyId: workspace.keyId,
93
93
  clientKind: 'cli',
@@ -102,7 +102,7 @@ export async function runIngest(options) {
102
102
  try {
103
103
  const content = await readFile(filePath, 'utf8');
104
104
  const sourceRef = filePath;
105
- const result = await convexCall('chain.ingestDocument', {
105
+ const result = await kernelCall('chain.ingestDocument', {
106
106
  content,
107
107
  sourceRef,
108
108
  ingestionRunId,
@@ -167,7 +167,7 @@ export async function runIngest(options) {
167
167
  }
168
168
  }
169
169
  finally {
170
- await convexCall('agent.closeSession', { sessionId, status: 'closed' });
170
+ await kernelCall('agent.closeSession', { sessionId, status: 'closed' });
171
171
  }
172
172
  if (json) {
173
173
  process.stdout.write(JSON.stringify(stripConvexInternals({
@@ -2,7 +2,7 @@
2
2
  * pb init — intelligent entry point that detects setup state and guides the user.
3
3
  *
4
4
  * WP-303 Slice 4 (Keystone): 4-state machine (fresh → has-key → has-workspace → ready).
5
- * Uses getConfig() for key check, convexCall for workspace validation.
5
+ * Uses getConfig() for key check, kernelCall for workspace validation.
6
6
  */
7
7
  export type InitState = 'fresh' | 'has-key' | 'ready';
8
8
  /**
@@ -2,7 +2,7 @@
2
2
  * pb init — intelligent entry point that detects setup state and guides the user.
3
3
  *
4
4
  * WP-303 Slice 4 (Keystone): 4-state machine (fresh → has-key → has-workspace → ready).
5
- * Uses getConfig() for key check, convexCall for workspace validation.
5
+ * Uses getConfig() for key check, kernelCall for workspace validation.
6
6
  */
7
7
  import { getConfig } from '../lib/config.js';
8
8
  import { readSession } from '../lib/session.js';
@@ -3,7 +3,7 @@
3
3
  * BET-181 Slice 0: routes through runCliCommand for JSON-default output.
4
4
  */
5
5
  import { getConfigOrGuide } from '../lib/config.js';
6
- import { convexCall } from '../lib/client.js';
6
+ import { kernelCall } from '../lib/client.js';
7
7
  import { runCliCommand } from '../lib/runner.js';
8
8
  import { formatOrient, formatOrientBrief } from '../formatters/orient.js';
9
9
  function normalizeView(raw) {
@@ -44,7 +44,7 @@ export async function runOrient(options = {}) {
44
44
  callArgs.task = options.task;
45
45
  if (options.scope)
46
46
  callArgs.scope = options.scope;
47
- const raw = await convexCall('chain.getOrientView', Object.keys(callArgs).length > 0 ? callArgs : {});
47
+ const raw = await kernelCall('chain.getOrientView', Object.keys(callArgs).length > 0 ? callArgs : {});
48
48
  // Normalize before output in any mode — ensures JSON keys are stable
49
49
  // for agent consumers (optional sections become empty arrays, not absent).
50
50
  return normalizeView(raw);
@@ -4,7 +4,7 @@
4
4
  * Thin client: governance checks live in Convex (BR-104).
5
5
  */
6
6
  import { getConfigOrGuide } from '../lib/config.js';
7
- import { convexCallWithSession } from '../lib/client.js';
7
+ import { kernelCallWithSession } from '../lib/client.js';
8
8
  import { readSession } from '../lib/session.js';
9
9
  import { runCliCommand } from '../lib/runner.js';
10
10
  import { formatPromoteReceipt } from '../formatters/promote.js';
@@ -34,7 +34,7 @@ export async function runPromote(options) {
34
34
  }
35
35
  await runCliCommand({
36
36
  fn: async () => {
37
- const entry = await convexCallWithSession('chain.getEntry', { entryId });
37
+ const entry = await kernelCallWithSession('chain.getEntry', { entryId });
38
38
  if (!entry) {
39
39
  throw new CLIError(`Entry ${entryId} not found.`, {
40
40
  code: ErrorCode.VALIDATION_FAILED,
@@ -47,7 +47,7 @@ export async function runPromote(options) {
47
47
  '';
48
48
  let conflicts = [];
49
49
  try {
50
- conflicts = (await convexCallWithSession('chain.detectSemanticConflicts', {
50
+ conflicts = (await kernelCallWithSession('chain.detectSemanticConflicts', {
51
51
  name: entry.name,
52
52
  description,
53
53
  collectionHint: entry.collectionSlug ?? entry.collection?.slug ?? entry.collection?.name,
@@ -72,7 +72,7 @@ export async function runPromote(options) {
72
72
  if (options.message) {
73
73
  args.commitMessage = options.message;
74
74
  }
75
- const result = await convexCallWithSession('chain.commitEntry', args);
75
+ const result = await kernelCallWithSession('chain.commitEntry', args);
76
76
  // Resolve display name from result
77
77
  const name = ('name' in result && typeof result.name === 'string')
78
78
  ? result.name
@@ -6,7 +6,7 @@
6
6
  * Read-only — no active session required.
7
7
  */
8
8
  import { getConfigOrGuide } from '../lib/config.js';
9
- import { convexCall } from '../lib/client.js';
9
+ import { kernelCall } from '../lib/client.js';
10
10
  import { runCliCommand } from '../lib/runner.js';
11
11
  import { formatProposalsList } from '../formatters/proposals.js';
12
12
  export async function runProposals() {
@@ -15,7 +15,7 @@ export async function runProposals() {
15
15
  return;
16
16
  await runCliCommand({
17
17
  fn: async () => {
18
- const proposals = await convexCall('governance.listProposals', {});
18
+ const proposals = await kernelCall('governance.listProposals', {});
19
19
  return { proposals, count: proposals.length };
20
20
  },
21
21
  formatPretty: (data) => formatProposalsList(data),
@@ -6,7 +6,7 @@
6
6
  * Reason is mandatory — objections must be explained (BR-7).
7
7
  */
8
8
  import { getConfigOrGuide } from '../lib/config.js';
9
- import { convexCall } from '../lib/client.js';
9
+ import { kernelCall } from '../lib/client.js';
10
10
  import { runCliCommand } from '../lib/runner.js';
11
11
  import { formatRejectReceipt } from '../formatters/proposals.js';
12
12
  import { CLIError, ErrorCode } from '../lib/errors.js';
@@ -31,7 +31,7 @@ export async function runReject(options) {
31
31
  }
32
32
  await runCliCommand({
33
33
  fn: async () => {
34
- return await convexCall('governance.respondToProposal', {
34
+ return await kernelCall('governance.respondToProposal', {
35
35
  proposalId,
36
36
  verdict: 'reject',
37
37
  reason: options.reason.trim(),
@@ -5,7 +5,7 @@
5
5
  * Thin client: relation type validation lives in Convex (BR-104).
6
6
  */
7
7
  import { getConfigOrGuide } from '../lib/config.js';
8
- import { convexCallWithSession } from '../lib/client.js';
8
+ import { kernelCallWithSession } from '../lib/client.js';
9
9
  import { readSession } from '../lib/session.js';
10
10
  import { runCliCommand } from '../lib/runner.js';
11
11
  import { formatRelateReceipt, formatUnrelateReceipt } from '../formatters/relate.js';
@@ -43,7 +43,7 @@ export async function runRelate(options) {
43
43
  if (options.ifMissing) {
44
44
  mcpArgs.ifMissing = true;
45
45
  }
46
- const result = await convexCallWithSession('chain.createEntryRelation', mcpArgs);
46
+ const result = await kernelCallWithSession('chain.createEntryRelation', mcpArgs);
47
47
  const isProposal = result?.status === 'proposal_created';
48
48
  const output = {
49
49
  fromId,
@@ -85,7 +85,7 @@ export async function runUnrelate(options) {
85
85
  }
86
86
  await runCliCommand({
87
87
  fn: async () => {
88
- await convexCallWithSession('chain.removeEntryRelation', {
88
+ await kernelCallWithSession('chain.removeEntryRelation', {
89
89
  fromEntryId: fromId,
90
90
  toEntryId: toId,
91
91
  type,
@@ -3,7 +3,7 @@
3
3
  * BET-181 Slice 0: routes through runCliCommand for JSON-default output.
4
4
  */
5
5
  import { getConfigOrGuide } from '../lib/config.js';
6
- import { convexCall } from '../lib/client.js';
6
+ import { kernelCall } from '../lib/client.js';
7
7
  import { runCliCommand } from '../lib/runner.js';
8
8
  import { formatSearchResults } from '../formatters/search.js';
9
9
  export async function runSearch(options) {
@@ -11,7 +11,7 @@ export async function runSearch(options) {
11
11
  if (!config)
12
12
  return;
13
13
  await runCliCommand({
14
- fn: () => convexCall('chain.searchEntries', { query: options.query }),
14
+ fn: () => kernelCall('chain.searchEntries', { query: options.query }),
15
15
  formatPretty: (results) => formatSearchResults(results ?? []),
16
16
  });
17
17
  }
@@ -6,7 +6,7 @@
6
6
  * on session start preserved for backward compatibility.
7
7
  */
8
8
  import { getConfigOrGuide } from '../lib/config.js';
9
- import { convexCall } from '../lib/client.js';
9
+ import { kernelCall } from '../lib/client.js';
10
10
  import { readSession, writeSession, clearSession, readClosedMarker } from '../lib/session.js';
11
11
  import { isJsonMode } from '../lib/runner.js';
12
12
  import { formatSessionStart, formatSessionClose } from '../formatters/session.js';
@@ -48,11 +48,11 @@ export async function runSessionStart(options = {}) {
48
48
  const elapsed = Date.now() - new Date(closedMarker.closedAt).getTime();
49
49
  if (elapsed < RESUME_WINDOW_MS) {
50
50
  // Resolve workspace to get keyId (needed for resumeSession)
51
- const wsForResume = await convexCall('resolveWorkspace', {});
51
+ const wsForResume = await kernelCall('resolveWorkspace', {});
52
52
  if (wsForResume?.keyId) {
53
53
  if (!json)
54
54
  process.stdout.write('Resuming session...\n');
55
- const resumed = await convexCall('agent.resumeSession', {
55
+ const resumed = await kernelCall('agent.resumeSession', {
56
56
  workspaceId: wsForResume._id,
57
57
  apiKeyId: wsForResume.keyId,
58
58
  previousSessionId: closedMarker.sessionId,
@@ -96,7 +96,7 @@ export async function runSessionStart(options = {}) {
96
96
  }
97
97
  }
98
98
  // Resolve workspace + keyId
99
- const workspace = await convexCall('resolveWorkspace', {});
99
+ const workspace = await kernelCall('resolveWorkspace', {});
100
100
  if (!workspace?.keyId) {
101
101
  throw new CLIError('API key has read-only scope. Write operations require a readwrite key.', {
102
102
  code: ErrorCode.AUTH_INVALID,
@@ -107,7 +107,7 @@ export async function runSessionStart(options = {}) {
107
107
  // Start agent session with clientKind attribution (DEC-184)
108
108
  if (!json)
109
109
  process.stdout.write('Starting session...\n');
110
- const result = await convexCall('agent.startSession', {
110
+ const result = await kernelCall('agent.startSession', {
111
111
  workspaceId: workspace._id,
112
112
  apiKeyId: workspace.keyId,
113
113
  clientKind: 'cli',
@@ -165,7 +165,7 @@ export async function runSessionClose(options = {}) {
165
165
  const entriesCount = session.entriesCaptured.length;
166
166
  if (entriesCount > 0) {
167
167
  try {
168
- await convexCall('agent.recordWrapup', {
168
+ await kernelCall('agent.recordWrapup', {
169
169
  sessionId: session.sessionId,
170
170
  draftsReviewed: entriesCount,
171
171
  draftsCommitted: 0, // CLI captures are drafts; user commits in Studio
@@ -179,7 +179,7 @@ export async function runSessionClose(options = {}) {
179
179
  }
180
180
  // Close the session
181
181
  try {
182
- await convexCall('agent.closeSession', {
182
+ await kernelCall('agent.closeSession', {
183
183
  sessionId: session.sessionId,
184
184
  status: 'closed',
185
185
  });
@@ -12,7 +12,7 @@
12
12
  * WP-303 Slice 1: migrated from readline to @clack/prompts via lib/prompts.ts.
13
13
  */
14
14
  import { getConfig } from '../lib/config.js';
15
- import { convexCall } from '../lib/client.js';
15
+ import { kernelCall } from '../lib/client.js';
16
16
  import { readSession, writeSession } from '../lib/session.js';
17
17
  import { trackEvent } from '../lib/telemetry.js';
18
18
  import { runLogin } from './login.js';
@@ -47,7 +47,7 @@ async function runSetupFlow() {
47
47
  let wsName = 'your workspace';
48
48
  let wsId;
49
49
  try {
50
- const workspace = await convexCall('resolveWorkspace', {});
50
+ const workspace = await kernelCall('resolveWorkspace', {});
51
51
  if (workspace?.name) {
52
52
  console.log(`Connected to workspace: ${workspace.name}`);
53
53
  wsName = workspace.name;
@@ -96,7 +96,7 @@ async function runSetupPostLogin() {
96
96
  let wsName = 'your workspace';
97
97
  let wsId;
98
98
  try {
99
- const workspace = await convexCall('resolveWorkspace', {});
99
+ const workspace = await kernelCall('resolveWorkspace', {});
100
100
  if (workspace?.name) {
101
101
  console.log(`Connected to workspace: ${workspace.name}`);
102
102
  wsName = workspace.name;
@@ -117,10 +117,10 @@ async function ensureSessionAndOnboard(workspaceName, workspaceId) {
117
117
  try {
118
118
  const resolvedWs = workspaceId
119
119
  ? { _id: workspaceId, keyId: null }
120
- : await convexCall('resolveWorkspace', {});
120
+ : await kernelCall('resolveWorkspace', {});
121
121
  if (!resolvedWs)
122
122
  return;
123
- const result = await convexCall('agent.startSession', {
123
+ const result = await kernelCall('agent.startSession', {
124
124
  workspaceId: resolvedWs._id,
125
125
  apiKeyId: resolvedWs.keyId,
126
126
  clientKind: 'cli',