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

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/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 +16 -30
  14. package/dist/__tests__/setup.test.js.map +1 -1
  15. package/dist/__tests__/state.test.d.ts +6 -0
  16. package/dist/__tests__/state.test.d.ts.map +1 -0
  17. package/dist/__tests__/state.test.js +97 -0
  18. package/dist/__tests__/state.test.js.map +1 -0
  19. package/dist/__tests__/update.test.js +21 -21
  20. package/dist/__tests__/workspace.test.js +20 -20
  21. package/dist/commands/accept.js +4 -4
  22. package/dist/commands/admin/cockpit.d.ts +4 -2
  23. package/dist/commands/admin/cockpit.d.ts.map +1 -1
  24. package/dist/commands/admin/cockpit.js +219 -10
  25. package/dist/commands/admin/cockpit.js.map +1 -1
  26. package/dist/commands/admin/index.d.ts.map +1 -1
  27. package/dist/commands/admin/index.js +2 -0
  28. package/dist/commands/admin/index.js.map +1 -1
  29. package/dist/commands/admin/inspect.d.ts +9 -0
  30. package/dist/commands/admin/inspect.d.ts.map +1 -1
  31. package/dist/commands/admin/inspect.js +19 -0
  32. package/dist/commands/admin/inspect.js.map +1 -1
  33. package/dist/commands/admin/inspect.test.js +20 -1
  34. package/dist/commands/admin/inspect.test.js.map +1 -1
  35. package/dist/commands/admin/manage.d.ts +8 -0
  36. package/dist/commands/admin/manage.d.ts.map +1 -0
  37. package/dist/commands/admin/manage.js +76 -0
  38. package/dist/commands/admin/manage.js.map +1 -0
  39. package/dist/commands/audit.js +4 -4
  40. package/dist/commands/brief.js +4 -4
  41. package/dist/commands/capture.js +6 -6
  42. package/dist/commands/chain-walk.js +2 -2
  43. package/dist/commands/changes.js +2 -2
  44. package/dist/commands/codex-prep.js +2 -2
  45. package/dist/commands/collections.js +5 -5
  46. package/dist/commands/connect-screens.d.ts +21 -0
  47. package/dist/commands/connect-screens.d.ts.map +1 -0
  48. package/dist/commands/connect-screens.js +79 -0
  49. package/dist/commands/connect-screens.js.map +1 -0
  50. package/dist/commands/constellation.js +2 -2
  51. package/dist/commands/context.js +2 -2
  52. package/dist/commands/cross-cut.js +2 -2
  53. package/dist/commands/doctor.js +3 -3
  54. package/dist/commands/doctor.test.js +1 -1
  55. package/dist/commands/fields.js +2 -2
  56. package/dist/commands/get.js +3 -3
  57. package/dist/commands/handshake.js +5 -5
  58. package/dist/commands/ingest.js +6 -6
  59. package/dist/commands/init.d.ts +1 -1
  60. package/dist/commands/init.d.ts.map +1 -1
  61. package/dist/commands/init.js +1 -9
  62. package/dist/commands/init.js.map +1 -1
  63. package/dist/commands/orient.js +2 -2
  64. package/dist/commands/promote.js +4 -4
  65. package/dist/commands/proposals.js +2 -2
  66. package/dist/commands/reject.js +2 -2
  67. package/dist/commands/relate.js +3 -3
  68. package/dist/commands/search.js +2 -2
  69. package/dist/commands/session.js +7 -7
  70. package/dist/commands/setup.d.ts +1 -1
  71. package/dist/commands/setup.d.ts.map +1 -1
  72. package/dist/commands/setup.js +10 -31
  73. package/dist/commands/setup.js.map +1 -1
  74. package/dist/commands/update.js +3 -3
  75. package/dist/commands/usage.d.ts +1 -1
  76. package/dist/commands/usage.js +4 -4
  77. package/dist/commands/verify.js +2 -2
  78. package/dist/commands/welcome.d.ts +21 -0
  79. package/dist/commands/welcome.d.ts.map +1 -0
  80. package/dist/commands/welcome.js +50 -0
  81. package/dist/commands/welcome.js.map +1 -0
  82. package/dist/commands/workspace.js +4 -4
  83. package/dist/generators/chain-rules.d.ts +3 -3
  84. package/dist/generators/chain-rules.js +3 -3
  85. package/dist/generators/chain-rules.test.js +2 -2
  86. package/dist/generators/portable-knowledge.js +1 -1
  87. package/dist/index.js +1 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/lib/activation.js +2 -2
  90. package/dist/lib/activation.test.js +3 -3
  91. package/dist/lib/client.d.ts +4 -4
  92. package/dist/lib/client.d.ts.map +1 -1
  93. package/dist/lib/client.js +8 -9
  94. package/dist/lib/client.js.map +1 -1
  95. package/dist/lib/onboarding-path-b.js +8 -8
  96. package/dist/lib/onboarding-shared.js +2 -2
  97. package/dist/lib/onboarding.js +4 -4
  98. package/dist/lib/state.d.ts +51 -0
  99. package/dist/lib/state.d.ts.map +1 -0
  100. package/dist/lib/state.js +90 -0
  101. package/dist/lib/state.js.map +1 -0
  102. package/dist/lib/workspace-probe.js +2 -2
  103. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  * Path B — Facilitator-pattern onboarding (2 exchanges max).
