@clue-ai/cli 0.0.15 → 0.0.17

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.
@@ -2,9 +2,15 @@ import {
2
2
  CLUE_CLI_INVOCATION_CONTRACT,
3
3
  clueCliCommand,
4
4
  } from "./cli-invocation.mjs";
5
+ import {
6
+ AI_SETUP_CONTRACT_VERSION,
7
+ API_CONNECTIVITY_CONTRACT,
8
+ DETERMINISTIC_CONTROL_MODEL,
9
+ SETUP_DOCTRINE,
10
+ } from "./setup-ai-contract.mjs";
5
11
  import { buildSetupDocumentationContract } from "./setup-documents.mjs";
6
12
 
7
- export const AI_SETUP_HELP_VERSION = "2026-05-10.lifecycle-placement-only.v4";
13
+ export const AI_SETUP_HELP_VERSION = AI_SETUP_CONTRACT_VERSION;
8
14
 
9
15
  export const buildAiSetupHelp = () => ({
10
16
  name: "@clue-ai/cli AI setup help",
@@ -13,6 +19,9 @@ export const buildAiSetupHelp = () => ({
13
19
  "Machine-readable Clue setup contract for AI coding agents. Use this before editing a customer repository for Clue setup.",
14
20
  cli_invocation: CLUE_CLI_INVOCATION_CONTRACT,
15
21
  setup_execution_contract: {
22
+ setup_doctrine: SETUP_DOCTRINE,
23
+ deterministic_control_model: DETERMINISTIC_CONTROL_MODEL,
24
+ api_connectivity_contract: API_CONNECTIVITY_CONTRACT,
16
25
  agent_primary_task:
17
26
  "Decide where to place ClueInit, ClueIdentify, ClueSetAccount, and ClueLogout in existing repository lifecycle boundaries, then apply only those minimal Clue SDK wiring changes.",
18
27
  implementation_workstreams: ["sdk_lifecycle_placement"],
@@ -57,6 +66,8 @@ export const buildAiSetupHelp = () => ({
57
66
  backend_browser_token_proxy_env: {
58
67
  variables: ["CLUE_API_KEY", "CLUE_API_BASE_URL"],
59
68
  rule: "CLUE_API_KEY stays server-side. CLUE_API_BASE_URL is used only by backend-owned browser token proxy code and is not part of backend SDK initialization. The proxy endpoint belongs to the customer backend, but it calls the Clue API server-side at /api/v1/ingest/browser-tokens. The frontend browserTokenProvider must send the frontend ClueInit serviceKey to that customer backend proxy, and the proxy must issue browser tokens for that frontend serviceKey, not the backend service key.",
69
+ origin_rule:
70
+ "The backend proxy must derive request origin from trusted request headers or server request metadata. Project key and environment must come from server configuration or be validated against it. Do not forward origin, projectKey, or environment from JSON/body payload fields under server CLUE_API_KEY.",
60
71
  },
61
72
  },
62
73
  documentation_contract: buildSetupDocumentationContract(),
@@ -68,6 +79,13 @@ export const buildAiSetupHelp = () => ({
68
79
  ai_agent_responsibility:
69
80
  "Report the command and required user verification as pending when it was not run by the user.",
70
81
  },
82
+ setup_doctor: {
83
+ owner: "ai_or_user",
84
+ ai_agent_may_run: true,
85
+ command: clueCliCommand("setup-doctor --local"),
86
+ rule: "Run setup-doctor after local frontend/backend services and required env are available. It checks API connectivity only and does not replace user-operated setup-watch.",
87
+ checked_hops: Object.keys(API_CONNECTIVITY_CONTRACT.hops),
88
+ },
71
89
  completion_boundary: {
72
90
  ai_may_claim: [
73
91
  "Clue setup code changes were applied",
@@ -8,6 +8,7 @@ import {
8
8
  CLUE_CLI_INVOCATION_CONTRACT,
9
9
  clueCliCommand,
10
10
  } from "./cli-invocation.mjs";
11
+ import { API_CONNECTIVITY_CONTRACT } from "./setup-ai-contract.mjs";
11
12
  import { buildSetupDocumentationContract } from "./setup-documents.mjs";
12
13
  import { runSetupDetect } from "./setup-detect.mjs";
13
14
 
@@ -488,6 +489,7 @@ export const runSetupPrepare = async ({
488
489
  project_key: setupContext.project_key,
489
490
  environment: setupContext.environment,
490
491
  clue_api_base_url: setupContext.clue_api_base_url,
492
+ api_connectivity_contract: API_CONNECTIVITY_CONTRACT,
491
493
  ingest_endpoints: setupContext.clue_api_base_url
492
494
  ? {
493
495
  browser: buildEndpoint(
@@ -557,6 +559,12 @@ export const runSetupPrepare = async ({
557
559
  completion_meaning:
558
560
  "required before setup-watch local completion can be trusted",
559
561
  },
562
+ {
563
+ id: "local_api_connectivity_preflight",
564
+ command: clueCliCommand("setup-doctor --local"),
565
+ completion_meaning:
566
+ "required before user setup-watch; verifies customer proxy, Clue browser-token issuance, browser ingest, and backend ingest connectivity when local services and required env are available",
567
+ },
560
568
  {
561
569
  id: "local_event_delivery",
562
570
  command: `user runs ${clueCliCommand("setup-watch --local")}`,
@@ -7,6 +7,11 @@ import {
7
7
  CLUE_CLI_RECOMMENDED_PREFIX,
8
8
  clueCliCommand,
9
9
  } from "./cli-invocation.mjs";
10
+ import {
11
+ AI_SETUP_CONTRACT_VERSION,
12
+ API_CONNECTIVITY_CONTRACT,
13
+ setupDoctrineSkillLines,
14
+ } from "./setup-ai-contract.mjs";
10
15
  import { buildSetupDocumentationContract } from "./setup-documents.mjs";
11
16
 
12
17
  const SKILL_NAMES = [
@@ -19,7 +24,7 @@ const SKILL_NAMES = [
19
24
  "clue-local-verification",
20
25
  "clue-setup-report",
21
26
  ];
22
- const SETUP_SKILL_CONTENT_VERSION = "2026-05-10.lifecycle-placement-only.v4";
27
+ const SETUP_SKILL_CONTENT_VERSION = AI_SETUP_CONTRACT_VERSION;
23
28
 
24
29
  const TARGETS = new Set(["codex", "claude_code"]);
25
30
 
@@ -82,7 +87,7 @@ const skillBody = (name, { documentsUrl } = {}) => {
82
87
  "clue-setup-audit":
83
88
  "Read-only monitoring agent. Owns P0/P1 review for one completed workstream at a time. It must not edit files.",
84
89
  "clue-local-verification":
85
- "Read-only verification agent. Owns static setup checks, dependency/import/startup evidence, and user verification handoff. It must not edit files or run setup-watch automatically.",
90
+ "Read-only verification agent. Owns static setup checks, setup-doctor API connectivity preflight, dependency/import/startup evidence, and user verification handoff. It must not edit files or run setup-watch automatically.",
86
91
  "clue-setup-report":
87
92
  "Final reporting agent. Owns concise completion evidence only after execution and monitoring gates pass.",
88
93
  };
@@ -128,6 +133,7 @@ const skillBody = (name, { documentsUrl } = {}) => {
128
133
  ],
129
134
  "clue-local-verification": [
130
135
  "`setup-check` evidence",
136
+ "`setup-doctor --local` API connectivity preflight when local services and required env are available",
131
137
  "user-operated `setup-watch --local` handoff readiness",
132
138
  "local URL confirmation without assuming ports",
133
139
  ],
@@ -322,9 +328,10 @@ const skillBody = (name, { documentsUrl } = {}) => {
322
328
  "Never put `CLUE_API_KEY` in frontend code, frontend env files, browser bundles, or client-readable config.",
323
329
  "When browser SDK ingest is configured, implement a backend-owned browser token endpoint that reads server-side `CLUE_API_KEY` and requests `POST /api/v1/ingest/browser-tokens` from Clue.",
324
330
  "Configure frontend `ClueInit` with `browserTokenProvider` that calls the local backend token endpoint and returns the token string.",
325
- "The local backend token endpoint is part of the customer app, not the Clue API. It may be named with the customer app's route convention, but it must call Clue server-side at `/api/v1/ingest/browser-tokens`.",
331
+ "The local backend token endpoint is part of the customer app, not the Clue API. Place it under a Clue-reserved local route such as `/api/v1/clue/browser-tokens`; do not use a generic path such as `/browser-tokens` that could be confused with product behavior. It must call Clue server-side at `/api/v1/ingest/browser-tokens`.",
326
332
  "The frontend `browserTokenProvider` must send the same service key used by `ClueInit` to the customer backend token endpoint. For Next.js this value comes from `NEXT_PUBLIC_CLUE_SERVICE_KEY`.",
327
- "The browser token request must include project key, environment, service key, and the current browser origin; the backend must attach `x-clue-api-key` server-side when calling Clue.",
333
+ "The browser token request must include the frontend service key used by `ClueInit`. Project key and environment may be included only as public consistency hints; the backend must use server configuration or validate them against server configuration before calling Clue.",
334
+ "The backend browser token proxy must derive origin from trusted request headers or server request metadata. Do not forward `origin`, `projectKey`, or `environment` from JSON/body payload fields under server `CLUE_API_KEY`.",
328
335
  "For browser token proxy code, the service key sent to Clue must be the frontend `ClueInit` serviceKey from the browser request, not the backend service's `CLUE_SERVICE_KEY`.",
329
336
  "If a backend-owned browser token endpoint is implemented, read `CLUE_API_BASE_URL` from the backend env block and normalize it so values with or without a trailing `/api/v1` do not produce duplicate paths.",
330
337
  "For FastAPI code, add `clue-fastapi-sdk` to the backend dependency file when missing, import `clue_init_fastapi` plus `ClueIdentify`, `ClueSetAccount`, and `ClueLogout` where needed, and use `CLUE_PROJECT_KEY`, `CLUE_ENVIRONMENT`, `CLUE_API_KEY`, and `CLUE_INGEST_ENDPOINT` from the backend env block.",
@@ -359,6 +366,7 @@ const skillBody = (name, { documentsUrl } = {}) => {
359
366
  "Reject Django SDK setup when `clue-django-sdk` installability has not been verified.",
360
367
  "Reject backend setup when backend routes exist but no backend Clue SDK dependency/import/init was added.",
361
368
  "Reject awaited lifecycle calls that can block host service behavior.",
369
+ "Reject browser token proxy code that forwards origin, projectKey, or environment from request JSON/body under server `CLUE_API_KEY`.",
362
370
  "Reject setup that covers only one login path when multiple login success paths are clearly present.",
363
371
  "Reject ClueInit inside React component lifecycle hooks, page components, sidebars, login/register success callbacks, or any repeated user interaction path.",
364
372
  "Reject broad ClueTrack instrumentation and DOM clue tags.",
@@ -384,6 +392,7 @@ const skillBody = (name, { documentsUrl } = {}) => {
384
392
  "Confirm the semantic workflow does not send GitHub actor, triggering_actor, sender, repository owner, repository name, or default branch to Clue.",
385
393
  "Confirm `.clue/semantic-request.runtime.json` is not created, committed, or staged.",
386
394
  `Run \`${clueCliCommand("setup-check --framework <framework> --backend-root-path <path> --repo . --target <codex|claude_code> --require-sdk-lifecycle")}\` when possible.`,
395
+ `Run \`${clueCliCommand("setup-doctor --local")}\` when local frontend/backend services are running and required env values are available. Report skipped_setup_doctor with the missing service URL or env name when it cannot run.`,
387
396
  `Do not run \`${clueCliCommand("setup-watch --local")}\` automatically. setup-watch requires the user to operate real local frontend/backend services and login/logout/account flows.`,
388
397
  "If the user has not provided setup-watch or setup-screen evidence, report event delivery verification as `user_verification_pending` and do not state `setup completed`.",
389
398
  "Local static verification passed does not mean setup complete unless dependency install, SDK imports, app startup, and user-provided setup-watch or setup-screen event delivery were all verified.",
@@ -436,6 +445,7 @@ const skillBody = (name, { documentsUrl } = {}) => {
436
445
  "",
437
446
  "# Shared Rules",
438
447
  "",
448
+ ...setupDoctrineSkillLines(),
439
449
  "- For full Clue setup, use one SDK lifecycle placement implementation agent and multiple monitoring agents for read-only checks.",
440
450
  `- Clue CLI public npm package: \`${CLUE_CLI_PACKAGE_NAME}\`.`,
441
451
  `- Clue CLI binary name exposed by that package: \`${CLUE_CLI_BINARY_NAME}\`; a global \`${CLUE_CLI_BINARY_NAME}\` install is not required.`,
@@ -451,7 +461,11 @@ const skillBody = (name, { documentsUrl } = {}) => {
451
461
  "- Only exact changes required to place ClueInit, ClueIdentify, ClueSetAccount, and ClueLogout are allowed. Do not perform ClueTrack instrumentation unless the user explicitly requested product event tracking.",
452
462
  "- Do not perform unrelated refactors, renames, file moves, formatting churn, broad cleanup, business logic rewrites, auth/session rewrites beyond minimal Clue hook insertion, UI changes unrelated to Clue setup, or unrelated dependency upgrades.",
453
463
  "- Do not run broad formatters or make whitespace-only cleanup. Keep formatting changes limited to lines directly touched for Clue SDK wiring.",
454
- "- A customer backend browser-token endpoint is only a proxy for browser SDK token issuance. It is not the Clue API itself; the backend must call Clue server-side at `/api/v1/ingest/browser-tokens` with the frontend `ClueInit` service key supplied by the browser token provider.",
464
+ "- A customer backend browser-token endpoint is only a proxy for browser SDK token issuance. It must live under a Clue-reserved local route such as `/api/v1/clue/browser-tokens`, not a generic product-looking path such as `/browser-tokens`. It is not the Clue API itself; the backend must call Clue server-side at `/api/v1/ingest/browser-tokens` with the frontend `ClueInit` service key supplied by the browser token provider and server-owned project/environment values.",
465
+ `- Setup API connectivity has four distinct hops: ${Object.entries(API_CONNECTIVITY_CONTRACT.hops)
466
+ .map(([name, hop]) => `${name}=${hop.method} ${hop.path}`)
467
+ .join(", ")}.`,
468
+ `- Run \`${clueCliCommand("setup-doctor --local")}\` when local services and required env are available. This checks API connectivity only; it does not replace user-operated setup-watch.`,
455
469
  "- Do not implement or refresh semantic snapshot CI during lifecycle placement; report a blocker if generated semantic artifacts are missing or stale.",
456
470
  `- Do not run \`${clueCliCommand("setup-watch --local")}\` automatically. setup-watch and the Clue setup screen are user-operated verification steps, not implementation-agent responsibility.`,
457
471
  "- The full setup must start with `clue-setup-orchestrator`.",