@clue-ai/cli 0.0.4 → 0.0.6

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,289 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import { dirname, join, resolve } from "node:path";
3
+ import {
4
+ buildSemanticWorkflowRequestFromFlags,
5
+ writeSemanticWorkflow,
6
+ } from "./init-tool.mjs";
7
+ import { runSetupDetect } from "./setup-detect.mjs";
8
+
9
+ const DEFAULT_SETUP_MANIFEST_PATH = ".clue/setup-manifest.json";
10
+ const BROWSER_INGEST_PATH = "/api/v1/ingest/browser";
11
+ const BACKEND_INGEST_PATH = "/api/v1/ingest/backend";
12
+
13
+ const writeJson = async ({ repoRoot, path, value }) => {
14
+ const absolutePath = join(resolve(repoRoot), path);
15
+ await mkdir(dirname(absolutePath), { recursive: true });
16
+ await writeFile(absolutePath, `${JSON.stringify(value, null, 2)}\n`, "utf8");
17
+ };
18
+
19
+ const firstCandidateOrBlocker = (detection) => {
20
+ if (!detection.detected || detection.candidates.length === 0) {
21
+ return {
22
+ candidate: null,
23
+ blockers: detection.blockers.length
24
+ ? detection.blockers
25
+ : [
26
+ {
27
+ code: "NO_SETUP_CANDIDATE",
28
+ message: "No setup candidate was mechanically detected.",
29
+ },
30
+ ],
31
+ };
32
+ }
33
+ return {
34
+ candidate: detection.candidates[0],
35
+ blockers: [],
36
+ };
37
+ };
38
+
39
+ const DEFAULT_SETUP_LIFECYCLE = [
40
+ "init",
41
+ "identify",
42
+ "set-account",
43
+ "logout",
44
+ "event-sent",
45
+ ];
46
+
47
+ const buildWatchTargets = (detection, fallbackCandidate) => {
48
+ const frontendServices = Array.isArray(detection.services?.frontend)
49
+ ? detection.services.frontend
50
+ : [];
51
+ const backendServices = Array.isArray(detection.services?.backend)
52
+ ? detection.services.backend
53
+ : [
54
+ {
55
+ kind: "backend",
56
+ framework: fallbackCandidate.framework,
57
+ root_path: fallbackCandidate.backend_root_path,
58
+ service_key: fallbackCandidate.service_key,
59
+ local_url_candidates: [],
60
+ },
61
+ ];
62
+ return [...frontendServices, ...backendServices].map((service) => ({
63
+ kind: service.kind,
64
+ framework: service.framework,
65
+ root_path: service.root_path,
66
+ service_key: service.service_key,
67
+ producer_id: service.service_key,
68
+ expected_lifecycle: DEFAULT_SETUP_LIFECYCLE,
69
+ local_url_candidates: service.local_url_candidates ?? [],
70
+ url_env_name:
71
+ service.kind === "frontend"
72
+ ? `CLUE_LOCAL_${service.service_key.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_FRONTEND_URL`
73
+ : `CLUE_LOCAL_${service.service_key.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_BACKEND_URL`,
74
+ }));
75
+ };
76
+
77
+ const optionalString = (value) =>
78
+ typeof value === "string" && value.trim() ? value.trim() : null;
79
+
80
+ const trimTrailingSlash = (value) => String(value).replace(/\/+$/, "");
81
+
82
+ const buildEndpoint = (baseUrl, path) => `${trimTrailingSlash(baseUrl)}${path}`;
83
+
84
+ const setupContextFromInput = (input = {}) => ({
85
+ clue_api_key: optionalString(input.clueApiKey),
86
+ clue_api_base_url: optionalString(input.clueApiBaseUrl),
87
+ project_key: optionalString(input.projectKey),
88
+ environment: optionalString(input.environment),
89
+ });
90
+
91
+ const envFileCandidates = (target) => {
92
+ if (target.kind === "frontend") {
93
+ return target.framework === "nextjs" ? [".env.local"] : [".env"];
94
+ }
95
+ return [".env"];
96
+ };
97
+
98
+ const buildServiceEnvBlock = ({ target, setupContext }) => {
99
+ const ingestPath =
100
+ target.kind === "frontend" ? BROWSER_INGEST_PATH : BACKEND_INGEST_PATH;
101
+ const variables = [
102
+ {
103
+ name: "CLUE_INGEST_ENDPOINT",
104
+ value: buildEndpoint(setupContext.clue_api_base_url, ingestPath),
105
+ },
106
+ { name: "CLUE_PROJECT_KEY", value: setupContext.project_key },
107
+ { name: "CLUE_ENVIRONMENT", value: setupContext.environment },
108
+ { name: "CLUE_SERVICE_KEY", value: target.service_key },
109
+ ];
110
+ if (target.kind === "backend") {
111
+ variables.push({ name: "CLUE_API_KEY", value: setupContext.clue_api_key });
112
+ }
113
+ return variables.map(({ name, value }) => `${name}=${value}`).join("\n");
114
+ };
115
+
116
+ const buildEnvironmentInstructions = ({ manifest, setupContext }) => {
117
+ const missingFlags = [
118
+ ["clue_api_key", "--clue-api-key"],
119
+ ["clue_api_base_url", "--clue-api-base-url"],
120
+ ["project_key", "--project-key"],
121
+ ["environment", "--environment"],
122
+ ]
123
+ .filter(([key]) => !setupContext[key])
124
+ .map(([, flag]) => flag);
125
+
126
+ if (missingFlags.length > 0 || manifest.status !== "ready_for_ai") {
127
+ return {
128
+ status: "missing_setup_arguments",
129
+ required_flags: missingFlags,
130
+ message:
131
+ "Run setup with Clue values from the setup screen to print service-specific env blocks.",
132
+ };
133
+ }
134
+
135
+ const watchTargets = manifest.lifecycle_verification.watch_targets;
136
+ return {
137
+ status: "ready",
138
+ message: "各サービスの env ファイルに以下を設定してください。",
139
+ service_env_blocks: watchTargets.map((target) => ({
140
+ kind: target.kind,
141
+ framework: target.framework,
142
+ root_path: target.root_path,
143
+ service_key: target.service_key,
144
+ env_file_candidates: envFileCandidates(target),
145
+ env_block: buildServiceEnvBlock({ target, setupContext }),
146
+ })),
147
+ ci_github: {
148
+ secrets: [
149
+ { name: "CLUE_API_KEY", value: setupContext.clue_api_key },
150
+ {
151
+ name: "CLUE_AI_PROVIDER_API_KEY",
152
+ value: "<openai-or-anthropic-api-key>",
153
+ },
154
+ ],
155
+ variables: [
156
+ { name: "CLUE_AI_PROVIDER", value: "<openai-or-anthropic>" },
157
+ { name: "CLUE_AI_MODEL", value: "<selected-provider-model>" },
158
+ ],
159
+ },
160
+ };
161
+ };
162
+
163
+ export const runSetupPrepare = async ({
164
+ repoRoot,
165
+ target,
166
+ skillRoot,
167
+ setupContext: setupContextInput,
168
+ setupManifestPath = DEFAULT_SETUP_MANIFEST_PATH,
169
+ }) => {
170
+ const resolvedRepoRoot = resolve(repoRoot ?? ".");
171
+ const setupContext = setupContextFromInput(setupContextInput);
172
+ const detection = await runSetupDetect({ repoRoot: resolvedRepoRoot });
173
+ const { candidate, blockers } = firstCandidateOrBlocker(detection);
174
+ if (!candidate) {
175
+ const manifest = {
176
+ status: "blocked",
177
+ target,
178
+ skill_root: skillRoot,
179
+ blockers,
180
+ detection,
181
+ ai_next_scope: "blocked_until_backend_routes_are_detected",
182
+ machine_owned_artifacts: [],
183
+ ai_owned_workstreams: [
184
+ "sdk_lifecycle_implementation_after_blockers_are_resolved",
185
+ ],
186
+ };
187
+ await writeJson({
188
+ repoRoot: resolvedRepoRoot,
189
+ path: setupManifestPath,
190
+ value: manifest,
191
+ });
192
+ return {
193
+ ...manifest,
194
+ environment_instructions: buildEnvironmentInstructions({
195
+ manifest,
196
+ setupContext,
197
+ }),
198
+ };
199
+ }
200
+
201
+ const request = buildSemanticWorkflowRequestFromFlags({
202
+ framework: candidate.framework,
203
+ backendRootPath: candidate.backend_root_path,
204
+ serviceKey: candidate.service_key,
205
+ projectKey: setupContext.project_key,
206
+ environment: setupContext.environment,
207
+ clueApiBaseUrl: setupContext.clue_api_base_url,
208
+ });
209
+ const workflow = await writeSemanticWorkflow({
210
+ repoRoot: resolvedRepoRoot,
211
+ request,
212
+ });
213
+
214
+ const manifest = {
215
+ status: "ready_for_ai",
216
+ target,
217
+ skill_root: skillRoot,
218
+ detected: {
219
+ framework: candidate.framework,
220
+ backend_root_path: candidate.backend_root_path,
221
+ service_key: candidate.service_key,
222
+ },
223
+ service_identity: {
224
+ canonical_field: "service_key",
225
+ backend_env_name: "CLUE_SERVICE_KEY",
226
+ frontend_env_name: "CLUE_SERVICE_KEY",
227
+ producer_id_derivation: "producer_id defaults to service_key",
228
+ },
229
+ clue_context: {
230
+ project_key: setupContext.project_key,
231
+ environment: setupContext.environment,
232
+ clue_api_base_url: setupContext.clue_api_base_url,
233
+ ingest_endpoints: setupContext.clue_api_base_url
234
+ ? {
235
+ browser: buildEndpoint(
236
+ setupContext.clue_api_base_url,
237
+ BROWSER_INGEST_PATH,
238
+ ),
239
+ backend: buildEndpoint(
240
+ setupContext.clue_api_base_url,
241
+ BACKEND_INGEST_PATH,
242
+ ),
243
+ }
244
+ : null,
245
+ },
246
+ lifecycle_verification: {
247
+ watch_target_format:
248
+ "frontend:<service-key>[init,identify,set-account,logout,event-sent]=<frontend-url>,backend:<service-key>[init,identify,set-account,logout,event-sent]=<backend-url>",
249
+ rule: "setup-watch --local uses the structured watch_targets below. Lifecycle checks are fixed for setup verification and are evaluated per service_key.",
250
+ watch_targets: buildWatchTargets(detection, candidate),
251
+ },
252
+ artifacts: {
253
+ ci_workflow_path: workflow.ci_workflow_path,
254
+ setup_manifest_path: setupManifestPath,
255
+ runtime_request_committed: false,
256
+ },
257
+ machine_owned_artifacts: [workflow.ci_workflow_path, setupManifestPath],
258
+ ai_must_not_edit: [workflow.ci_workflow_path],
259
+ ai_owned_workstreams: ["sdk_lifecycle_implementation"],
260
+ required_final_check: {
261
+ command:
262
+ `npx @clue-ai/cli setup-check --framework ${candidate.framework} ` +
263
+ `--backend-root-path ${candidate.backend_root_path} --repo . --target ${target} --require-sdk-lifecycle`,
264
+ },
265
+ required_env_names: [
266
+ "CLUE_SERVICE_KEY",
267
+ "CLUE_API_KEY",
268
+ "CLUE_AI_PROVIDER",
269
+ "CLUE_AI_PROVIDER_API_KEY",
270
+ "CLUE_PROJECT_KEY",
271
+ "CLUE_ENVIRONMENT",
272
+ "CLUE_INGEST_ENDPOINT",
273
+ "CLUE_API_BASE_URL",
274
+ "CLUE_AI_MODEL",
275
+ ],
276
+ };
277
+ await writeJson({
278
+ repoRoot: resolvedRepoRoot,
279
+ path: setupManifestPath,
280
+ value: manifest,
281
+ });
282
+ return {
283
+ ...manifest,
284
+ environment_instructions: buildEnvironmentInstructions({
285
+ manifest,
286
+ setupContext,
287
+ }),
288
+ };
289
+ };
@@ -20,7 +20,10 @@ const TARGET_SKILL_ROOTS = {
20
20
  };
