siteplane 0.1.40 → 0.1.42

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/dist/index.js CHANGED
@@ -1014,6 +1014,8 @@ var CONTINUE_SITE_SETUP_LOCATOR_HINT_MAX_BYTES = 512;
1014
1014
  var CONTINUE_SITE_SETUP_REQUESTED_LABEL_MAX_BYTES = 120;
1015
1015
  var CONTINUE_SITE_SETUP_REQUESTED_SECTION_MAX_BYTES = 120;
1016
1016
  var CONTINUE_SITE_SETUP_REQUESTED_SUBSECTION_MAX_BYTES = 120;
1017
+ var SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_LENGTH = 2e3;
1018
+ var SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_BYTES = 8e3;
1017
1019
  var CONTINUE_SITE_SETUP_ITEMS_MAX_BYTES = 32 * 1024;
1018
1020
  var CONTINUE_SITE_SETUP_HTTP_BODY_MAX_BYTES = 64 * 1024;
1019
1021
  var siteSetupRunStatusSchema = z14.enum(SITE_SETUP_RUN_STATUSES);
@@ -1103,6 +1105,7 @@ var editorDefinitionV1Schema = z14.object({
1103
1105
  }
1104
1106
  });
1105
1107
  var forbiddenControlOrBidi = /[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/u;
1108
+ var forbiddenOwnerNoteControlOrBidi = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/u;
1106
1109
  var unsafeLocator = /<\/?[a-z][^>]*>|\b(?:javascript|data:text\/html)\s*:|\bon[a-z]+\s*=/iu;
1107
1110
  var renderedPathSchema = z14.string().trim().transform((value) => value !== "/" ? value.replace(/\/+$/u, "") : value).superRefine((value, context) => {
1108
1111
  if (!value.startsWith("/") || value === "$global" || value.includes("?") || value.includes("#")) {
@@ -1155,6 +1158,175 @@ var setupCorrectionItemsSchema = z14.array(setupCorrectionItemSchema).max(CONTIN
1155
1158
  });
1156
1159
  }
1157
1160
  });
