@clue-ai/cli 0.0.9 → 0.0.10

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.
@@ -0,0 +1,69 @@
1
+ import {
2
+ CLUE_CLI_INVOCATION_CONTRACT,
3
+ clueCliCommand,
4
+ } from "./cli-invocation.mjs";
5
+
6
+ export const AI_SETUP_HELP_VERSION = "2026-05-10.lifecycle-placement-only.v1";
7
+
8
+ export const buildAiSetupHelp = () => ({
9
+ name: "@clue-ai/cli AI setup help",
10
+ version: AI_SETUP_HELP_VERSION,
11
+ purpose:
12
+ "Machine-readable Clue setup contract for AI coding agents. Use this before editing a customer repository for Clue setup.",
13
+ cli_invocation: CLUE_CLI_INVOCATION_CONTRACT,
14
+ setup_execution_contract: {
15
+ agent_primary_task:
16
+ "Decide where to place ClueInit, ClueIdentify, ClueSetAccount, and ClueLogout in existing repository lifecycle boundaries, then apply only those minimal Clue SDK wiring changes.",
17
+ implementation_workstreams: ["sdk_lifecycle_placement"],
18
+ lifecycle_apis_in_scope: [
19
+ "ClueInit",
20
+ "ClueIdentify",
21
+ "ClueSetAccount",
22
+ "ClueLogout",
23
+ ],
24
+ lifecycle_apis_out_of_scope_by_default: ["ClueTrack"],
25
+ allowed_change_scope: {
26
+ rule: "Only changes required to place ClueInit, ClueIdentify, ClueSetAccount, and ClueLogout are allowed.",
27
+ allowed: [
28
+ "Clue SDK dependency declarations and lockfile changes needed to install those SDKs",
29
+ "Clue SDK imports, bootstrap adapters, and single initialization points",
30
+ "backend-owned browser token endpoints required so frontend SDK code never exposes CLUE_API_KEY",
31
+ "Clue lifecycle calls at existing clear login, logout, account, workspace, organization, or tenant boundaries",
32
+ "tests or verification scripts directly proving the four lifecycle API placement decisions",
33
+ ],
34
+ forbidden: [
35
+ "ClueTrack instrumentation unless the user explicitly requested product event tracking",
36
+ "semantic snapshot implementation or CI workflow edits during lifecycle placement",
37
+ "unrelated refactors, renames, file moves, formatting churn, or broad cleanup",
38
+ "business logic changes that are not required for Clue setup",
39
+ "auth/session flow rewrites beyond the minimal Clue hook insertion point",
40
+ "UI layout, styling, copy, or navigation changes unrelated to Clue setup",
41
+ "dependency upgrades unrelated to Clue SDK installability",
42
+ "hand-authored semantic snapshot artifacts or runtime request files",
43
+ ],
44
+ },
45
+ setup_watch: {
46
+ owner: "user",
47
+ ai_agent_must_run: false,
48
+ command: clueCliCommand("setup-watch --local"),
49
+ rule: "Do not run setup-watch during implementation. setup-watch and the Clue setup screen require user-operated local services and real login/logout/account flows.",
50
+ ai_agent_responsibility:
51
+ "Report the command and required user verification as pending when it was not run by the user.",
52
+ },
53
+ completion_boundary: {
54
+ ai_may_claim: [
55
+ "Clue setup code changes were applied",
56
+ "static setup-check passed",
57
+ "SDK dependency install/import/build/typecheck checks passed when actually run",
58
+ ],
59
+ ai_must_not_claim: [
60
+ "setup completed",
61
+ "event delivery verified",
62
+ "setup-watch passed",
63
+ "Clue setup screen verification passed",
64
+ ],
65
+ final_status_when_setup_watch_not_user_verified:
66
+ "user_verification_pending",
67
+ },
68
+ },
69
+ });
@@ -4,6 +4,10 @@ import {
4
4
  buildSemanticWorkflowRequestFromFlags,
5
5
  writeSemanticWorkflow,
6
6
  } from "./init-tool.mjs";