21
21
 
22
22
  const normalizeTarget = (target) => {
23
- const normalized = String(target ?? "").trim().toLowerCase().replace(/[\s-]+/g, "_");
23
+ const normalized = String(target ?? "")
24
+ .trim()
25
+ .toLowerCase()
26
+ .replace(/[\s-]+/g, "_");
24
27
  if (!TARGETS.has(normalized)) {
25
28
  throw new Error("AIツールは codex または claude_code を指定してください");
26
29
  }
@@ -32,7 +35,7 @@ const skillBody = (name) => {
32
35
  "clue-setup-orchestrator":
33
36
  "Use first when running the full Clue setup so one execution agent per implementation workstream and multiple monitoring agents coordinate separate setup phases.",
34
37
  "clue-route-semantic-snapshot":
35
- "Use when analyzing backend routes, handlers, controllers, or endpoints to create privacy-safe Clue semantic snapshots.",
38
+ "Use when checking backend route coverage and semantic snapshot readiness without hand-authoring generated snapshot files.",
36
39
  "clue-semantic-ci":
37
40
  "Use when adding or updating Clue semantic snapshot CI for this repository.",
38
41
  "clue-sdk-instrumentation":
@@ -49,11 +52,14 @@ const skillBody = (name) => {
49
52
  "clue-setup-orchestrator": [
50
53
  "Use one execution agent per implementation workstream.",
51
54
  "Each execution agent owns exactly one workstream and its tests.",
52
- "Required execution agents: SDK Lifecycle Execution Agent, Semantic Snapshot Execution Agent, and Semantic Snapshot CI Execution Agent.",
55
+ "Required execution agents: SDK Lifecycle Execution Agent, Semantic Snapshot Readiness Execution Agent, and Semantic Snapshot CI Execution Agent.",
53
56
  "Run execution agents in parallel only when file ownership does not conflict; otherwise run them sequentially with monitor gates between workstreams.",
54
57
  "Use multiple monitoring agents for read-only checks, or named review passes if subagents are unavailable.",
55
- "Run setup phases separately in this order: repository discovery, semantic snapshot, semantic snapshot CI, SDK lifecycle implementation, verification, final report.",
56
- "Treat only semantic snapshot, semantic snapshot CI, and SDK lifecycle implementation as implementation workstreams with execution agents.",
58
+ "The initial `clue-ai setup --clue-api-key <key> --clue-api-base-url <url> --project-key <key> --environment <environment>` command already performs repository discovery, semantic CI workflow generation, setup manifest generation, and service-specific environment guidance when backend routes can be detected.",
59
+ "Before implementation, read `.clue/setup-manifest.json` and treat it as the mechanical setup source of truth.",
60
+ "Use the service keys and watch targets from `.clue/setup-manifest.json`; do not invent service keys.",
61
+ "If `.clue/setup-manifest.json` has status `blocked`, stop and report its blockers instead of guessing.",
62
+ "Treat only semantic snapshot readiness, semantic snapshot CI, and SDK lifecycle implementation as implementation workstreams with execution agents.",
57
63
  "Before each workstream, read and apply the matching Clue setup skill.",
58
64
  "After each implementation workstream, run a monitoring check with `clue-setup-audit` before continuing.",
59
65
  "For final local verification, read and apply `clue-local-verification`.",
@@ -61,37 +67,71 @@ const skillBody = (name) => {
61
67
  "Do not continue past P0/P1 monitoring findings until fixed or reported as blocked.",
62
68
  ],
63
69
  "clue-route-semantic-snapshot": [
64
- "Use this skill as the source of truth for semantic snapshot content and structure.",
65
- "Keep semantic snapshot authoring separate from CI workflow creation and SDK lifecycle implementation.",
70
+ "Use this skill as the source of truth for semantic snapshot readiness and route coverage verification.",
71
+ "Do not hand-author semantic snapshot content files.",
72
+ "Do not create or commit `.clue/semantic-request.runtime.json`; the semantic CI request must be passed through the generated workflow environment instead of a repository file.",
73
+ "Keep route coverage/readiness checks separate from CI workflow creation and SDK lifecycle implementation.",
66
74
  "Do not create CI workflow files or SDK lifecycle calls from this skill.",
75
+ "Do not create or commit `.clue/semantic-routes.json`; route inventory is dynamic and must be recomputed mechanically by `clue-ai semantic-inventory`, `clue-ai setup-check`, or `clue-ai semantic-ci`.",
76
+ "If route inventory must be inspected locally, run `npx @clue-ai/cli semantic-inventory --framework <framework> --backend-root-path <path> --repo .` and review stdout instead of writing a repo file.",
67
77
  "Inspect only allowed source paths.",
68
- "Identify route, handler, controller, and endpoint behavior from privacy-safe evidence.",
69
- "Create route entries with operation_source_key, method/path_template when available, route_summary, route_confidence, confidence_reason, and source_evidence_refs.",
70
- "Create layer_evidence for data effects, side effects, validation, permissions, failures, and component fingerprints when available.",
71
- "Create operation_effects only when target object evidence and domain behavior evidence are sufficient.",
72
- "Create target_object_profiles, target_object_catalog, and target_object_mappings for accepted operation effects.",
73
- "Preserve unresolved_operation_effects with missing_context instead of fabricating unknown operation effects.",
74
- "Include source_evidence_refs and ai_inference_evidence without raw source, secrets, prompts, or completions.",
75
- "Create semantic snapshot inputs without raw source, secrets, prompts, or completions.",
76
- "Report unresolved routes as blockers instead of guessing.",
78
+ "Identify the backend framework, backend root path, route files, controllers, handlers, and route declaration patterns from privacy-safe evidence.",
79
+ "Run `npx @clue-ai/cli semantic-inventory --framework <framework> --backend-root-path <path> --repo .` whenever possible to verify route discovery without AI or secrets.",
80
+ "If `npx` cannot be used in the current environment, use the local `clue-ai semantic-inventory` command equivalent.",
81
+ "Verify that every API route can be discovered from the selected backend root path and that unsupported frameworks are reported as blockers.",
82
+ "The semantic snapshot CI command must mechanically enumerate operation_source_key, method, path_template, route fingerprints, and privacy-safe evidence before AI interpretation.",
83
+ "AI interpretation may summarize each mechanically discovered route, but it must not create missing routes or operation_source_key values.",
84
+ "The expected generated snapshot structure includes route entries with operation_source_key, method/path_template when available, route_summary, route_confidence, confidence_reason, and source_evidence_refs.",
85
+ "The expected generated snapshot structure includes layer_evidence for data effects, side effects, validation, permissions, failures, and component fingerprints when available.",
86
+ "The expected generated snapshot structure includes operation_effects only when target object evidence and domain behavior evidence are sufficient.",
87
+ "The expected generated snapshot structure preserves unresolved_operation_effects with missing_context instead of fabricating unknown operation effects.",
88
+ "Report route coverage gaps, unsupported backend frameworks, and unclear backend roots as blockers instead of guessing.",
77
89
  ],
78
90
  "clue-semantic-ci": [
79
91
  "Use this skill as the source of truth for semantic snapshot CI workflow format.",
80
- "Keep CI workflow creation separate from semantic snapshot content authoring and SDK lifecycle implementation.",
81
- "Do not author semantic snapshot content or SDK lifecycle calls from this skill.",
82
- "Create or update `.github/workflows/clue-semantic-snapshot.yml`.",
83
- "Use `npx @clue-ai/cli semantic-ci --request .clue/semantic-request.runtime.json --repo .`.",
92
+ "Keep CI workflow creation separate from route coverage/readiness checks and SDK lifecycle implementation.",
93
+ "Do not author semantic snapshot content, runtime request files, or SDK lifecycle calls from this skill.",
94
+ "Treat `.github/workflows/clue-semantic-snapshot.yml` as a machine-owned artifact generated by `clue-ai setup`; do not hand-edit it.",
95
+ "Create or update `.github/workflows/clue-semantic-snapshot.yml` only by running `npx @clue-ai/cli semantic-workflow --framework <framework> --backend-root-path <path> --repo .` when it must be refreshed.",
96
+ "If `npx` cannot be used in the current environment, use the local `clue-ai semantic-workflow` command equivalent instead of hand-writing the workflow.",
97
+ "The workflow must pass `CLUE_SEMANTIC_REQUEST_JSON` through the workflow environment and then call `npx @clue-ai/cli semantic-ci --request-env CLUE_SEMANTIC_REQUEST_JSON --repo .`.",
98
+ "Do not create, commit, or stage `.clue/semantic-request.runtime.json` in the customer repository.",
99
+ "The workflow must not send GitHub actor, triggering_actor, sender, repository owner, repository name, or default branch to Clue.",
100
+ "The workflow should send only repository id, commit sha, workflow run id, project key variable, service key, framework, source path allowlist, source path denylist, Clue API base URL variable, and AI model variable.",
101
+ "Use minimal GitHub permissions and checkout without persisted credentials when generating the workflow.",
84
102
  "Reference GitHub Secrets and Variables by name only.",
103
+ "Required GitHub secrets are `CLUE_API_KEY` and `CLUE_AI_PROVIDER_API_KEY`.",
104
+ "Required GitHub variables are `CLUE_AI_PROVIDER` and `CLUE_AI_MODEL`.",
85
105
  "Do not print or commit secret values.",
86
106
  ],
87
107
  "clue-sdk-instrumentation": [
88
108
  "Use this skill as the source of truth for Clue SDK lifecycle implementation.",
89
109
  "Keep SDK lifecycle implementation separate from semantic snapshot and CI workflow work.",
90
110
  "Do not create semantic snapshot content or semantic snapshot CI workflow files from this skill.",
111
+ "Do not create no-op wrappers around nonexistent `window.Clue*` globals or local placeholder functions.",
112
+ "Lifecycle calls must resolve to real Clue SDK imports or a real repository adapter that forwards to the Clue SDK.",
113
+ "Every Clue lifecycle call must be failure-isolated with try/catch, try/except, `.catch`, or an explicit safe Clue helper so Clue failure never stops the host service.",
114
+ "Never await a Clue lifecycle call in a way that can block login, logout, account selection, request handling, page rendering, or API responses.",
115
+ "Add or report the required SDK dependency instead of fabricating lifecycle APIs.",
116
+ "When lifecycle edits are clear, write an exact replacement plan to a temporary local JSON file and apply it with `npx @clue-ai/cli lifecycle-apply --plan <plan-file> --repo .`.",
117
+ "If `npx` cannot be used in the current environment, use the local `clue-ai lifecycle-apply` command equivalent instead of manually applying the exact replacements.",
118
+ "Delete the temporary lifecycle plan file after applying it unless the user explicitly asks to keep it for review.",
119
+ "Use environment variable names for Clue configuration values; do not paste project keys or API keys into code.",
120
+ "For local env files, use the service-specific env blocks printed by `clue-ai setup`; do not ask the user to guess `CLUE_SERVICE_KEY`.",
121
+ "For browser code, use `CLUE_PROJECT_KEY`, `CLUE_ENVIRONMENT`, and `CLUE_INGEST_ENDPOINT`. Let the target framework expose or inject those values safely without hard-coding a Next.js-only prefix.",
122
+ "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`.",
123
+ "Use `CLUE_SERVICE_KEY` as the canonical local service identifier. Do not ask the user to manage a separate producer id; SDKs should send producer id as the service key for setup verification compatibility.",
124
+ "For frontend code, pass `serviceKey` from `CLUE_SERVICE_KEY` to `ClueInit`. Do not require a separate producer id unless the repository already has one for compatibility.",
125
+ "For Django code, add `clue-django-sdk` to the backend dependency file when missing and use the Django SDK lifecycle helpers.",
126
+ "For other backend frameworks, use the matching Clue backend SDK if one exists; if no backend SDK exists, report a blocker instead of silently frontend-only setup.",
127
+ "Do not send raw email, raw person names, tokens, workspace names, organization names, or tenant names as lifecycle traits unless the repository already has an explicit Clue privacy policy allowing them.",
128
+ "Prefer stable ids and non-PII booleans/counts for ClueIdentify and ClueSetAccount traits.",
91
129
  "Find the app/bootstrap entrypoint and add ClueInit only when the location is clear.",
92
- "Find login success handling and add ClueIdentify only when the user identity is available.",
93
- "Find account, workspace, organization, or tenant resolution and add ClueSetAccount only when the subject is available.",
94
- "Find logout/sign-out completion and add ClueLogout only when the session reset point is clear.",
130
+ "Place ClueInit in a stable app bootstrap, SDK adapter, or client singleton; do not place ClueInit inside React component lifecycle hooks, page components, sidebars, login/register success callbacks, or other paths that can run repeatedly.",
131
+ "If the repository needs lifecycle calls from UI hooks, import a shared initialized Clue adapter instead of calling ClueInit again.",
132
+ "Find every clear frontend and backend login success path and add ClueIdentify to every one when the user identity is available.",
133
+ "Find every clear frontend and backend account, workspace, organization, or tenant resolution path and add ClueSetAccount to every one when the subject is available.",
134
+ "Find every clear frontend and backend logout/sign-out/session reset completion path and add ClueLogout to every one when the reset point is clear.",
95
135
  "Skip unclear lifecycle points and report blockers.",
96
136
  ],
97
137
  "clue-setup-audit": [
@@ -99,6 +139,14 @@ const skillBody = (name) => {
99
139
  "Check one completed workstream at a time and report P0/P1 issues before more implementation continues.",
100
140
  "Review changed files line by line.",
101
141
  "Verify semantic snapshot, semantic CI, and SDK lifecycle responsibilities did not bleed into each other.",
142
+ "Reject hand-authored semantic snapshot content and runtime request files.",
143
+ "Reject semantic CI workflows that were not generated by or equivalent to `clue-ai semantic-workflow`.",
144
+ "Reject semantic CI workflows that send GitHub actor, triggering_actor, sender, repository owner, repository name, or default branch to Clue.",
145
+ "Reject no-op lifecycle wrappers or lifecycle calls that do not resolve to a real Clue SDK import.",
146
+ "Reject backend setup when backend routes exist but no backend Clue SDK dependency/import/init was added.",
147
+ "Reject lifecycle calls that are not failure-isolated; Clue failure must never stop the host service.",
148
+ "Reject setup that covers only one login path when multiple login success paths are clearly present.",
149
+ "Reject ClueInit inside React component lifecycle hooks, page components, sidebars, login/register success callbacks, or any repeated user interaction path.",
102
150
  "Reject broad ClueTrack instrumentation and DOM clue tags.",
103
151
  "Confirm no project key, API key, secret, or env value appears in diff or report.",
104
152
  "Confirm lifecycle insertions are minimal and reviewable.",
@@ -108,6 +156,15 @@ const skillBody = (name) => {
108
156
  "Verify each workstream independently before the final setup report.",
109
157
  "Confirm generated skill files exist.",
110
158
  "Confirm workflow files and SDK lifecycle imports/calls exist when those phases have run.",
159
+ "Confirm backend routes have a backend Clue SDK dependency/import/init when a backend exists.",
160
+ "Confirm `.github/workflows/clue-semantic-snapshot.yml` calls `npx @clue-ai/cli semantic-ci --request-env CLUE_SEMANTIC_REQUEST_JSON`.",
161
+ "Confirm the semantic workflow does not send GitHub actor, triggering_actor, sender, repository owner, repository name, or default branch to Clue.",
162
+ "Confirm `.clue/semantic-request.runtime.json` is not created, committed, or staged.",
163
+ "Run `npx @clue-ai/cli setup-check --framework <framework> --backend-root-path <path> --repo . --target <codex|claude_code> --require-sdk-lifecycle` when possible.",
164
+ "For interactive local verification, run `npx @clue-ai/cli setup-watch --project-key <project-key> --environment <environment> --clue-api-base-url <clue-api-base-url> --watch-targets frontend:<service-key>[init,identify,set-account,event-sent]=<frontend-url>,backend:<service-key>[init,identify,set-account,logout,event-sent]=<backend-url>` and operate every local frontend/backend service until all expected checks pass.",
165
+ "Only include lifecycle checks that the implementation ownership plan expects for that service. If a service emits an undeclared lifecycle event, treat it as a possible duplicate instrumentation issue.",
166
+ "Never assume localhost ports. Ask the repository scripts, env examples, or the running service output for the actual frontend/backend URLs.",
167
+ "If `npx` cannot be used in the current environment, use the local `clue-ai setup-check` command equivalent.",
111
168
  "Confirm only env names are reported.",
112
169
  "Leave event delivery verification to the Clue setup screen.",
113
170
  ],
@@ -153,7 +210,10 @@ const skillBody = (name) => {
153
210
  ].join("\n");
154
211
  };
155
212
 
156
- const askTarget = async ({ input = process.stdin, output = process.stdout } = {}) => {
213
+ const askTarget = async ({
214
+ input = process.stdin,
215
+ output = process.stdout,
216
+ } = {}) => {
157
217
  const rl = readline.createInterface({ input, output });
158
218
  try {
159
219
  const answer = await rl.question(
@@ -171,9 +231,14 @@ export const installSetupSkills = async ({
171
231
  input,
172
232
  output,
173
233
  } = {}) => {
174
- const resolvedTarget = target ? normalizeTarget(target) : await askTarget({ input, output });
234
+ const resolvedTarget = target
235
+ ? normalizeTarget(target)
236
+ : await askTarget({ input, output });
175
237
  const resolvedRepoRoot = resolve(repoRoot ?? ".");
176
- const skillRoot = join(resolvedRepoRoot, ...TARGET_SKILL_ROOTS[resolvedTarget]);
238
+ const skillRoot = join(
239
+ resolvedRepoRoot,
240
+ ...TARGET_SKILL_ROOTS[resolvedTarget],
241
+ );
177
242
  const installed = [];
178
243
 
179
244
  for (const skillName of SKILL_NAMES) {
@@ -188,6 +253,8 @@ export const installSetupSkills = async ({
188
253
  target: resolvedTarget,
189
254
  skill_root: join(...TARGET_SKILL_ROOTS[resolvedTarget]),
190
255
  skills: SKILL_NAMES,
191
- installed_files: installed.map((path) => path.replace(`${resolvedRepoRoot}/`, "")),
256
+ installed_files: installed.map((path) =>
257
+ path.replace(`${resolvedRepoRoot}/`, ""),
258
+ ),
192
259
  };
193
260
  };