1161
+ var siteSetupOwnerEditabilityNoteSchema = z14.string().max(SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_LENGTH).superRefine((value, context) => {
1162
+ if (utf8Bytes(value) > SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_BYTES) {
1163
+ context.addIssue({
1164
+ code: "custom",
1165
+ message: `ownerEditabilityNote exceeds ${SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_BYTES} UTF-8 bytes.`
1166
+ });
1167
+ }
1168
+ if (forbiddenOwnerNoteControlOrBidi.test(value)) {
1169
+ context.addIssue({
1170
+ code: "custom",
1171
+ message: "ownerEditabilityNote contains a forbidden control or bidi character."
1172
+ });
1173
+ }
1174
+ });
1175
+ var SITE_SETUP_MODULE_SCOPES = {
1176
+ editing: ["setup:read", "setup:write"],
1177
+ analytics: [
1178
+ "analytics:setup",
1179
+ "analytics:sync",
1180
+ "analytics:test",
1181
+ "analytics:readiness",
1182
+ "analytics:agent_instructions",
1183
+ "analytics:public_key_read"
1184
+ ]
1185
+ };
1186
+ var siteSetupModulesSchema = z14.array(z14.enum(["editing", "analytics"])).min(1).max(2).refine((modules) => modules[0] === "editing" && (modules.length === 1 || modules[1] === "analytics"), "Choose Editing with optional Analytics.");
1187
+ function siteSetupScopes(modules) {
1188
+ return modules.flatMap((module) => [...SITE_SETUP_MODULE_SCOPES[module]]);
1189
+ }
1190
+ function hasExactSiteSetupScopes(scopes, modules) {
1191
+ const matches = (expected) => scopes.length === expected.length && expected.every((scope) => scopes.includes(scope));
1192
+ return modules ? matches(siteSetupScopes(modules)) : matches(siteSetupScopes(["editing"])) || matches(siteSetupScopes(["editing", "analytics"]));
1193
+ }
1194
+ var siteSetupActivityInputSchema = z14.object({
1195
+ phase: z14.enum([
1196
+ "inspecting",
1197
+ "integrating",
1198
+ "deploying",
1199
+ "verifying",
1200
+ "repairing"
1201
+ ]),
1202
+ textId: z14.enum([
1203
+ "inspecting",
1204
+ "integrating",
1205
+ "deploying",
1206
+ "verifying",
1207
+ "repairing"
1208
+ ])
1209
+ }).strict().refine((value) => value.phase === value.textId, "Activity text must describe its phase.");
1210
+ var nextActionFields = {
1211
+ actor: z14.enum(["agent", "user", "siteplane"]),
1212
+ boundary: z14.enum([
1213
+ "source",
1214
+ "environment",
1215
+ "deployment",
1216
+ "verification",
1217
+ "authorization",
1218
+ "review"
1219
+ ]),
1220
+ precondition: z14.string().min(1).max(1e3),
1221
+ instruction: z14.string().min(1).max(2e3),
1222
+ expectedEvidence: z14.string().min(1).max(1e3)
1223
+ };
1224
+ var siteSetupNextActionSchema = z14.discriminatedUnion("kind", [
1225
+ z14.object({
1226
+ ...nextActionFields,
1227
+ kind: z14.literal("run_command"),
1228
+ command: z14.string().min(1).max(500)
1229
+ }).strict(),
1230
+ z14.object({ ...nextActionFields, kind: z14.literal("agent_edit") }).strict(),
1231
+ z14.object({ ...nextActionFields, kind: z14.literal("needs_user_action") }).strict(),
1232
+ z14.object({ ...nextActionFields, kind: z14.literal("wait") }).strict(),
1233
+ z14.object({ ...nextActionFields, kind: z14.literal("done") }).strict()
1234
+ ]);
1235
+ var siteSetupTaskRunSchema = z14.object({
1236
+ runId: z14.string().uuid(),
1237
+ mode: siteSetupRunModeSchema,
1238
+ status: siteSetupRunStatusSchema,
1239
+ fieldContractHash: z14.string().nullable(),
1240
+ deploymentOrigin: z14.string().url().nullable(),
1241
+ deploymentRevision: z14.string().nullable(),
1242
+ publicRuntimeKeyId: z14.string().uuid().nullable(),
1243
+ reviewVersion: z14.string().nullable()
1244
+ }).strict();
1245
+ var siteSetupTaskProgressSchema = z14.object({
1246
+ progressStage: z14.enum([
1247
+ "waiting_for_connection",
1248
+ "agent_connected",
1249
+ "project_context_loaded",
1250
+ "fields_prepared",
1251
+ "deployment_verification",
1252
+ "ready_for_review",
1253
+ "action_required",
1254
+ "completed"
1255
+ ]),
1256
+ lastVerifiedAt: z14.string().datetime().nullable(),
1257
+ lastActivityAt: z14.string().datetime(),
1258
+ activitySource: z14.enum(["user", "server", "agent"]),
1259
+ activityPhase: siteSetupActivityInputSchema.shape.phase.nullable(),
1260
+ activityTextId: siteSetupActivityInputSchema.shape.textId.nullable()
1261
+ }).strict();
1262
+ var siteSetupTaskSchema = z14.object({
1263
+ contractVersion: z14.literal("siteplane.setup-task.v2"),
1264
+ workflow: z14.enum(["initial_setup", "structure_update"]),
1265
+ goal: z14.string().min(1),
1266
+ modules: siteSetupModulesSchema,
1267
+ authorizationVersion: z14.number().int().positive(),
1268
+ authorizedScopes: z14.array(z14.string()).min(2),
1269
+ site: z14.object({
1270
+ siteId: z14.string().uuid(),
1271
+ portalPath: z14.string(),
1272
+ adminOrigin: z14.string().url()
1273
+ }).strict().nullable(),
1274
+ run: siteSetupTaskRunSchema.nullable(),
1275
+ progress: siteSetupTaskProgressSchema.nullable(),
1276
+ assignment: z14.literal("owned"),
1277
+ deadline: z14.string().datetime().nullable(),
1278
+ userInstructions: z14.object({
1279
+ text: siteSetupOwnerEditabilityNoteSchema,
1280
+ source: z14.literal("user"),
1281
+ trust: z14.literal("untrusted")
1282
+ }).strict(),
1283
+ corrections: setupCorrectionItemsSchema,
1284
+ environmentBindings: z14.array(z14.object({
1285
+ name: z14.string().regex(/^[A-Z][A-Z0-9_]+$/u),
1286
+ source: z14.string().min(1),
1287
+ sensitivity: z14.enum(["public", "secret"]),
1288
+ usage: z14.enum(["build", "server", "build_and_server"]),
1289
+ evidence: z14.string().min(1)
1290
+ }).strict()),
1291
+ nextAction: siteSetupNextActionSchema,
1292
+ error: z14.object({
1293
+ code: z14.string().regex(/^[a-z0-9_.]+$/u).max(160),
1294
+ boundary: nextActionFields.boundary,
1295
+ responsibleActor: nextActionFields.actor,
1296
+ retryable: z14.boolean(),
1297
+ retryAfter: z14.number().int().nonnegative().nullable(),
1298
+ requestId: z14.string().regex(/^[A-Za-z0-9_-]+$/u).max(128)
1299
+ }).strict().nullable(),
1300
+ packages: z14.object({
1301
+ siteplane: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u),
1302
+ runtimeNext: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
1303
+ }).strict(),
1304
+ communication: z14.object({
1305
+ beforeSourceChanges: z14.string().min(1),
1306
+ updates: z14.array(z14.string().min(1)).min(1),
1307
+ blocker: z14.string().min(1)
1308
+ }).strict(),
1309
+ discovery: z14.object({
1310
+ inspectPublicRoutes: z14.boolean(),
1311
+ contentKinds: z14.array(z14.enum(["text", "longText", "link", "image"])).min(1),
1312
+ rules: z14.array(z14.string().min(1)).min(1)
1313
+ }).strict(),
1314
+ steps: z14.array(z14.object({
1315
+ id: z14.enum([
1316
+ "inspect_repository",
1317
+ "install_packages",
1318
+ "instrument_fields",
1319
+ "apply_contract",
1320
+ "deploy_production",
1321
+ "verify_deployment"
1322
+ ]),
1323
+ instruction: z14.string().min(1)
1324
+ }).strict()).length(6),
1325
+ completion: z14.object({
1326
+ verifiedStatus: z14.literal("ready_for_review"),
1327
+ instruction: z14.string().min(1)
1328
+ }).strict()
1329
+ }).strict().refine((task) => hasExactSiteSetupScopes(task.authorizedScopes, task.modules), "Task scopes must exactly match its modules.");
1158
1330
  var canonicalHashSchema = z14.string().regex(/^sha256:[0-9a-f]{64}$/iu);
