product-console-companion 0.4.0 → 0.5.0

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/README.md CHANGED
@@ -9,12 +9,12 @@ your own machine, so:
9
9
  `MAX_FILE_CHARS`/`MAX_TREE_PATHS` don't apply here at all);
10
10
  - AI spend bills against your own key/subscription, not the workspace's shared/BYOK credential.
11
11
 
12
- Covers every AI call the hosted Console makes that reads your code — six task kinds as of this
13
- release (`verify_module` — "Check against code" on a module card; `generate_spec_batch` —
14
- writing full specs during setup; `propose_skeleton` and `propose_new_capabilities` — the two
15
- shallow whole-repo scans; `design_prompt` — the free-text export; `analyse_shipment` — the
16
- passive per-commit drift check behind the GitHub webhook and the "Check GitHub" button), two
17
- backends, chosen per connection at `connect` time:
12
+ Runs every AI task the hosted Console dispatches. That includes the repo-aware setup and code
13
+ checks as well as graph reasoning such as impact analysis, reviews, coupling maps, graph Q&A,
14
+ edge descriptions, and exports. Graph-reasoning tasks receive all of their context from the
15
+ Console and run connectionless with zero filesystem access. New server-side graph-reasoning task
16
+ kinds use the same safe fallback without requiring another companion release. Two backends are
17
+ available, chosen per connection at `connect` time:
18
18
 
19
19
  - **`api-key`** (default) — no CLI dependency. Calls Anthropic directly with your own API key
20
20
  (`api-key-caller.ts`), running its own two-pass file-select-then-judge, mirroring
@@ -300,7 +300,16 @@ ${repoCtx.packageJson ?? '(none found)'}
300
300
  const text = message.content.find((b) => b.type === 'text');
301
301
  if (!text || text.type !== 'text')
302
302
  throw new Error('No result returned.');
303
- return { result: JSON.parse(text.text), filesRead: [] };
303
+ return { result: spec.schema ? JSON.parse(text.text) : text.text, filesRead: [] };
304
+ }
305
+ /** Forward-compatible fallback for server-created graph/spec reasoning tasks. The server sends
306
+ * the complete self-describing spec, so these calls never need or receive filesystem context. */
307
+ export async function runGenericTask(client, task, repoPath) {
308
+ const spec = task.payload?.spec;
309
+ if (!spec || typeof spec !== 'object' || Array.isArray(spec)) {
310
+ throw new Error(`Cannot run task kind "${task.kind}": payload.spec is missing or not an object.`);
311
+ }
312
+ return runShallowRepoTask(client, spec, repoPath, true);
304
313
  }
305
314
  export async function runProposeSkeletonTask(client, task, repoPath) {
306
315
  const payload = task.payload;
@@ -135,6 +135,15 @@ async function runViaCli(spec, maxBudgetUsd, repoPath, connectionless = false) {
135
135
  await sandbox.cleanup();
136
136
  }
137
137
  }