7
+ import {
8
+ CLUE_CLI_INVOCATION_CONTRACT,
9
+ clueCliCommand,
10
+ } from "./cli-invocation.mjs";
7
11
  import { runSetupDetect } from "./setup-detect.mjs";
8
12
 
9
13
  const DEFAULT_SETUP_MANIFEST_PATH = ".clue/setup-manifest.json";
@@ -222,6 +226,9 @@ const buildEnvironmentInstructions = ({ manifest, setupContext }) => {
222
226
  },
223
227
  ],
224
228
  variables: [
229
+ { name: "CLUE_PROJECT_KEY", value: setupContext.project_key },
230
+ { name: "CLUE_ENVIRONMENT", value: setupContext.environment },
231
+ { name: "CLUE_API_BASE_URL", value: setupContext.clue_api_base_url },
225
232
  {
226
233
  name: "CLUE_AI_PROVIDER",
227
234
  value: aiProviderGuide.provider,
@@ -282,8 +289,7 @@ const summarizeEnvironmentInstructions = (instructions) => {
282
289
  return {
283
290
  status: "ready",
284
291
  env_file_path: instructions.env_file_path,
285
- message:
286
- `${instructions.env_file_path} を開き、各サービスの env と GitHub Secrets に反映してください。`,
292
+ message: `${instructions.env_file_path} を開き、各サービスの env と GitHub Secrets に反映してください。`,
287
293
  service_env_block_count: instructions.service_env_blocks.length,
288
294
  github_secret_names: instructions.ci_github.secrets.map(
289
295
  (entry) => entry.name,
@@ -326,8 +332,18 @@ export const runSetupPrepare = async ({
326
332
  ai_next_scope: "blocked_until_backend_routes_are_detected",
327
333
  machine_owned_artifacts: [],
328
334
  ai_owned_workstreams: [
329
- "sdk_lifecycle_implementation_after_blockers_are_resolved",
335
+ "sdk_lifecycle_placement_after_blockers_are_resolved",
330
336
  ],
337
+ ai_implementation_scope: {
338
+ rule: "AI implementation is limited to placing ClueInit, ClueIdentify, ClueSetAccount, and ClueLogout in existing lifecycle boundaries after blockers are resolved.",
339
+ lifecycle_apis: [
340
+ "ClueInit",
341
+ "ClueIdentify",
342
+ "ClueSetAccount",
343
+ "ClueLogout",
344
+ ],
345
+ out_of_scope_by_default: ["ClueTrack"],
346
+ },
331
347
  };
332
348
  await writeJson({
333
349
  repoRoot: resolvedRepoRoot,
@@ -340,8 +356,9 @@ export const runSetupPrepare = async ({
340
356
  });
341
357
  return {
342
358
  ...manifest,
343
- environment_instructions:
344
- summarizeEnvironmentInstructions(environmentInstructions),
359
+ environment_instructions: summarizeEnvironmentInstructions(
360
+ environmentInstructions,
361
+ ),
345
362
  };
346
363
  }
347
364
 
@@ -349,9 +366,6 @@ export const runSetupPrepare = async ({
349
366
  framework: candidate.framework,
350
367
  backendRootPath: candidate.backend_root_path,
351
368
  serviceKey: candidate.service_key,
352
- projectKey: setupContext.project_key,
353
- environment: setupContext.environment,
354
- clueApiBaseUrl: setupContext.clue_api_base_url,
355
369
  });
356
370
  const workflow = await writeSemanticWorkflow({
357
371
  repoRoot: resolvedRepoRoot,
@@ -373,6 +387,7 @@ export const runSetupPrepare = async ({
373
387
  frontend_env_name: "CLUE_SERVICE_KEY",
374
388
  producer_id_derivation: "producer_id defaults to service_key",
375
389
  },
390
+ cli_invocation: CLUE_CLI_INVOCATION_CONTRACT,
376
391
  clue_context: {
377
392
  project_key: setupContext.project_key,
378
393
  environment: setupContext.environment,
@@ -391,9 +406,11 @@ export const runSetupPrepare = async ({
391
406
  : null,
392
407
  },
393
408
  lifecycle_verification: {
409
+ owner: "user",
410
+ ai_agent_must_run_setup_watch: false,
394
411
  watch_target_format:
395
412
  "frontend:<service-key>[init,identify,set-account,logout,event-sent]=<frontend-url>,backend:<service-key>[init,identify,set-account,logout,event-sent]=<backend-url>",
396
- rule: "setup-watch --local uses the structured watch_targets below. Lifecycle checks are fixed for setup verification and are evaluated per service_key.",
413
+ rule: "setup-watch --local uses the structured watch_targets below, but it is user-operated verification. AI implementation agents must not run setup-watch automatically.",
397
414
  watch_targets: buildWatchTargets(detection, candidate),
398
415
  },
399
416
  artifacts: {
@@ -403,12 +420,54 @@ export const runSetupPrepare = async ({
403
420
  },
404
421
  machine_owned_artifacts: [workflow.ci_workflow_path, setupManifestPath],
405
422
  ai_must_not_edit: [workflow.ci_workflow_path],
406
- ai_owned_workstreams: ["sdk_lifecycle_implementation"],
423
+ ai_owned_workstreams: ["sdk_lifecycle_placement"],
424
+ ai_implementation_scope: {
425
+ rule: "AI implementation is limited to placing ClueInit, ClueIdentify, ClueSetAccount, and ClueLogout in existing lifecycle boundaries plus the minimal SDK wiring required for those calls.",
426
+ lifecycle_apis: [
427
+ "ClueInit",
428
+ "ClueIdentify",
429
+ "ClueSetAccount",
430
+ "ClueLogout",
431
+ ],
432
+ out_of_scope_by_default: ["ClueTrack"],
433
+ },
407
434
  required_final_check: {
408
- command:
409
- `npx @clue-ai/cli setup-check --framework ${candidate.framework} ` +
410
- `--backend-root-path ${candidate.backend_root_path} --repo . --target ${target} --require-sdk-lifecycle`,
435
+ command: clueCliCommand(
436
+ `setup-check --framework ${candidate.framework} ` +
437
+ `--backend-root-path ${candidate.backend_root_path} --repo . --target ${target} --require-sdk-lifecycle`,
438
+ ),
411
439
  },
440
+ required_final_verification: [
441
+ {
442
+ id: "static_setup_check",
443
+ command: clueCliCommand(
444
+ `setup-check --framework ${candidate.framework} ` +
445
+ `--backend-root-path ${candidate.backend_root_path} --repo . --target ${target} --require-sdk-lifecycle`,
446
+ ),
447
+ completion_meaning:
448
+ "static_passed_only_dependency_install_import_app_startup_and_event_delivery_still_required",
449
+ },
450
+ {
451
+ id: "sdk_dependency_install_and_import",
452
+ command:
453
+ "run the repository package-manager install plus frontend/backend SDK import checks in the target environments",
454
+ completion_meaning:
455
+ "required before claiming SDK lifecycle setup is complete",
456
+ },
457
+ {
458
+ id: "app_startup",
459
+ command:
460
+ "start the affected frontend/backend services and verify their configured local URLs respond",
461
+ completion_meaning:
462
+ "required before setup-watch local completion can be trusted",
463
+ },
464
+ {
465
+ id: "local_event_delivery",
466
+ command: `user runs ${clueCliCommand("setup-watch --local")}`,
467
+ completion_meaning:
468
+ "requires user-operated local services plus expected lifecycle event delivery; AI agents must report user_verification_pending when user evidence is not provided",
469
+ },
470
+ ],
412
471
  required_env_names: [
413
472
  "CLUE_SERVICE_KEY",
414
473
  "CLUE_API_KEY",
@@ -450,7 +509,8 @@ export const runSetupPrepare = async ({
450
509
  ...manifestWithEnvironmentArtifact.artifacts,
451
510
  environment_file_path: environmentFilePath,
452
511
  },
453
- environment_instructions:
454
- summarizeEnvironmentInstructions(environmentInstructions),
512
+ environment_instructions: summarizeEnvironmentInstructions(
513
+ environmentInstructions,
514
+ ),
455
515
  };
456
516
  };