@construct-space/cli 1.6.3 → 1.6.4

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
@@ -2889,8 +2889,12 @@ function load2() {
2889
2889
  const path = credentialsPath();
2890
2890
  if (existsSync10(path)) {
2891
2891
  const data = JSON.parse(readFileSync7(path, "utf-8"));
2892
- if (data.token)
2892
+ if (data.token) {
2893
+ if (!data.publisherKey && data.token.startsWith("csk_live_")) {
2894
+ data.publisherKey = data.token;
2895
+ }
2893
2896
  return data;
2897
+ }
2894
2898
  }
2895
2899
  const fromProfile = loadFromActiveProfile();
2896
2900
  if (fromProfile)
@@ -2923,7 +2927,10 @@ function loadFromActiveProfile() {
2923
2927
  id: u.id || u.uuid || activeId,
2924
2928
  name: u.name || u.username || activeId,
2925
2929
  email: u.email || ""
2926
- }
2930
+ },
2931
+ publisherKey: a.publisher?.api_key,
2932
+ publisherKind: a.publisher?.kind,
2933
+ publisherName: a.publisher?.name
2927
2934
  };
2928
2935
  } catch {
2929
2936
  return null;
@@ -5291,8 +5298,7 @@ async function scaffold(nameArg, options) {
5291
5298
  join2(name, "agent", "skills"),
5292
5299
  join2(name, "agent", "hooks"),
5293
5300
  join2(name, "agent", "tools"),
5294
- join2(name, "widgets", "summary"),
5295
- join2(name, ".github", "workflows")
5301
+ join2(name, "widgets", "summary")
5296
5302
  ];
5297
5303
  for (const d of dirs)
5298
5304
  mkdirSync(d, { recursive: true });
@@ -5311,7 +5317,6 @@ async function scaffold(nameArg, options) {
5311
5317
  "config.md.tmpl": join2(name, "agent", "config.md"),
5312
5318
  "skill.md.tmpl": join2(name, "agent", "skills", "default.md"),
5313
5319
  "safety.json.tmpl": join2(name, "agent", "hooks", "safety.json"),
5314
- "build.yml.tmpl": join2(name, ".github", "workflows", "build.yml"),
5315
5320
  "tsconfig.json.tmpl": join2(name, "tsconfig.json"),
5316
5321
  "eslint.config.js.tmpl": join2(name, "eslint.config.js"),
5317
5322
  "gitignore.tmpl": join2(name, ".gitignore"),
@@ -5353,8 +5358,8 @@ async function scaffold(nameArg, options) {
5353
5358
 
5354
5359
  // src/commands/build.ts
5355
5360
  init_source();
5356
- import { existsSync as existsSync6, readFileSync as readFileSync4, readdirSync as readdirSync3, renameSync, statSync as statSync3 } from "fs";
5357
- import { extname as extname3, join as join6 } from "path";
5361
+ import { cpSync, existsSync as existsSync6, readFileSync as readFileSync4, readdirSync as readdirSync3, renameSync, statSync as statSync3 } from "fs";
5362
+ import { join as join6 } from "path";
5358
5363
  import { createHash } from "crypto";
5359
5364
 
5360
5365
  // node_modules/ora/index.js
@@ -7991,7 +7996,6 @@ function ora(options) {
7991
7996
  import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync3 } from "fs";
7992
7997
  import { join as join3 } from "path";
7993
7998
  var MANIFEST_FILE = "space.manifest.json";
7994
- var HOST_API_VERSION = "0.5.0";
7995
7999
  var idRegex = /^[a-z][a-z0-9-]*$/;
7996
8000
  var versionRegex = /^\d+\.\d+\.\d+/;
7997
8001
  function validate2(m) {
@@ -8248,245 +8252,53 @@ function bundleAgentDir(srcDir, distDir) {
8248
8252
  }
8249
8253
 
8250
8254
  // src/commands/build.ts
8251
- function stripComments(source) {
8252
- let out = "";
8253
- let i = 0;
8254
- let quote = null;
8255
- let escaped = false;
8256
- while (i < source.length) {
8257
- const ch = source[i];
8258
- const next = source[i + 1];
8259
- if (quote) {
8260
- out += ch;
8261
- if (escaped) {
8262
- escaped = false;
8263
- } else if (ch === "\\") {
8264
- escaped = true;
8265
- } else if (ch === quote) {
8266
- quote = null;
8267
- }
8268
- i++;
8269
- continue;
8270
- }
8271
- if (ch === '"' || ch === "'" || ch === "`") {
8272
- quote = ch;
8273
- out += ch;
8274
- i++;
8275
- continue;
8276
- }
8277
- if (ch === "/" && next === "/") {
8278
- while (i < source.length && source[i] !== `
8279
- `) {
8280
- out += " ";
8281
- i++;
8282
- }
8283
- continue;
8284
- }
8285
- if (ch === "/" && next === "*") {
8286
- out += " ";
8287
- i += 2;
8288
- while (i < source.length && !(source[i] === "*" && source[i + 1] === "/")) {
8289
- out += source[i] === `
8290
- ` ? `
8291
- ` : " ";
8292
- i++;
8293
- }
8294
- if (i < source.length) {
8295
- out += " ";
8296
- i += 2;
8297
- }
8298
- continue;
8299
- }
8300
- out += ch;
8301
- i++;
8302
- }
8303
- return out;
8304
- }
8305
- function findMatchingBrace(source, openIndex) {
8306
- let depth = 0;
8307
- let quote = null;
8308
- let escaped = false;
8309
- for (let i = openIndex;i < source.length; i++) {
8310
- const ch = source[i];
8311
- if (quote) {
8312
- if (escaped)
8313
- escaped = false;
8314
- else if (ch === "\\")
8315
- escaped = true;
8316
- else if (ch === quote)
8317
- quote = null;
8255
+ var ASSET_DIRS = ["icons", "assets", "media", "public"];
8256
+ function copyAssetDirs(root, distDir) {
8257
+ const copied = [];
8258
+ for (const name of ASSET_DIRS) {
8259
+ const src = join6(root, name);
8260
+ if (!existsSync6(src) || !statSync3(src).isDirectory())
8318
8261
  continue;
8319
- }
8320
- if (ch === '"' || ch === "'" || ch === "`") {
8321
- quote = ch;
8322
- continue;
8323
- }
8324
- if (ch === "{")
8325
- depth++;
8326
- else if (ch === "}") {
8327
- depth--;
8328
- if (depth === 0)
8329
- return i;
8330
- }
8262
+ cpSync(src, join6(distDir, name), { recursive: true });
8263
+ copied.push(name);
8331
8264
  }
8332
- return -1;
8333
- }
8334
- function objectLiteralAfter(source, start) {
8335
- const open = source.indexOf("{", start);
8336
- if (open < 0)
8337
- return null;
8338
- const close = findMatchingBrace(source, open);
8339
- if (close < 0)
8340
- return null;
8341
- return source.slice(open + 1, close);
8342
- }
8343
- function actionsObject(source) {
8344
- const stripped = stripComments(source);
8345
- const match = /export\s+const\s+actions\s*=/.exec(stripped);
8346
- if (!match)
8347
- return null;
8348
- return objectLiteralAfter(stripped, match.index + match[0].length);
8349
- }
8350
- function objectEntries(body) {
8351
- const entries = [];
8352
- let i = 0;
8353
- while (i < body.length) {
8354
- const match = /\s*,?\s*([A-Za-z_$][\w$]*)\s*:/.exec(body.slice(i));
8355
- if (!match)
8356
- break;
8357
- const name = match[1];
8358
- const valueStart = i + match.index + match[0].length;
8359
- const open = body.indexOf("{", valueStart);
8360
- if (open < 0)
8361
- break;
8362
- if (body.slice(valueStart, open).trim()) {
8363
- i = valueStart;
8364
- continue;
8365
- }
8366
- const close = findMatchingBrace(body, open);
8367
- if (close < 0)
8368
- break;
8369
- entries.push({ name, body: body.slice(open + 1, close) });
8370
- i = close + 1;
8371
- }
8372
- return entries;
8373
- }
8374
- function stringProperty(body, name) {
8375
- const match = new RegExp(`${name}\\s*:\\s*['"\`]([^'"\`]*)['"\`]`).exec(body);
8376
- return match?.[1];
8377
- }
8378
- function booleanProperty(body, name) {
8379
- const match = new RegExp(`${name}\\s*:\\s*(true|false)`).exec(body);
8380
- if (!match)
8381
- return;
8382
- return match[1] === "true";
8383
- }
8384
- function propertyObject(body, name) {
8385
- const match = new RegExp(`${name}\\s*:`).exec(body);
8386
- if (!match)
8387
- return null;
8388
- return objectLiteralAfter(body, match.index + match[0].length);
8265
+ return copied;
8389
8266
  }
8390
8267
  function extractActionMetadata(actionsPath) {
8391
8268
  try {
8392
- const actionsBody = actionsObject(readFileSync4(actionsPath, "utf-8"));
8393
- if (!actionsBody)
8394
- return null;
8269
+ const source = readFileSync4(actionsPath, "utf-8");
8395
8270
  const result = {};
8396
- for (const action of objectEntries(actionsBody)) {
8397
- const description = stringProperty(action.body, "description");
8398
- if (!description)
8399
- continue;
8400
- const metadata = { description };
8401
- const paramsBody = propertyObject(action.body, "params");
8402
- if (paramsBody) {
8271
+ const actionPattern = /(\w+)\s*:\s*\{[^}]*description\s*:\s*['"`]([^'"`]+)['"`]/g;
8272
+ let match;
8273
+ while ((match = actionPattern.exec(source)) !== null) {
8274
+ const actionId = match[1];
8275
+ const description = match[2];
8276
+ result[actionId] = { description };
8277
+ }
8278
+ for (const actionId of Object.keys(result)) {
8279
+ const paramBlockPattern = new RegExp(`${actionId}\\s*:\\s*\\{[\\s\\S]*?params\\s*:\\s*\\{([\\s\\S]*?)\\}\\s*,?\\s*(?:run|\\})`);
8280
+ const paramMatch = source.match(paramBlockPattern);
8281
+ if (paramMatch?.[1]) {
8403
8282
  const params = {};
8404
- for (const param of objectEntries(paramsBody)) {
8405
- const type = stringProperty(param.body, "type");
8406
- if (!type)
8407
- continue;
8408
- const required = booleanProperty(param.body, "required");
8409
- params[param.name] = {
8410
- type,
8411
- ...stringProperty(param.body, "description") ? { description: stringProperty(param.body, "description") } : {},
8412
- ...required === true ? { required: true } : {}
8283
+ const paramEntryPattern = /(\w+)\s*:\s*\{\s*type\s*:\s*['"`](\w+)['"`](?:\s*,\s*description\s*:\s*['"`]([^'"`]*)['"`])?(?:\s*,\s*required\s*:\s*(true|false))?\s*\}/g;
8284
+ let pm;
8285
+ while ((pm = paramEntryPattern.exec(paramMatch[1])) !== null) {
8286
+ params[pm[1]] = {
8287
+ type: pm[2],
8288
+ ...pm[3] ? { description: pm[3] } : {},
8289
+ ...pm[4] === "true" ? { required: true } : {}
8413
8290
  };
8414
8291
  }
8415
- if (Object.keys(params).length > 0)
8416
- metadata.params = params;
8292
+ if (Object.keys(params).length > 0) {
8293
+ result[actionId].params = params;
8294
+ }
8417
8295
  }
8418
- result[action.name] = metadata;
8419
8296
  }
8420
8297
  return Object.keys(result).length > 0 ? result : null;
8421
8298
  } catch {
8422
8299
  return null;
8423
8300
  }
8424
8301
  }
8425
- var ICON_MIME = {
8426
- ".svg": "image/svg+xml",
8427
- ".png": "image/png",
8428
- ".jpg": "image/jpeg",
8429
- ".jpeg": "image/jpeg",
8430
- ".webp": "image/webp",
8431
- ".gif": "image/gif",
8432
- ".ico": "image/x-icon"
8433
- };
8434
- function isInlineableIcon(value) {
8435
- if (typeof value !== "string" || !value)
8436
- return false;
8437
- if (value.startsWith("i-") || value.startsWith("lucide:"))
8438
- return false;
8439
- if (value.startsWith("data:"))
8440
- return false;
8441
- if (/^https?:\/\//.test(value))
8442
- return false;
8443
- return extname3(value).toLowerCase() in ICON_MIME;
8444
- }
8445
- function resolveIconPath(root, ref) {
8446
- const rel = ref.replace(/^\.?\//, "");
8447
- for (const candidate of [join6(root, rel), join6(root, "src", rel)]) {
8448
- if (existsSync6(candidate))
8449
- return candidate;
8450
- }
8451
- return null;
8452
- }
8453
- function inlineIcon(root, ref) {
8454
- const abs = resolveIconPath(root, ref);
8455
- if (!abs)
8456
- return null;
8457
- const mime = ICON_MIME[extname3(abs).toLowerCase()] || "application/octet-stream";
8458
- const b64 = readFileSync4(abs).toString("base64");
8459
- return `data:${mime};base64,${b64}`;
8460
- }
8461
- function inlineManifestIcons(root, raw) {
8462
- if (isInlineableIcon(raw.icon)) {
8463
- const data = inlineIcon(root, raw.icon);
8464
- if (data)
8465
- raw.icon = data;
8466
- else
8467
- console.warn(source_default.yellow(` Icon not found: ${raw.icon}`));
8468
- }
8469
- const nav = raw.navigation;
8470
- if (nav && isInlineableIcon(nav.icon)) {
8471
- const data = inlineIcon(root, nav.icon);
8472
- if (data)
8473
- nav.icon = data;
8474
- else
8475
- console.warn(source_default.yellow(` navigation.icon not found: ${nav.icon}`));
8476
- }
8477
- const pages = raw.pages;
8478
- if (Array.isArray(pages)) {
8479
- for (const p of pages) {
8480
- if (isInlineableIcon(p.icon)) {
8481
- const data = inlineIcon(root, p.icon);
8482
- if (data)
8483
- p.icon = data;
8484
- else
8485
- console.warn(source_default.yellow(` page icon not found: ${p.icon}`));
8486
- }
8487
- }
8488
- }
8489
- }
8490
8302
  async function build(options) {
8491
8303
  const root = process.cwd();
8492
8304
  if (!exists(root)) {
@@ -8519,6 +8331,10 @@ async function build(options) {
8519
8331
  bundleAgentDir(agentDir, distDir2);
8520
8332
  bundleAgentDir(agentDir, root);
8521
8333
  }
8334
+ const copiedAssetDirs = copyAssetDirs(root, join6(root, "dist"));
8335
+ if (copiedAssetDirs.length > 0) {
8336
+ console.log(source_default.blue(` Assets: ${copiedAssetDirs.join(", ")}`));
8337
+ }
8522
8338
  const distDir = join6(root, "dist");
8523
8339
  const expectedBundle = `space-${m.id}.iife.js`;
8524
8340
  let bundlePath = join6(distDir, expectedBundle);
@@ -8535,7 +8351,6 @@ async function build(options) {
8535
8351
  const bundleData = readFileSync4(bundlePath);
8536
8352
  const checksum = createHash("sha256").update(bundleData).digest("hex");
8537
8353
  const raw = readRaw(root);
8538
- inlineManifestIcons(root, raw);
8539
8354
  const actionsPath = join6(root, "src", "actions.ts");
8540
8355
  if (existsSync6(actionsPath)) {
8541
8356
  const actionMeta = extractActionMetadata(actionsPath);
@@ -8547,7 +8362,7 @@ async function build(options) {
8547
8362
  writeWithBuild(distDir, raw, {
8548
8363
  checksum,
8549
8364
  size: bundleData.length,
8550
- hostApiVersion: HOST_API_VERSION,
8365
+ hostApiVersion: "0.5.0",
8551
8366
  builtAt: new Date().toISOString()
8552
8367
  });
8553
8368
  console.log(source_default.green(`Built ${m.name} v${m.version}`));
@@ -8559,16 +8374,16 @@ import { existsSync as existsSync7, readFileSync as readFileSync5 } from "fs";
8559
8374
  import { join as join9 } from "path";
8560
8375
  import { createHash as createHash2 } from "crypto";
8561
8376
 
8562
- // node_modules/chokidar/index.js
8377
+ // node_modules/chokidar/esm/index.js
8378
+ import { stat as statcb } from "fs";
8379
+ import { stat as stat3, readdir as readdir2 } from "fs/promises";
8563
8380
  import { EventEmitter } from "events";
8564
- import { stat as statcb, Stats } from "fs";
8565
- import { readdir as readdir2, stat as stat3 } from "fs/promises";
8566
- import * as sp2 from "path";
8381
+ import * as sysPath2 from "path";
8567
8382
 
8568
- // node_modules/readdirp/index.js
8569
- import { lstat, readdir, realpath, stat } from "fs/promises";
8570
- import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from "path";
8383
+ // node_modules/readdirp/esm/index.js
8384
+ import { stat, lstat, readdir, realpath } from "fs/promises";
8571
8385
  import { Readable } from "stream";
8386
+ import { resolve as presolve, relative as prelative, join as pjoin, sep as psep } from "path";
8572
8387
  var EntryTypes = {
8573
8388
  FILE_TYPE: "files",
8574
8389
  DIR_TYPE: "directories",
@@ -8624,20 +8439,6 @@ var normalizeFilter = (filter) => {
8624
8439
  };
8625
8440
 
8626
8441
  class ReaddirpStream extends Readable {
8627
- parents;
8628
- reading;
8629
- parent;
8630
- _stat;
8631
- _maxDepth;
8632
- _wantsDir;
8633
- _wantsFile;
8634
- _wantsEverything;
8635
- _root;
8636
- _isDirent;
8637
- _statsProp;
8638
- _rdOptions;
8639
- _fileFilter;
8640
- _directoryFilter;
8641
8442
  constructor(options = {}) {
8642
8443
  super({
8643
8444
  objectMode: true,
@@ -8654,7 +8455,7 @@ class ReaddirpStream extends Readable {
8654
8455
  } else {
8655
8456
  this._stat = statMethod;
8656
8457
  }
8657
- this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
8458
+ this._maxDepth = opts.depth ?? defaultOptions.depth;
8658
8459
  this._wantsDir = type ? DIR_TYPES.has(type) : false;
8659
8460
  this._wantsFile = type ? FILE_TYPES.has(type) : false;
8660
8461
  this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
@@ -8799,11 +8600,11 @@ function readdirp(root, options = {}) {
8799
8600
  return new ReaddirpStream(options);
8800
8601
  }
8801
8602
 
8802
- // node_modules/chokidar/handler.js
8803
- import { watch as fs_watch, unwatchFile, watchFile } from "fs";
8804
- import { realpath as fsrealpath, lstat as lstat2, open, stat as stat2 } from "fs/promises";
8603
+ // node_modules/chokidar/esm/handler.js
8604
+ import { watchFile, unwatchFile, watch as fs_watch } from "fs";
8605
+ import { open, stat as stat2, lstat as lstat2, realpath as fsrealpath } from "fs/promises";
8606
+ import * as sysPath from "path";
8805
8607
  import { type as osType } from "os";
8806
- import * as sp from "path";
8807
8608
  var STR_DATA = "data";
8808
8609
  var STR_END = "end";
8809
8610
  var STR_CLOSE = "close";
@@ -9095,7 +8896,7 @@ var binaryExtensions = new Set([
9095
8896
  "zip",
9096
8897
  "zipx"
9097
8898
  ]);
9098
- var isBinaryPath = (filePath) => binaryExtensions.has(sp.extname(filePath).slice(1).toLowerCase());
8899
+ var isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());
9099
8900
  var foreach = (val, fn) => {
9100
8901
  if (val instanceof Set) {
9101
8902
  val.forEach(fn);
@@ -9133,7 +8934,7 @@ function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
9133
8934
  listener(path);
9134
8935
  emitRaw(rawEvent, evPath, { watchedPath: path });
9135
8936
  if (evPath && path !== evPath) {
9136
- fsWatchBroadcast(sp.resolve(path, evPath), KEY_LISTENERS, sp.join(path, evPath));
8937
+ fsWatchBroadcast(sysPath.resolve(path, evPath), KEY_LISTENERS, sysPath.join(path, evPath));
9137
8938
  }
9138
8939
  };
9139
8940
  try {
@@ -9248,19 +9049,17 @@ var setFsWatchFileListener = (path, fullPath, options, handlers) => {
9248
9049
  };
9249
9050
 
9250
9051
  class NodeFsHandler {
9251
- fsw;
9252
- _boundHandleError;
9253
9052
  constructor(fsW) {
9254
9053
  this.fsw = fsW;
9255
9054
  this._boundHandleError = (error2) => fsW._handleError(error2);
9256
9055
  }
9257
9056
  _watchWithNodeFs(path, listener) {
9258
9057
  const opts = this.fsw.options;
9259
- const directory = sp.dirname(path);
9260
- const basename4 = sp.basename(path);
9058
+ const directory = sysPath.dirname(path);
9059
+ const basename4 = sysPath.basename(path);
9261
9060
  const parent = this.fsw._getWatchedDir(directory);
9262
9061
  parent.add(basename4);
9263
- const absolutePath = sp.resolve(path);
9062
+ const absolutePath = sysPath.resolve(path);
9264
9063
  const options = {
9265
9064
  persistent: opts.persistent
9266
9065
  };
@@ -9287,8 +9086,8 @@ class NodeFsHandler {
9287
9086
  if (this.fsw.closed) {
9288
9087
  return;
9289
9088
  }
9290
- const dirname3 = sp.dirname(file);
9291
- const basename4 = sp.basename(file);
9089
+ const dirname3 = sysPath.dirname(file);
9090
+ const basename4 = sysPath.basename(file);
9292
9091
  const parent = this.fsw._getWatchedDir(dirname3);
9293
9092
  let prevStats = stats;
9294
9093
  if (parent.has(basename4))
@@ -9371,9 +9170,8 @@ class NodeFsHandler {
9371
9170
  this.fsw._symlinkPaths.set(full, true);
9372
9171
  }
9373
9172
  _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
9374
- directory = sp.join(directory, "");
9375
- const throttleKey = target ? `${directory}:${target}` : directory;
9376
- throttler = this.fsw._throttle("readdir", throttleKey, 1000);
9173
+ directory = sysPath.join(directory, "");
9174
+ throttler = this.fsw._throttle("readdir", directory, 1000);
9377
9175
  if (!throttler)
9378
9176
  return;
9379
9177
  const previous = this.fsw._getWatchedDir(wh.path);
@@ -9390,7 +9188,7 @@ class NodeFsHandler {
9390
9188
  return;
9391
9189
  }
9392
9190
  const item = entry.path;
9393
- let path = sp.join(directory, item);
9191
+ let path = sysPath.join(directory, item);
9394
9192
  current.add(item);
9395
9193
  if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) {
9396
9194
  return;
@@ -9401,7 +9199,7 @@ class NodeFsHandler {
9401
9199
  }
9402
9200
  if (item === target || !target && !previous.has(item)) {
9403
9201
  this.fsw._incrReadyCount();
9404
- path = sp.join(dir, sp.relative(dir, path));
9202
+ path = sysPath.join(dir, sysPath.relative(dir, path));
9405
9203
  this._addToNodeFs(path, initialAdd, wh, depth + 1);
9406
9204
  }
9407
9205
  }).on(EV.ERROR, this._boundHandleError);
@@ -9427,12 +9225,12 @@ class NodeFsHandler {
9427
9225
  });
9428
9226
  }
9429
9227
  async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
9430
- const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
9431
- const tracked = parentDir.has(sp.basename(dir));
9228
+ const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
9229
+ const tracked = parentDir.has(sysPath.basename(dir));
9432
9230
  if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
9433
9231
  this.fsw._emit(EV.ADD_DIR, dir, stats);
9434
9232
  }
9435
- parentDir.add(sp.basename(dir));
9233
+ parentDir.add(sysPath.basename(dir));
9436
9234
  this.fsw._getWatchedDir(dir);
9437
9235
  let throttler;
9438
9236
  let closer;
@@ -9473,7 +9271,7 @@ class NodeFsHandler {
9473
9271
  const follow = this.fsw.options.followSymlinks;
9474
9272
  let closer;
9475
9273
  if (stats.isDirectory()) {
9476
- const absPath = sp.resolve(path);
9274
+ const absPath = sysPath.resolve(path);
9477
9275
  const targetPath = follow ? await fsrealpath(path) : path;
9478
9276
  if (this.fsw.closed)
9479
9277
  return;
@@ -9487,14 +9285,14 @@ class NodeFsHandler {
9487
9285
  const targetPath = follow ? await fsrealpath(path) : path;
9488
9286
  if (this.fsw.closed)
9489
9287
  return;
9490
- const parent = sp.dirname(wh.watchPath);
9288
+ const parent = sysPath.dirname(wh.watchPath);
9491
9289
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
9492
9290
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
9493
9291
  closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
9494
9292
  if (this.fsw.closed)
9495
9293
  return;
9496
9294
  if (targetPath !== undefined) {
9497
- this.fsw._symlinkPaths.set(sp.resolve(path), targetPath);
9295
+ this.fsw._symlinkPaths.set(sysPath.resolve(path), targetPath);
9498
9296
  }
9499
9297
  } else {
9500
9298
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
@@ -9512,7 +9310,7 @@ class NodeFsHandler {
9512
9310
  }
9513
9311
  }
9514
9312
 
9515
- // node_modules/chokidar/index.js
9313
+ // node_modules/chokidar/esm/index.js
9516
9314
  /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
9517
9315
  var SLASH = "/";
9518
9316
  var SLASH_SLASH = "//";
@@ -9520,7 +9318,7 @@ var ONE_DOT = ".";
9520
9318
  var TWO_DOTS = "..";
9521
9319
  var STRING_TYPE = "string";
9522
9320
  var BACK_SLASH_RE = /\\/g;
9523
- var DOUBLE_SLASH_RE = /\/\//g;
9321
+ var DOUBLE_SLASH_RE = /\/\//;
9524
9322
  var DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
9525
9323
  var REPLACER_RE = /^\.[/\\]/;
9526
9324
  function arrify(item) {
@@ -9539,11 +9337,11 @@ function createPattern(matcher) {
9539
9337
  if (matcher.path === string)
9540
9338
  return true;
9541
9339
  if (matcher.recursive) {
9542
- const relative4 = sp2.relative(matcher.path, string);
9340
+ const relative4 = sysPath2.relative(matcher.path, string);
9543
9341
  if (!relative4) {
9544
9342
  return false;
9545
9343
  }
9546
- return !relative4.startsWith("..") && !sp2.isAbsolute(relative4);
9344
+ return !relative4.startsWith("..") && !sysPath2.isAbsolute(relative4);
9547
9345
  }
9548
9346
  return false;
9549
9347
  };
@@ -9553,12 +9351,14 @@ function createPattern(matcher) {
9553
9351
  function normalizePath(path) {
9554
9352
  if (typeof path !== "string")
9555
9353
  throw new Error("string expected");
9556
- path = sp2.normalize(path);
9354
+ path = sysPath2.normalize(path);
9557
9355
  path = path.replace(/\\/g, "/");
9558
9356
  let prepend = false;
9559
9357
  if (path.startsWith("//"))
9560
9358
  prepend = true;
9561
- path = path.replace(DOUBLE_SLASH_RE, "/");
9359
+ const DOUBLE_SLASH_RE2 = /\/\//;
9360
+ while (path.match(DOUBLE_SLASH_RE2))
9361
+ path = path.replace(DOUBLE_SLASH_RE2, "/");
9562
9362
  if (prepend)
9563
9363
  path = "/" + path;
9564
9364
  return path;
@@ -9599,32 +9399,31 @@ var toUnix = (string) => {
9599
9399
  if (str.startsWith(SLASH_SLASH)) {
9600
9400
  prepend = true;
9601
9401
  }
9602
- str = str.replace(DOUBLE_SLASH_RE, SLASH);
9402
+ while (str.match(DOUBLE_SLASH_RE)) {
9403
+ str = str.replace(DOUBLE_SLASH_RE, SLASH);
9404
+ }
9603
9405
  if (prepend) {
9604
9406
  str = SLASH + str;
9605
9407
  }
9606
9408
  return str;
9607
9409
  };
9608
- var normalizePathToUnix = (path) => toUnix(sp2.normalize(toUnix(path)));
9410
+ var normalizePathToUnix = (path) => toUnix(sysPath2.normalize(toUnix(path)));
9609
9411
  var normalizeIgnored = (cwd = "") => (path) => {
9610
9412
  if (typeof path === "string") {
9611
- return normalizePathToUnix(sp2.isAbsolute(path) ? path : sp2.join(cwd, path));
9413
+ return normalizePathToUnix(sysPath2.isAbsolute(path) ? path : sysPath2.join(cwd, path));
9612
9414
  } else {
9613
9415
  return path;
9614
9416
  }
9615
9417
  };
9616
9418
  var getAbsolutePath = (path, cwd) => {
9617
- if (sp2.isAbsolute(path)) {
9419
+ if (sysPath2.isAbsolute(path)) {
9618
9420
  return path;
9619
9421
  }
9620
- return sp2.join(cwd, path);
9422
+ return sysPath2.join(cwd, path);
9621
9423
  };
9622
9424
  var EMPTY_SET = Object.freeze(new Set);
9623
9425
 
9624
9426
  class DirEntry {
9625
- path;
9626
- _removeWatcher;
9627
- items;
9628
9427
  constructor(dir, removeWatcher) {
9629
9428
  this.path = dir;
9630
9429
  this._removeWatcher = removeWatcher;
@@ -9649,7 +9448,7 @@ class DirEntry {
9649
9448
  await readdir2(dir);
9650
9449
  } catch (err) {
9651
9450
  if (this._removeWatcher) {
9652
- this._removeWatcher(sp2.dirname(dir), sp2.basename(dir));
9451
+ this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
9653
9452
  }
9654
9453
  }
9655
9454
  }
@@ -9677,19 +9476,12 @@ var STAT_METHOD_F = "stat";
9677
9476
  var STAT_METHOD_L = "lstat";
9678
9477
 
9679
9478
  class WatchHelper {
9680
- fsw;
9681
- path;
9682
- watchPath;
9683
- fullWatchPath;
9684
- dirParts;
9685
- followSymlinks;
9686
- statMethod;
9687
9479
  constructor(path, follow, fsw) {
9688
9480
  this.fsw = fsw;
9689
9481
  const watchPath = path;
9690
9482
  this.path = path = path.replace(REPLACER_RE, "");
9691
9483
  this.watchPath = watchPath;
9692
- this.fullWatchPath = sp2.resolve(watchPath);
9484
+ this.fullWatchPath = sysPath2.resolve(watchPath);
9693
9485
  this.dirParts = [];
9694
9486
  this.dirParts.forEach((parts) => {
9695
9487
  if (parts.length > 1)
@@ -9699,7 +9491,7 @@ class WatchHelper {
9699
9491
  this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
9700
9492
  }
9701
9493
  entryPath(entry) {
9702
- return sp2.join(this.watchPath, sp2.relative(this.watchPath, entry.fullPath));
9494
+ return sysPath2.join(this.watchPath, sysPath2.relative(this.watchPath, entry.fullPath));
9703
9495
  }
9704
9496
  filterPath(entry) {
9705
9497
  const { stats } = entry;
@@ -9714,24 +9506,6 @@ class WatchHelper {
9714
9506
  }
9715
9507
 
9716
9508
  class FSWatcher extends EventEmitter {
9717
- closed;
9718
- options;
9719
- _closers;
9720
- _ignoredPaths;
9721
- _throttled;
9722
- _streams;
9723
- _symlinkPaths;
9724
- _watched;
9725
- _pendingWrites;
9726
- _pendingUnlinks;
9727
- _readyCount;
9728
- _emitReady;
9729
- _closePromise;
9730
- _userIgnored;
9731
- _readyEmitted;
9732
- _emitRaw;
9733
- _boundRemove;
9734
- _nodeFsHandler;
9735
9509
  constructor(_opts = {}) {
9736
9510
  super();
9737
9511
  this.closed = false;
@@ -9840,7 +9614,7 @@ class FSWatcher extends EventEmitter {
9840
9614
  return;
9841
9615
  results.forEach((item) => {
9842
9616
  if (item)
9843
- this.add(sp2.dirname(item), sp2.basename(_origAdd || item));
9617
+ this.add(sysPath2.dirname(item), sysPath2.basename(_origAdd || item));
9844
9618
  });
9845
9619
  });
9846
9620
  return this;
@@ -9851,10 +9625,10 @@ class FSWatcher extends EventEmitter {
9851
9625
  const paths = unifyPaths(paths_);
9852
9626
  const { cwd } = this.options;
9853
9627
  paths.forEach((path) => {
9854
- if (!sp2.isAbsolute(path) && !this._closers.has(path)) {
9628
+ if (!sysPath2.isAbsolute(path) && !this._closers.has(path)) {
9855
9629
  if (cwd)
9856
- path = sp2.join(cwd, path);
9857
- path = sp2.resolve(path);
9630
+ path = sysPath2.join(cwd, path);
9631
+ path = sysPath2.resolve(path);
9858
9632
  }
9859
9633
  this._closePath(path);
9860
9634
  this._addIgnoredPath(path);
@@ -9898,7 +9672,7 @@ class FSWatcher extends EventEmitter {
9898
9672
  getWatched() {
9899
9673
  const watchList = {};
9900
9674
  this._watched.forEach((entry, dir) => {
9901
- const key = this.options.cwd ? sp2.relative(this.options.cwd, dir) : dir;
9675
+ const key = this.options.cwd ? sysPath2.relative(this.options.cwd, dir) : dir;
9902
9676
  const index = key || ONE_DOT;
9903
9677
  watchList[index] = entry.getChildren().sort();
9904
9678
  });
@@ -9914,9 +9688,9 @@ class FSWatcher extends EventEmitter {
9914
9688
  return;
9915
9689
  const opts = this.options;
9916
9690
  if (isWindows)
9917
- path = sp2.normalize(path);
9691
+ path = sysPath2.normalize(path);
9918
9692
  if (opts.cwd)
9919
- path = sp2.relative(opts.cwd, path);
9693
+ path = sysPath2.relative(opts.cwd, path);
9920
9694
  const args = [path];
9921
9695
  if (stats != null)
9922
9696
  args.push(stats);
@@ -9967,7 +9741,7 @@ class FSWatcher extends EventEmitter {
9967
9741
  return this;
9968
9742
  }
9969
9743
  if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
9970
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path) : path;
9744
+ const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path) : path;
9971
9745
  let stats2;
9972
9746
  try {
9973
9747
  stats2 = await stat3(fullPath);
@@ -10023,8 +9797,8 @@ class FSWatcher extends EventEmitter {
10023
9797
  const pollInterval = awf.pollInterval;
10024
9798
  let timeoutHandler;
10025
9799
  let fullPath = path;
10026
- if (this.options.cwd && !sp2.isAbsolute(path)) {
10027
- fullPath = sp2.join(this.options.cwd, path);
9800
+ if (this.options.cwd && !sysPath2.isAbsolute(path)) {
9801
+ fullPath = sysPath2.join(this.options.cwd, path);
10028
9802
  }
10029
9803
  const now = new Date;
10030
9804
  const writes = this._pendingWrites;
@@ -10081,7 +9855,7 @@ class FSWatcher extends EventEmitter {
10081
9855
  return new WatchHelper(path, this.options.followSymlinks, this);
10082
9856
  }
10083
9857
  _getWatchedDir(directory) {
10084
- const dir = sp2.resolve(directory);
9858
+ const dir = sysPath2.resolve(directory);
10085
9859
  if (!this._watched.has(dir))
10086
9860
  this._watched.set(dir, new DirEntry(dir, this._boundRemove));
10087
9861
  return this._watched.get(dir);
@@ -10092,8 +9866,8 @@ class FSWatcher extends EventEmitter {
10092
9866
  return Boolean(Number(stats.mode) & 256);
10093
9867
  }
10094
9868
  _remove(directory, item, isDirectory) {
10095
- const path = sp2.join(directory, item);
10096
- const fullPath = sp2.resolve(path);
9869
+ const path = sysPath2.join(directory, item);
9870
+ const fullPath = sysPath2.resolve(path);
10097
9871
  isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
10098
9872
  if (!this._throttle("remove", path, 100))
10099
9873
  return;
@@ -10111,7 +9885,7 @@ class FSWatcher extends EventEmitter {
10111
9885
  }
10112
9886
  let relPath = path;
10113
9887
  if (this.options.cwd)
10114
- relPath = sp2.relative(this.options.cwd, path);
9888
+ relPath = sysPath2.relative(this.options.cwd, path);
10115
9889
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
10116
9890
  const event = this._pendingWrites.get(relPath).cancelWait();
10117
9891
  if (event === EVENTS.ADD)
@@ -10126,8 +9900,8 @@ class FSWatcher extends EventEmitter {
10126
9900
  }
10127
9901
  _closePath(path) {
10128
9902
  this._closeFile(path);
10129
- const dir = sp2.dirname(path);
10130
- this._getWatchedDir(dir).remove(sp2.basename(path));
9903
+ const dir = sysPath2.dirname(path);
9904
+ this._getWatchedDir(dir).remove(sysPath2.basename(path));
10131
9905
  }
10132
9906
  _closeFile(path) {
10133
9907
  const closers = this._closers.get(path);
@@ -10229,7 +10003,7 @@ async function dev() {
10229
10003
  writeWithBuild(distDir, raw, {
10230
10004
  checksum,
10231
10005
  size: bundleData.length,
10232
- hostApiVersion: HOST_API_VERSION,
10006
+ hostApiVersion: "0.5.0",
10233
10007
  builtAt: new Date().toISOString()
10234
10008
  });
10235
10009
  console.log(source_default.green(`Built \u2192 dist/ (${(bundleData.length / 1024).toFixed(1)} KB)`));
@@ -10241,7 +10015,7 @@ async function dev() {
10241
10015
 
10242
10016
  // src/commands/run.ts
10243
10017
  init_source();
10244
- import { existsSync as existsSync9, cpSync, mkdirSync as mkdirSync3 } from "fs";
10018
+ import { existsSync as existsSync9, cpSync as cpSync2, mkdirSync as mkdirSync3 } from "fs";
10245
10019
  import { join as join11 } from "path";
10246
10020
  init_appdir();
10247
10021
  function install() {
@@ -10262,7 +10036,7 @@ function install() {
10262
10036
  }
10263
10037
  const installDir = spaceDir(m.id);
10264
10038
  mkdirSync3(installDir, { recursive: true });
10265
- cpSync(distDir, installDir, { recursive: true });
10039
+ cpSync2(distDir, installDir, { recursive: true });
10266
10040
  console.log(source_default.green(`Installed ${m.name} \u2192 ${installDir}`));
10267
10041
  console.log(source_default.dim(" Restart Construct to load the updated space."));
10268
10042
  }
@@ -10467,12 +10241,25 @@ async function publish(options) {
10467
10241
  m = read(root);
10468
10242
  console.log(source_default.green(`Version bumped to ${m.version}`));
10469
10243
  }
10244
+ const publishToken = creds.publisherKey ?? creds.token;
10245
+ if (!creds.publisherKey) {
10246
+ console.log(source_default.yellow("No publisher key in active profile."));
10247
+ console.log(source_default.dim(" Spaces will be attributed to your personal user identity."));
10248
+ console.log(source_default.dim(" To publish as an org: enroll the org from the desktop app"));
10249
+ console.log(source_default.dim(" (Org Settings \u2192 Developer), then re-run this command."));
10250
+ console.log();
10251
+ }
10470
10252
  console.log();
10471
10253
  console.log(` Space: ${source_default.cyan(m.name)}`);
10472
10254
  console.log(` Version: ${source_default.cyan("v" + m.version)}`);
10473
10255
  console.log(` Server: ${source_default.dim(creds.portal)}`);
10474
- if (creds.user)
10256
+ if (creds.publisherKey) {
10257
+ const kind = creds.publisherKind === "org" ? "org" : "personal";
10258
+ const label = creds.publisherName || creds.user?.name || "";
10259
+ console.log(` As: ${source_default.cyan(label)} ${source_default.dim(`(${kind} publisher)`)}`);
10260
+ } else if (creds.user) {
10475
10261
  console.log(` Author: ${source_default.dim(creds.user.name)}`);
10262
+ }
10476
10263
  console.log();
10477
10264
  if (!yes) {
10478
10265
  const proceed = await dist_default4({
@@ -10496,7 +10283,7 @@ async function publish(options) {
10496
10283
  }
10497
10284
  const uploadSpinner = ora("Uploading & building...").start();
10498
10285
  try {
10499
- const result = await uploadSource(creds.portal, creds.token, tarballPath, m);
10286
+ const result = await uploadSource(creds.portal, publishToken, tarballPath, m);
10500
10287
  unlinkSync2(tarballPath);
10501
10288
  gitSafe(root, "tag", `v${m.version}`);
10502
10289
  gitSafe(root, "push", "origin", `v${m.version}`);
@@ -11445,7 +11232,7 @@ function graphFork(newSpaceID) {
11445
11232
  // package.json
11446
11233
  var package_default = {
11447
11234
  name: "@construct-space/cli",
11448
- version: "1.6.3",
11235
+ version: "1.6.4",
11449
11236
  description: "Construct CLI \u2014 scaffold, build, develop, and publish spaces",
11450
11237
  type: "module",
11451
11238
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@construct-space/cli",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
4
4
  "description": "Construct CLI — scaffold, build, develop, and publish spaces",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,44 +0,0 @@
1
- name: Build Space
2
-
3
- on:
4
- push:
5
- tags:
6
- - 'v*'
7
- pull_request:
8
- branches: [main]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v4
15
- - uses: oven-sh/setup-bun@v2
16
- with:
17
- bun-version: latest
18
- - run: bun install
19
- - run: bun run build
20
- - name: Upload artifacts
21
- if: startsWith(github.ref, 'refs/tags/v')
22
- uses: actions/upload-artifact@v4
23
- with:
24
- name: space-dist
25
- path: dist/
26
-
27
- release:
28
- needs: build
29
- if: startsWith(github.ref, 'refs/tags/v')
30
- runs-on: ubuntu-latest
31
- permissions:
32
- contents: write
33
- steps:
34
- - uses: actions/download-artifact@v4
35
- with:
36
- name: space-dist
37
- path: dist/
38
- - run: tar -czf space-dist.tar.gz -C dist .
39
- - uses: softprops/action-gh-release@v2
40
- with:
41
- files: |
42
- space-dist.tar.gz
43
- dist/manifest.json
44
- generate_release_notes: true
@@ -1,44 +0,0 @@
1
- name: Build Space
2
-
3
- on:
4
- push:
5
- tags:
6
- - 'v*'
7
- pull_request:
8
- branches: [main]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v4
15
- - uses: oven-sh/setup-bun@v2
16
- with:
17
- bun-version: latest
18
- - run: bun install
19
- - run: bun run build
20
- - name: Upload artifacts
21
- if: startsWith(github.ref, 'refs/tags/v')
22
- uses: actions/upload-artifact@v4
23
- with:
24
- name: space-dist
25
- path: dist/
26
-
27
- release:
28
- needs: build
29
- if: startsWith(github.ref, 'refs/tags/v')
30
- runs-on: ubuntu-latest
31
- permissions:
32
- contents: write
33
- steps:
34
- - uses: actions/download-artifact@v4
35
- with:
36
- name: space-dist
37
- path: dist/
38
- - run: tar -czf space-dist.tar.gz -C dist .
39
- - uses: softprops/action-gh-release@v2
40
- with:
41
- files: |
42
- space-dist.tar.gz
43
- dist/manifest.json
44
- generate_release_notes: true