138
+ /** Forward-compatible fallback for server-created graph/spec reasoning tasks. The server sends
139
+ * the complete self-describing spec, so these calls run connectionless with zero tools. */
140
+ export async function runGenericTaskViaCli(task, repoPath) {
141
+ const spec = task.payload?.spec;
142
+ if (!spec || typeof spec !== 'object' || Array.isArray(spec)) {
143
+ throw new Error(`Cannot run task kind "${task.kind}": payload.spec is missing or not an object.`);
144
+ }
145
+ return runViaCli(spec, task.maxBudgetUsd, repoPath, true);
146
+ }
138
147
  export async function runVerifyModuleTaskViaCli(task, repoPath) {
139
148
  const payload = task.payload;
140
149
  return runViaCli(payload.spec, task.maxBudgetUsd, repoPath);
package/dist/cli.js CHANGED
@@ -5,8 +5,8 @@ import { resolve } from 'node:path';
5
5
  import { addConnection, configPath, enableWorkspacePolling, loadConfig } from './config.js';
6
6
  import { CompanionClient, CompanionHttpError } from './http-client.js';
7
7
  import { assertIsRepo, currentCommit } from './local-scan.js';
8
- import { runAnalyseShipmentTask, runDesignPromptTask, runGenerateSpecBatchTask, runProposeNewCapabilitiesTask, runProposeSkeletonTask, runVerifyModuleTask } from './api-key-caller.js';
9
- import { runAnalyseShipmentTaskViaCli, runDesignPromptTaskViaCli, runGenerateSpecBatchTaskViaCli, runProposeNewCapabilitiesTaskViaCli, runProposeSkeletonTaskViaCli, runVerifyModuleTaskViaCli } from './claude-cli-caller.js';
8
+ import { runAnalyseShipmentTask, runDesignPromptTask, runGenerateSpecBatchTask, runGenericTask, runProposeNewCapabilitiesTask, runProposeSkeletonTask, runVerifyModuleTask } from './api-key-caller.js';
9
+ import { runAnalyseShipmentTaskViaCli, runDesignPromptTaskViaCli, runGenerateSpecBatchTaskViaCli, runGenericTaskViaCli, runProposeNewCapabilitiesTaskViaCli, runProposeSkeletonTaskViaCli, runVerifyModuleTaskViaCli } from './claude-cli-caller.js';
10
10
  /** A flag with nothing after it (end of argv, or the next token is itself another "--flag") is
11
11
  * treated as a bare boolean ("true") rather than swallowing the following flag as its value —
12
12
  * needed for --no-run below. Every existing "--flag value" pair still parses exactly as before. */
@@ -136,9 +136,11 @@ const IDLE_POLL_MS = 5000;
136
136
  /** How often to extend a claimed task's lease while it's in flight — comfortably inside the
137
137
  * server's ~2-minute lease window (server/store.ts's LOCAL_TASK_LEASE_MS). */
138
138
  const HEARTBEAT_MS = 30_000;
139
- /** The task-kind registry, companion-side — one entry per kind this companion knows how to run,
140
- * each backed by both backends. Grows by one entry per phase, same as the server's own registry
141
- * (server/companion.ts's TASK_RESULT_SCHEMAS) — the two lists should always name the same kinds. */
139
+ /** The explicitly repo-aware task kinds, companion-side. Everything else falls through to a
140
+ * connectionless runner: only our server creates tasks, their ModelTaskSpec is self-describing
141
+ * (model, effort, maxTokens, system, stable/volatile text, optional schema), and graph reasoning
142
+ * has nothing legitimate to read from disk. That also makes future server kinds work without a
143
+ * companion release. */
142
144
  async function runTask(task, backend, anthropic, repoPath) {
143
145
  if (task.kind === 'verify_module') {
144
146
  return backend === 'cli' ? runVerifyModuleTaskViaCli(task, repoPath) : runVerifyModuleTask(anthropic, task, repoPath); // anthropic is always set for backend 'api-key' — see cmdRun
@@ -158,7 +160,7 @@ async function runTask(task, backend, anthropic, repoPath) {
158
160
  if (task.kind === 'analyse_shipment') {
159
161
  return backend === 'cli' ? runAnalyseShipmentTaskViaCli(task, repoPath) : runAnalyseShipmentTask(anthropic, task, repoPath);
160
162
  }
161
- throw new Error(`This companion doesn't know how to run task kind "${task.kind}" yet.`);
163
+ return backend === 'cli' ? runGenericTaskViaCli(task, repoPath) : runGenericTask(anthropic, task, repoPath);
162
164
  }
163
165
  async function runOneTask(anthropic, backend, client, repoPath, task) {
164
166
  console.log(`[${new Date().toISOString()}] claimed ${task.kind} task ${task.id} via ${backend} (budget $${task.maxBudgetUsd.toFixed(2)} — not yet enforced client-side, see README)`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "product-console-companion",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Local-first BYOS companion for the Fynch Product Console — reads code and runs AI calls from your own machine instead of the hosted server.",
5
5
  "type": "module",
6
6
  "license": "MIT",