1159
1331
  var deploymentRevisionSchema = normalizedSafeTextSchema(256, "deploymentRevision");
1160
1332
  var continueSiteSetupInputSchema = z14.object({
@@ -1162,7 +1334,15 @@ var continueSiteSetupInputSchema = z14.object({
1162
1334
  runId: z14.string().uuid(),
1163
1335
  expectedFieldContractHash: canonicalHashSchema,
1164
1336
  expectedDeploymentRevision: deploymentRevisionSchema,
1165
- correctionItems: setupCorrectionItemsSchema
1337
+ correctionItems: setupCorrectionItemsSchema,
1338
+ ownerEditabilityNote: siteSetupOwnerEditabilityNoteSchema.optional()
1339
+ }).strict();
1340
+ var saveSiteSetupOwnerNoteInputSchema = z14.object({
1341
+ siteId: z14.string().uuid(),
1342
+ runId: z14.string().uuid(),
1343
+ expectedFieldContractHash: canonicalHashSchema,
1344
+ expectedDeploymentRevision: deploymentRevisionSchema,
1345
+ ownerEditabilityNote: siteSetupOwnerEditabilityNoteSchema
1166
1346
  }).strict();
1167
1347
  var siteSetupContextInputSchema = z14.object({}).strict();
1168
1348
  var siteSetupApplyInputSchema = z14.object({
@@ -1327,6 +1507,7 @@ var FIELD_BRIDGE_MESSAGE_TYPES = [
1327
1507
  "siteplane:field-bridge:preview-ack",
1328
1508
  "siteplane:field-bridge:set-visual-control-state",
1329
1509
  "siteplane:field-bridge:missing-content",
1510
+ "siteplane:field-bridge:preview-scrolled",
1330
1511
  "siteplane:field-bridge:error"
1331
1512
  ];
1332
1513
  var canonicalFieldContractHashSchema = z15.string().regex(/^sha256:[0-9a-f]{64}$/u);
@@ -1457,6 +1638,10 @@ var fieldBridgeMissingContentMessageSchema = fieldBridgeBaseSchema.extend({
1457
1638
  suggestedSection: bridgeSectionSchema.optional()
1458
1639
  }).strict()
1459
1640
  });
1641
+ var fieldBridgePreviewScrolledMessageSchema = fieldBridgeBaseSchema.extend({
1642
+ type: z15.literal("siteplane:field-bridge:preview-scrolled"),
1643
+ payload: z15.object({ renderedPath: realRenderedPathSchema }).strict()
1644
+ });
1460
1645
  var fieldBridgeErrorMessageSchema = fieldBridgeBaseSchema.extend({
1461
1646
  type: z15.literal("siteplane:field-bridge:error"),
1462
1647
  payload: z15.object({
@@ -1476,6 +1661,7 @@ var fieldBridgeMessageSchema = z15.discriminatedUnion("type", [
1476
1661
  fieldBridgePreviewAckMessageSchema,
1477
1662
  fieldBridgeSetVisualControlStateMessageSchema,
1478
1663
  fieldBridgeMissingContentMessageSchema,
1664
+ fieldBridgePreviewScrolledMessageSchema,
1479
1665
  fieldBridgeErrorMessageSchema
1480
1666
  ]);
1481
1667
 
@@ -1989,49 +2175,75 @@ async function bookingTestCommand(input) {
1989
2175
  });
1990
2176
  }
1991
2177
 
1992
- // ../cli/dist/commands/connect.js
1993
- import { spawn } from "child_process";
1994
- import { randomBytes } from "crypto";
1995
- import { z as z27 } from "zod";
2178
+ // ../cli/dist/commands/export.js
2179
+ async function exportCommand(input) {
2180
+ requireContentExportScope(input.tokenScopes);
2181
+ const values = await input.readPublishedValues();
2182
+ if (input.format === "prompt") {
2183
+ return {
2184
+ kind: "prompt",
2185
+ output: Object.entries(values).map(([fieldId, value]) => `${fieldId}: ${JSON.stringify(value)}`).join("\n")
2186
+ };
2187
+ }
2188
+ return {
2189
+ kind: "json",
2190
+ values
2191
+ };
2192
+ }
2193
+ function requireContentExportScope(scopes) {
2194
+ if (!scopes?.includes("content:export")) {
2195
+ throw new Error("A Project Connection with content:export is required.");
2196
+ }
2197
+ }
1996
2198
 
1997
- // ../cli/dist/config/credentials.js
1998
- import { execFile } from "child_process";
2199
+ // ../cli/dist/config/project-config.js
2200
+ import { access, chmod, open, readFile as readFile5, rename, rm } from "fs/promises";
1999
2201
  import { randomUUID as randomUUID2 } from "crypto";
2000
- import { chmod, mkdir as mkdir5, open, readFile as readFile5, rename, rm } from "fs/promises";
2001
- import { dirname as dirname5, join as join3, relative } from "path";
2002
- import { promisify } from "util";
2202
+ import { join as join3 } from "path";
2003
2203
  import { z as z24 } from "zod";
2004
- var siteplaneCredentialsSchema = z24.object({
2005
- accessToken: z24.string().trim().min(1),
2006
- siteRevalidationSecret: z24.string().trim().min(1)
2204
+ var siteplaneProjectConfigSchema = z24.object({
2205
+ version: z24.literal(1),
2206
+ apiBaseUrl: z24.string().url(),
2207
+ siteId: z24.string().uuid(),
2208
+ publicSiteKeyId: z24.string().uuid(),
2209
+ publicSiteKey: z24.string().trim().min(1),
2210
+ fieldContractHash: z24.string().regex(/^sha256:[0-9a-f]{64}$/iu).optional()
2007
2211
  }).strict();
2008
- async function assertLocalCredentialsPathSafe(projectDir, options = {}) {
2009
- const path = join3(projectDir, ".siteplane/credentials.json");
2010
- const isTrackedFile = options.isTrackedFile ?? ((targetPath) => gitPathMatches(projectDir, targetPath, "ls-files"));
2011
- const isIgnoredFile = options.isIgnoredFile ?? ((targetPath) => gitPathMatches(projectDir, targetPath, "check-ignore"));
2012
- if (await isTrackedFile(path)) {
2013
- throw new Error("Refusing to write Siteplane credentials into a tracked file.");
2212
+ async function readProjectPackageJson(projectDir) {
2213
+ return JSON.parse(await readFile5(join3(projectDir, "package.json"), "utf8"));
2214
+ }
2215
+ async function detectNextProject(projectDir) {
2216
+ const packageJson = await readProjectPackageJson(projectDir).catch(() => null);
2217
+ if (packageJson?.dependencies?.next || packageJson?.devDependencies?.next) {
2218
+ return true;
2014
2219
  }
2015
- if (!await isIgnoredFile(path)) {
2016
- throw new Error("Add .siteplane/credentials.json to .gitignore before running Siteplane connect.");
2220
+ for (const fileName of [
2221
+ "next.config.js",
2222
+ "next.config.mjs",
2223
+ "next.config.ts"
2224
+ ]) {
2225
+ try {
2226
+ await access(join3(projectDir, fileName));
2227
+ return true;
2228
+ } catch {
2229
+ }
2017
2230
  }
2018
- return path;
2231
+ return false;
2019
2232
  }
2020
- async function writeLocalCredentials(projectDir, credentials, options = {}) {
2021
- const path = await assertLocalCredentialsPathSafe(projectDir, options);
2022
- const parsed = siteplaneCredentialsSchema.parse(credentials);
2023
- await mkdir5(dirname5(path), { recursive: true, mode: 448 });
2024
- await writeCredentialsAtomically(path, parsed);
2233
+ async function writeProjectConfig(projectDir, config) {
2234
+ const path = join3(projectDir, "siteplane.config.json");
2235
+ const parsed = siteplaneProjectConfigSchema.parse(config);
2236
+ await writeJsonAtomically(path, parsed, 420);
2025
2237
  return path;
2026
2238
  }
2027
- async function readLocalCredentials(projectDir) {
2028
- return siteplaneCredentialsSchema.parse(JSON.parse(await readFile5(join3(projectDir, ".siteplane/credentials.json"), "utf8")));
2239
+ async function readProjectConfig(projectDir) {
2240
+ return siteplaneProjectConfigSchema.parse(JSON.parse(await readFile5(join3(projectDir, "siteplane.config.json"), "utf8")));
2029
2241
  }
2030
- async function writeCredentialsAtomically(path, credentials) {
2242
+ async function writeJsonAtomically(path, value, mode) {
2031
2243
  const temporaryPath = `${path}.${randomUUID2()}.tmp`;
2032
- const file = await open(temporaryPath, "wx", 384);
2244
+ const file = await open(temporaryPath, "wx", mode);
2033
2245
  try {
2034
- await file.writeFile(`${JSON.stringify(credentials, null, 2)}
2246
+ await file.writeFile(`${JSON.stringify(value, null, 2)}
2035
2247
  `, "utf8");
2036
2248
  await file.sync();
2037
2249
  } catch (error) {
@@ -2042,71 +2254,51 @@ async function writeCredentialsAtomically(path, credentials) {
2042
2254
  await file.close();
2043
2255
  try {
2044
2256
  await rename(temporaryPath, path);
2045
- await chmod(path, 384);
2257
+ await chmod(path, mode);
2046
2258
  } catch (error) {
2047
2259
  await rm(temporaryPath, { force: true });
2048
2260
  throw error;
2049
2261
  }
2050
2262
  }
2051
- var execFileAsync = promisify(execFile);
2052
- async function gitPathMatches(projectDir, path, command) {
2053
- const args = command === "check-ignore" ? ["check-ignore", "--quiet", relative(projectDir, path)] : ["ls-files", "--error-unmatch", relative(projectDir, path)];
2054
- try {
2055
- await execFileAsync("git", args, { cwd: projectDir });
2056
- return true;
2057
- } catch {
2058
- return false;
2059
- }
2060
- }
2061
2263
 
2062
- // ../cli/dist/config/project-config.js
2063
- import { access, chmod as chmod2, open as open2, readFile as readFile6, rename as rename2, rm as rm2 } from "fs/promises";
2264
+ // ../cli/dist/config/credentials.js
2265
+ import { execFile } from "child_process";
2064
2266
  import { randomUUID as randomUUID3 } from "crypto";
2065
- import { join as join4 } from "path";
2267
+ import { chmod as chmod2, mkdir as mkdir5, open as open2, readFile as readFile6, rename as rename2, rm as rm2 } from "fs/promises";
2268
+ import { dirname as dirname5, join as join4, relative } from "path";
2269
+ import { promisify } from "util";
2066
2270
  import { z as z25 } from "zod";
2067
- var siteplaneProjectConfigSchema = z25.object({
2068
- version: z25.literal(1),
2069
- apiBaseUrl: z25.string().url(),
2070
- siteId: z25.string().uuid(),
2071
- publicSiteKeyId: z25.string().uuid(),
2072
- publicSiteKey: z25.string().trim().min(1),
2073
- fieldContractHash: z25.string().regex(/^sha256:[0-9a-f]{64}$/iu).optional()
2271
+ var siteplaneCredentialsSchema = z25.object({
2272
+ accessToken: z25.string().trim().min(1),
2273
+ siteRevalidationSecret: z25.string().trim().min(1)
2074
2274
  }).strict();
2075
- async function readProjectPackageJson(projectDir) {
2076
- return JSON.parse(await readFile6(join4(projectDir, "package.json"), "utf8"));
2077
- }
2078
- async function detectNextProject(projectDir) {
2079
- const packageJson = await readProjectPackageJson(projectDir).catch(() => null);
2080
- if (packageJson?.dependencies?.next || packageJson?.devDependencies?.next) {
2081
- return true;
2275
+ async function assertLocalCredentialsPathSafe(projectDir, options = {}) {
2276
+ const path = join4(projectDir, ".siteplane/credentials.json");
2277
+ const isTrackedFile = options.isTrackedFile ?? ((targetPath) => gitPathMatches(projectDir, targetPath, "ls-files"));
2278
+ const isIgnoredFile = options.isIgnoredFile ?? ((targetPath) => gitPathMatches(projectDir, targetPath, "check-ignore"));
2279
+ if (await isTrackedFile(path)) {
2280
+ throw new Error("Refusing to write Siteplane credentials into a tracked file.");
2082
2281
  }
2083
- for (const fileName of [
2084
- "next.config.js",
2085
- "next.config.mjs",
2086
- "next.config.ts"
2087
- ]) {
2088
- try {
2089
- await access(join4(projectDir, fileName));
2090
- return true;
2091
- } catch {
2092
- }
2282
+ if (!await isIgnoredFile(path)) {
2283
+ throw new Error("Add .siteplane/credentials.json to .gitignore before running Siteplane init.");
2093
2284
  }
2094
- return false;
2285
+ return path;
2095
2286
  }
2096
- async function writeProjectConfig(projectDir, config) {
2097
- const path = join4(projectDir, "siteplane.config.json");
2098
- const parsed = siteplaneProjectConfigSchema.parse(config);
2099
- await writeJsonAtomically(path, parsed, 420);
2287
+ async function writeLocalCredentials(projectDir, credentials, options = {}) {
2288
+ const path = await assertLocalCredentialsPathSafe(projectDir, options);
2289
+ const parsed = siteplaneCredentialsSchema.parse(credentials);
2290
+ await mkdir5(dirname5(path), { recursive: true, mode: 448 });
2291
+ await writeCredentialsAtomically(path, parsed);
2100
2292
  return path;
2101
2293
  }
2102
- async function readProjectConfig(projectDir) {
2103
- return siteplaneProjectConfigSchema.parse(JSON.parse(await readFile6(join4(projectDir, "siteplane.config.json"), "utf8")));
2294
+ async function readLocalCredentials(projectDir) {
2295
+ return siteplaneCredentialsSchema.parse(JSON.parse(await readFile6(join4(projectDir, ".siteplane/credentials.json"), "utf8")));
2104
2296
  }
2105
- async function writeJsonAtomically(path, value, mode) {
2297
+ async function writeCredentialsAtomically(path, credentials) {
2106
2298
  const temporaryPath = `${path}.${randomUUID3()}.tmp`;
2107
- const file = await open2(temporaryPath, "wx", mode);
2299
+ const file = await open2(temporaryPath, "wx", 384);
2108
2300
  try {
2109
- await file.writeFile(`${JSON.stringify(value, null, 2)}
2301
+ await file.writeFile(`${JSON.stringify(credentials, null, 2)}
2110
2302
  `, "utf8");
2111
2303
  await file.sync();
2112
2304
  } catch (error) {
@@ -2117,12 +2309,22 @@ async function writeJsonAtomically(path, value, mode) {
2117
2309
  await file.close();
2118
2310
  try {
2119
2311
  await rename2(temporaryPath, path);
2120
- await chmod2(path, mode);
2312
+ await chmod2(path, 384);
2121
2313
  } catch (error) {
2122
2314
  await rm2(temporaryPath, { force: true });
2123
2315
  throw error;
2124
2316
  }
2125
2317
  }
2318
+ var execFileAsync = promisify(execFile);
2319
+ async function gitPathMatches(projectDir, path, command) {
2320
+ const args = command === "check-ignore" ? ["check-ignore", "--quiet", relative(projectDir, path)] : ["ls-files", "--error-unmatch", relative(projectDir, path)];
2321
+ try {
2322
+ await execFileAsync("git", args, { cwd: projectDir });
2323
+ return true;
2324
+ } catch {
2325
+ return false;
2326
+ }
2327
+ }
2126
2328
 
2127
2329
  // ../cli/dist/commands/init.js
2128
2330
  import { join as join5 } from "path";
@@ -2140,9 +2342,9 @@ async function initCommand(input) {
2140
2342
  return {
2141
2343
  ...paths,
2142
2344
  nextSteps: [
2143
- "npx siteplane setup context",
2144
- "Instrument the site and create EditorDefinitionV1.",
2145
- "npx siteplane setup apply --definition /tmp/siteplane-editor.json"
2345
+ "Run npx siteplane setup context and read the returned task.",
2346
+ "Before source changes, briefly tell the user what Siteplane requested and what you will do.",
2347
+ "Follow the returned steps through setup verify and stop only at ready_for_review or action_required."
2146
2348
  ]
2147
2349
  };
2148
2350
  }
@@ -2261,45 +2463,6 @@ function readErrorMessage(payload) {
2261
2463
  return null;
2262
2464
  }
2263
2465
 
2264
- // ../cli/dist/commands/connect.js
2265
- var claimResponseSchema = z27.object({
2266
- ok: z27.literal(true),
2267
- data: z27.object({
2268
- pairingId: z27.string().uuid(),
2269
- status: z27.literal("approval_required"),
2270
- approvalUrl: z27.string().url()
2271
- }).passthrough()
2272
- }).strict();
2273
- var waitingResponseSchema = z27.object({
2274
- ok: z27.literal(true),
2275
- data: z27.object({ status: z27.literal("approval_required") }).strict()
2276
- }).strict();
2277
- var bootstrapResponseSchema2 = z27.object({
2278
- ok: z27.literal(true),
2279
- data: siteSetupBootstrapDataSchema
2280
- }).strict();
2281
-
2282
- // ../cli/dist/commands/export.js
2283
- async function exportCommand(input) {
2284
- requireContentExportScope(input.tokenScopes);
2285
- const values = await input.readPublishedValues();
2286
- if (input.format === "prompt") {
2287
- return {
2288
- kind: "prompt",
2289
- output: Object.entries(values).map(([fieldId, value]) => `${fieldId}: ${JSON.stringify(value)}`).join("\n")
2290
- };
2291
- }
2292
- return {
2293
- kind: "json",
2294
- values
2295
- };
2296
- }
2297
- function requireContentExportScope(scopes) {
2298
- if (!scopes?.includes("content:export")) {
2299
- throw new Error("A Project Connection with content:export is required.");
2300
- }
2301
- }
2302
-
2303
2466
  // ../cli/dist/commands/scan.js
2304
2467
  import { readdir } from "fs/promises";
2305
2468
  import { extname, join as join6 } from "path";
@@ -2308,7 +2471,7 @@ import { extname, join as join6 } from "path";
2308
2471
  import { execFile as execFile2 } from "child_process";
2309
2472
  import { readFile as readFile7 } from "fs/promises";
2310
2473
  import { promisify as promisify2 } from "util";
2311
- import { z as z28 } from "zod";
2474
+ import { z as z27 } from "zod";
2312
2475
 
2313
2476
  // ../cli/dist/scan/next-source-scan.js
2314
2477
  import ts2 from "typescript";
@@ -2318,52 +2481,30 @@ var editableComponentNames = new Set(["Image", "Text", "LongText", "Link"].map((
2318
2481
 
2319
2482
  // ../cli/dist/commands/site-setup.js
2320
2483
  var execFileAsync2 = promisify2(execFile2);
2321
- var safeErrorSchema = z28.object({
2322
- code: z28.string().trim().min(1),
2323
- message: z28.string().trim().min(1)
2484
+ var safeErrorSchema = z27.object({
2485
+ code: z27.string().trim().min(1),
2486
+ message: z27.string().trim().min(1)
2324
2487
  }).passthrough();
2325
- var errorResponseSchema2 = z28.object({ ok: z28.literal(false), error: safeErrorSchema }).passthrough();
2326
- var contextDataSchema = z28.object({
2327
- site: z28.object({ siteId: z28.string().uuid(), portalPath: z28.string() }),
2328
- run: z28.object({
2329
- runId: z28.string().uuid(),
2330
- mode: z28.enum(["initial", "update"]),
2331
- status: z28.enum([
2332
- "waiting_for_agent",
2333
- "working",
2334
- "action_required",
2335
- "ready_for_review"
2336
- ]),
2337
- fieldContractHash: z28.string().nullable(),
2338
- deploymentOrigin: z28.string().nullable(),
2339
- deploymentRevision: z28.string().nullable(),
2340
- errorCode: z28.string().nullable(),
2341
- errorMessage: z28.string().nullable()
2342
- }),
2343
- structureHandoff: z28.object({
2344
- pendingFields: z28.array(setupCorrectionItemSchema).min(1).max(50)
2345
- }).strict().nullable(),
2346
- allowedTasks: z28.array(z28.string()),
2347
- requiredEnvironmentNames: z28.array(z28.string())
2348
- }).strict();
2349
- var contextResponseSchema = z28.object({ ok: z28.literal(true), data: contextDataSchema }).strict();
2350
- var applyDataSchema = z28.object({
2351
- status: z28.enum(["applied", "ready_for_review"]),
2352
- runId: z28.string().uuid().optional(),
2353
- contractVersionId: z28.string().uuid().optional(),
2354
- fieldContractHash: z28.string().regex(/^sha256:[0-9a-f]{64}$/u),
2355
- editorDefinitionHash: z28.string().regex(/^sha256:[0-9a-f]{64}$/u).optional(),
2356
- fieldCount: z28.number().int().nonnegative().optional(),
2357
- routeCount: z28.number().int().nonnegative().optional()
2488
+ var errorResponseSchema2 = z27.object({ ok: z27.literal(false), error: safeErrorSchema }).passthrough();
2489
+ var contextDataSchema = z27.object({ task: siteSetupTaskSchema }).strict();
2490
+ var contextResponseSchema = z27.object({ ok: z27.literal(true), data: contextDataSchema }).strict();
2491
+ var applyDataSchema = z27.object({
2492
+ status: z27.enum(["applied", "ready_for_review"]),
2493
+ runId: z27.string().uuid().optional(),
2494
+ contractVersionId: z27.string().uuid().optional(),
2495
+ fieldContractHash: z27.string().regex(/^sha256:[0-9a-f]{64}$/u),
2496
+ editorDefinitionHash: z27.string().regex(/^sha256:[0-9a-f]{64}$/u).optional(),
2497
+ fieldCount: z27.number().int().nonnegative().optional(),
2498
+ routeCount: z27.number().int().nonnegative().optional()
2358
2499
  }).strict();
2359
- var applyResponseSchema = z28.object({ ok: z28.literal(true), data: applyDataSchema }).strict();
2360
- var verifyDataSchema = z28.object({
2361
- status: z28.literal("ready_for_review"),
2362
- runId: z28.string().uuid().optional(),
2363
- deploymentOrigin: z28.string().url().optional(),
2364
- deploymentRevision: z28.string().optional()
2500
+ var applyResponseSchema = z27.object({ ok: z27.literal(true), data: applyDataSchema }).strict();
2501
+ var verifyDataSchema = z27.object({
2502
+ status: z27.literal("ready_for_review"),
2503
+ runId: z27.string().uuid().optional(),
2504
+ deploymentOrigin: z27.string().url().optional(),
2505
+ deploymentRevision: z27.string().optional()
2365
2506
  }).strict();
2366
- var verifyResponseSchema = z28.object({ ok: z28.literal(true), data: verifyDataSchema }).strict();
2507
+ var verifyResponseSchema = z27.object({ ok: z27.literal(true), data: verifyDataSchema }).strict();
2367
2508
  export {
2368
2509
  bookingCheckCommand,
2369
2510
  bookingInitCommand,