3
3
  * WP-304: Shorter flow, silent extraction, auto-capture, governance proof.
4
4
  */
5
- import { convexCall } from './client.js';
5
+ import { kernelCall } from './client.js';
6
6
  import { ask } from './prompts.js';
7
7
  import { bold, dim, green, icons } from './style.js';
8
8
  import { trackEvent } from './telemetry.js';
@@ -15,7 +15,7 @@ export async function runOnboardingPathB(workspaceName) {
15
15
  // Exchange 1: Opening question
16
16
  let greeting;
17
17
  try {
18
- const result = await convexCall('onboarding.chat', {
18
+ const result = await kernelCall('onboarding.chat', {
19
19
  messages: [],
20
20
  workspaceName,
21
21
  style: 'facilitator',
@@ -54,14 +54,14 @@ export async function runOnboardingPathB(workspaceName) {
54
54
  totalUserWords += countWords(userInput);
55
55
  // Silent extraction after first answer (parallel with follow-up)
56
56
  const [followUpResult, extractResult] = await Promise.allSettled([
57
- convexCall('onboarding.chat', {
57
+ kernelCall('onboarding.chat', {
58
58
  messages,
59
59
  workspaceName,
60
60
  style: 'facilitator',
61
61
  turnNumber: 2,
62
62
  totalUserWords,
63
63
  }),
64
- convexCall('onboarding.chat', {
64
+ kernelCall('onboarding.chat', {
65
65
  messages,
66
66
  workspaceName,
67
67
  mode: 'extract',
@@ -84,7 +84,7 @@ export async function runOnboardingPathB(workspaceName) {
84
84
  totalUserWords += countWords(secondInput);
85
85
  // Second extraction — merge with first
86
86
  try {
87
- const result2 = await convexCall('onboarding.chat', {
87
+ const result2 = await kernelCall('onboarding.chat', {
88
88
  messages,
89
89
  workspaceName,
90
90
  mode: 'extract',
@@ -107,7 +107,7 @@ export async function runOnboardingPathB(workspaceName) {
107
107
  // Try one final extraction if we don't have one
108
108
  if (!lastExtraction?.vision && messages.filter((m) => m.role === 'user').length > 0) {
109
109
  try {
110
- const finalExtract = await convexCall('onboarding.chat', {
110
+ const finalExtract = await kernelCall('onboarding.chat', {
111
111
  messages,
112
112
  workspaceName,
113
113
  mode: 'extract',
@@ -168,7 +168,7 @@ export function dedupe(arr) {
168
168
  /** Governance proof — show binding governance from captured knowledge via resolveTaskStartup. */
169
169
  async function showGovernanceProof(vision) {
170
170
  try {
171
- const result = await convexCall('chain.resolveTaskStartup', { task: vision });
171
+ const result = await kernelCall('chain.resolveTaskStartup', { task: vision });
172
172
  const governance = result?.bindingGovernance;
173
173
  const steering = result?.steeringContext ?? [];
174
174
  const allItems = [
@@ -191,7 +191,7 @@ async function showGovernanceProof(vision) {
191
191
  catch {
192
192
  // Governance proof is best-effort — fall back to orient-based proof
193
193
  try {
194
- const orient = await convexCall('orient', { brief: true });
194
+ const orient = await kernelCall('orient', { brief: true });
195
195
  const items = orient?.sections?.flatMap((s) => s.items ?? []).filter((i) => i.name) ?? [];
196
196
  if (items.length > 0) {
197
197
  process.stdout.write(`\n ${bold("Here's how your product brain will use this:")}\n\n`);
@@ -6,7 +6,7 @@
6
6
  * Copy-and-own: CLI uses 120-char truncate limits (vs MCP's 80). Shared package deferred.
7
7
  * Duplicated due to monorepo import boundary (BR-108).
8
8
  */
9
- import { convexCallWithSession } from './client.js';
9
+ import { kernelCallWithSession } from './client.js';
10
10
  import { bold, cyan, dim, icons } from './style.js';
11
11
  // ── String helpers ─────────────────────────────────────────────────────────
12
12
  export function truncate(str, maxLen) {
@@ -154,7 +154,7 @@ export async function batchCaptureEntries(entries) {
154
154
  const errors = [];
155
155
  for (const entry of entries) {
156
156
  try {
157
- await convexCallWithSession('chain.createEntry', {
157
+ await kernelCallWithSession('chain.createEntry', {
158
158
  collectionSlug: entry.collection,
159
159
  name: entry.name,
160
160
  status: 'active',
@@ -6,7 +6,7 @@
6
6
  * Convex onboardingChat action for conversation and extraction,
7
7
  * then chain.createEntry for batch-capture.
8
8
  */
9
- import { convexCall } from './client.js';
9
+ import { kernelCall } from './client.js';
10
10
  import { ask, confirm, select } from './prompts.js';
11
11
  import { bold, dim, green, icons } from './style.js';
12
12
  import { trackEvent } from './telemetry.js';
@@ -46,7 +46,7 @@ export async function runOnboardingConversation(workspaceName) {
46
46
  const openingDirective = buildTopicDirective(firstTopic, 0, ONBOARDING_TOPICS.length, [], workspaceName);
47
47
  let greeting;
48
48
  try {
49
- const result = await convexCall('onboarding.chat', {
49
+ const result = await kernelCall('onboarding.chat', {
50
50
  messages: [],
51
51
  workspaceName,
52
52
  phaseDirective: openingDirective,
@@ -128,7 +128,7 @@ export async function runOnboardingConversation(workspaceName) {
128
128
  const topicDirective = buildTopicDirective(topic, currentTopicIndex, ONBOARDING_TOPICS.length, state.completedQA, workspaceName);
129
129
  let topicComplete = false;
130
130
  try {
131
- const result = await convexCall('onboarding.chat', {
131
+ const result = await kernelCall('onboarding.chat', {
132
132
  messages: state.messages,
133
133
  workspaceName,
134
134
  phaseDirective: topicDirective,
@@ -194,7 +194,7 @@ export async function runOnboardingConversation(workspaceName) {
194
194
  }
195
195
  let entriesToCapture;
196
196
  try {
197
- const result = await convexCall('onboarding.chat', {
197
+ const result = await kernelCall('onboarding.chat', {
198
198
  messages: state.messages,
199
199
  workspaceName,
200
200
  mode: 'extract',
@@ -0,0 +1,51 @@
1
+ /**
2
+ * CLI setup state resolution — determines where the user is in the setup journey
3
+ * and what render tier to use for output.
4
+ *
5
+ * WP-325 S1: Foundation utilities consumed by S2 (index.ts) and S3 (connect.ts).
6
+ * No callers wired in this slice — this is the shared substrate.
7
+ *
8
+ * Stage model:
9
+ * unconfigured → no API key found anywhere
10
+ * authenticated → API key present, but workspace unreachable (offline or not yet connected)
11
+ * workspace-bound → key + workspace reachable, but no active session
12
+ * active → key + workspace + active session
13
+ */
14
+ /** Four-stage setup journey from cold start to active use. */
15
+ export type SetupStage = 'unconfigured' | 'authenticated' | 'workspace-bound' | 'active';
16
+ export interface SetupState {
17
+ stage: SetupStage;
18
+ /** Human-readable list of what is still missing. Empty when stage === 'active'. */
19
+ missingSteps: string[];
20
+ /** Single most important next command to run. */
21
+ nextAction: string;
22
+ /** Workspace name — populated when workspace probe succeeds. */
23
+ workspaceName?: string;
24
+ /** Total entry count from the workspace — populated when workspace probe succeeds. */
25
+ entryCount?: number;
26
+ /** Whether a write session is currently active. */
27
+ sessionActive?: boolean;
28
+ }
29
+ /** Output render tier for the current runtime context. */
30
+ export type RenderTier = 'json' | 'plain' | 'ink';
31
+ /**
32
+ * Determine the user's current setup stage and surface what's missing.
33
+ *
34
+ * Resolution order mirrors the config cascade (getConfigSafe → probeWorkspace → readSession).
35
+ * Each step is attempted only if the previous one succeeded, matching how the system
36
+ * actually behaves when a command runs.
37
+ *
38
+ * Network calls: probeWorkspace() makes one lightweight orient call. If the caller is in a
39
+ * context where network is unavailable, this returns 'authenticated' rather than throwing.
40
+ */
41
+ export declare function resolveSetupState(): Promise<SetupState>;
42
+ /**
43
+ * Determine the appropriate output rendering tier for the current process context.
44
+ *
45
+ * Priority:
46
+ * json → isJsonMode() is true (explicit --json flag or non-TTY piped output)
47
+ * plain → stdout is not a TTY (but isJsonMode() was false — e.g. --pretty on a pipe)
48
+ * ink → interactive TTY, Ink React rendering is safe
49
+ */
50
+ export declare function detectRenderTier(): RenderTier;
51
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/lib/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH,8DAA8D;AAC9D,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,eAAe,GAAG,iBAAiB,GAAG,QAAQ,CAAC;AAEzF,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,UAAU,CAAC;IAClB,mFAAmF;IACnF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAMlD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,UAAU,CAAC,CA2C7D;AAMD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAI7C"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * CLI setup state resolution — determines where the user is in the setup journey
3
+ * and what render tier to use for output.
4
+ *
5
+ * WP-325 S1: Foundation utilities consumed by S2 (index.ts) and S3 (connect.ts).
6
+ * No callers wired in this slice — this is the shared substrate.
7
+ *
8
+ * Stage model:
9
+ * unconfigured → no API key found anywhere
10
+ * authenticated → API key present, but workspace unreachable (offline or not yet connected)
11
+ * workspace-bound → key + workspace reachable, but no active session
12
+ * active → key + workspace + active session
13
+ */
14
+ import { getConfigSafe } from './config.js';
15
+ import { probeWorkspace } from './workspace-probe.js';
16
+ import { readSession } from './session.js';
17
+ import { isJsonMode } from './runner.js';
18
+ // ---------------------------------------------------------------------------
19
+ // resolveSetupState
20
+ // ---------------------------------------------------------------------------
21
+ /**
22
+ * Determine the user's current setup stage and surface what's missing.
23
+ *
24
+ * Resolution order mirrors the config cascade (getConfigSafe → probeWorkspace → readSession).
25
+ * Each step is attempted only if the previous one succeeded, matching how the system
26
+ * actually behaves when a command runs.
27
+ *
28
+ * Network calls: probeWorkspace() makes one lightweight orient call. If the caller is in a
29
+ * context where network is unavailable, this returns 'authenticated' rather than throwing.
30
+ */
31
+ export async function resolveSetupState() {
32
+ // Step 1 — is an API key configured?
33
+ const configResult = getConfigSafe();
34
+ if (!configResult.ok) {
35
+ return {
36
+ stage: 'unconfigured',
37
+ missingSteps: ['API key not found'],
38
+ nextAction: 'pb login',
39
+ };
40
+ }
41
+ // Step 2 — can we reach the workspace?
42
+ const wsInfo = await probeWorkspace();
43
+ if (!wsInfo) {
44
+ return {
45
+ stage: 'authenticated',
46
+ missingSteps: ['Workspace not connected or unreachable'],
47
+ nextAction: 'pb connect',
48
+ };
49
+ }
50
+ // Step 3 — is there an active write session?
51
+ const session = readSession();
52
+ if (!session) {
53
+ return {
54
+ stage: 'workspace-bound',
55
+ missingSteps: ['No active write session'],
56
+ nextAction: 'pb session start',
57
+ workspaceName: wsInfo.name,
58
+ entryCount: wsInfo.entryCount,
59
+ sessionActive: false,
60
+ };
61
+ }
62
+ // All steps satisfied — fully active
63
+ return {
64
+ stage: 'active',
65
+ missingSteps: [],
66
+ nextAction: 'pb orient -b',
67
+ workspaceName: wsInfo.name,
68
+ entryCount: wsInfo.entryCount,
69
+ sessionActive: true,
70
+ };
71
+ }
72
+ // ---------------------------------------------------------------------------
73
+ // detectRenderTier
74
+ // ---------------------------------------------------------------------------
75
+ /**
76
+ * Determine the appropriate output rendering tier for the current process context.
77
+ *
78
+ * Priority:
79
+ * json → isJsonMode() is true (explicit --json flag or non-TTY piped output)
80
+ * plain → stdout is not a TTY (but isJsonMode() was false — e.g. --pretty on a pipe)
81
+ * ink → interactive TTY, Ink React rendering is safe
82
+ */
83
+ export function detectRenderTier() {
84
+ if (isJsonMode())
85
+ return 'json';
86
+ if (!process.stdout.isTTY)
87
+ return 'plain';
88
+ return 'ink';
89
+ }
90
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/lib/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA0BzC,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,qCAAqC;IACrC,MAAM,YAAY,GAAG,aAAa,EAAE,CAAC;IACrC,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;QACrB,OAAO;YACL,KAAK,EAAE,cAAc;YACrB,YAAY,EAAE,CAAC,mBAAmB,CAAC;YACnC,UAAU,EAAE,UAAU;SACvB,CAAC;IACJ,CAAC;IAED,uCAAuC;IACvC,MAAM,MAAM,GAAG,MAAM,cAAc,EAAE,CAAC;IACtC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,KAAK,EAAE,eAAe;YACtB,YAAY,EAAE,CAAC,wCAAwC,CAAC;YACxD,UAAU,EAAE,YAAY;SACzB,CAAC;IACJ,CAAC;IAED,6CAA6C;IAC7C,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,KAAK,EAAE,iBAAiB;YACxB,YAAY,EAAE,CAAC,yBAAyB,CAAC;YACzC,UAAU,EAAE,kBAAkB;YAC9B,aAAa,EAAE,MAAM,CAAC,IAAI;YAC1B,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,aAAa,EAAE,KAAK;SACrB,CAAC;IACJ,CAAC;IAED,qCAAqC;IACrC,OAAO;QACL,KAAK,EAAE,QAAQ;QACf,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE,cAAc;QAC1B,aAAa,EAAE,MAAM,CAAC,IAAI;QAC1B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,aAAa,EAAE,IAAI;KACpB,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB;IAC9B,IAAI,UAAU,EAAE;QAAE,OAAO,MAAM,CAAC;IAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QAAE,OAAO,OAAO,CAAC;IAC1C,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -5,14 +5,14 @@
5
5
  * Design: lightweight orient call to detect workspace reachability. Returns structured
6
6
  * workspace info on success, null on any failure (network, auth, offline).
7
7
  */
8
- import { convexCall } from './client.js';
8
+ import { kernelCall } from './client.js';
9
9
  /**
10
10
  * Attempt to detect workspace connectivity via a lightweight API call.
11
11
  * Returns workspace info on success, null on any failure.
12
12
  */
13
13
  export async function probeWorkspace() {
14
14
  try {
15
- const result = await convexCall('orient', { brief: true });
15
+ const result = await kernelCall('orient', { brief: true });
16
16
  const name = result?.workspace?.name || 'unknown';
17
17
  // Sum entry counts from orient sections if available
18
18
  let entryCount;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@productbrain/cli",
3
- "version": "0.1.0-beta.71",
3
+ "version": "0.1.0-beta.75",
4
4
  "description": "Product Brain — Chain knowledge and write-back CLI",
5
5
  "type": "module",
6
6
  "bin": {