@insforge/cli 0.1.38 → 0.1.40

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
@@ -456,6 +456,21 @@ async function getProjectApiKey(projectId, apiUrl) {
456
456
  const data = await res.json();
457
457
  return data.access_api_key;
458
458
  }
459
+ async function reportAgentConnected(payload, apiUrl) {
460
+ const baseUrl = getPlatformApiUrl(apiUrl);
461
+ const headers = {
462
+ "Content-Type": "application/json"
463
+ };
464
+ const token = getAccessToken();
465
+ if (token) {
466
+ headers.Authorization = `Bearer ${token}`;
467
+ }
468
+ await fetch(`${baseUrl}/tracking/v1/agent-connected`, {
469
+ method: "POST",
470
+ headers,
471
+ body: JSON.stringify(payload)
472
+ });
473
+ }
459
474
  async function createProject(orgId, name, region, apiUrl) {
460
475
  const body = { name };
461
476
  if (region) body.region = region;
@@ -720,13 +735,13 @@ ${missing.join("\n")}
720
735
  async function installSkills(json) {
721
736
  try {
722
737
  if (!json) clack5.log.info("Installing InsForge agent skills...");
723
- await execAsync("npx skills add insforge/agent-skills -y -s insforge -s insforge-cli -a antigravity -a augment -a claude-code -a cline -a codex -a cursor -a gemini-cli -a github-copilot -a kilo -a qoder -a qwen-code -a roo -a trae -a windsurf", {
738
+ await execAsync("npx skills add insforge/agent-skills -y -a antigravity -a augment -a claude-code -a cline -a codex -a cursor -a gemini-cli -a github-copilot -a kilo -a qoder -a qwen-code -a roo -a trae -a windsurf", {
724
739
  cwd: process.cwd(),
725
740
  timeout: 6e4
726
741
  });
727
742
  if (!json) clack5.log.success("InsForge agent skills installed.");
728
743
  } catch {
729
- if (!json) clack5.log.warn("Failed to install agent skills. You can run manually: npx skills add insforge/agent-skills -s insforge -s insforge-cli");
744
+ if (!json) clack5.log.warn("Failed to install agent skills. You can run manually: npx skills add insforge/agent-skills");
730
745
  }
731
746
  try {
732
747
  if (!json) clack5.log.info("Installing find-skills...");
@@ -818,6 +833,13 @@ function registerProjectLinkCommand(program2) {
818
833
  }
819
834
  await installSkills(json);
820
835
  await reportCliUsage("cli.link_direct", true, 6);
836
+ try {
837
+ const urlMatch = opts.apiBaseUrl.match(/^https?:\/\/([^.]+)\.[^.]+\.insforge\.app/);
838
+ if (urlMatch) {
839
+ await reportAgentConnected({ app_key: urlMatch[1] }, apiUrl);
840
+ }
841
+ } catch {
842
+ }
821
843
  return;
822
844
  } catch (err) {
823
845
  await reportCliUsage("cli.link_direct", false);
@@ -901,6 +923,10 @@ function registerProjectLinkCommand(program2) {
901
923
  }
902
924
  await installSkills(json);
903
925
  await reportCliUsage("cli.link", true, 6);
926
+ try {
927
+ await reportAgentConnected({ project_id: project.id }, apiUrl);
928
+ } catch {
929
+ }
904
930
  } catch (err) {
905
931
  await reportCliUsage("cli.link", false);
906
932
  handleError(err, json);
@@ -2019,6 +2045,10 @@ function registerDeploymentsDeployCommand(deploymentsCmd2) {
2019
2045
  if (!stats?.isDirectory()) {
2020
2046
  throw new CLIError(`"${sourceDir}" is not a valid directory.`);
2021
2047
  }
2048
+ const dirName = path2.basename(sourceDir);
2049
+ if (EXCLUDE_PATTERNS.includes(dirName)) {
2050
+ throw new CLIError(`"${dirName}" is an excluded directory and cannot be used as a deploy source. Please specify your project root or output directory instead.`);
2051
+ }
2022
2052
  const s = !json ? clack9.spinner() : null;
2023
2053
  const startBody = {};
2024
2054
  if (opts.env) {
@@ -2713,6 +2743,83 @@ function registerDeploymentsCancelCommand(deploymentsCmd2) {
2713
2743
  });
2714
2744
  }
2715
2745
 
2746
+ // src/commands/deployments/env-vars.ts
2747
+ function registerDeploymentsEnvVarsCommand(deploymentsCmd2) {
2748
+ const envCmd = deploymentsCmd2.command("env").description("Manage deployment environment variables");
2749
+ envCmd.command("list").description("List all deployment environment variables").action(async (_opts, cmd) => {
2750
+ const { json } = getRootOpts(cmd);
2751
+ try {
2752
+ await requireAuth();
2753
+ if (!getProjectConfig()) throw new ProjectNotLinkedError();
2754
+ const res = await ossFetch("/api/deployments/env-vars");
2755
+ const data = await res.json();
2756
+ const envVars = data.envVars ?? [];
2757
+ if (json) {
2758
+ outputJson(data);
2759
+ } else {
2760
+ if (!envVars.length) {
2761
+ console.log("No environment variables found.");
2762
+ return;
2763
+ }
2764
+ outputTable(
2765
+ ["ID", "Key", "Type", "Updated At"],
2766
+ envVars.map((v) => [
2767
+ v.id,
2768
+ v.key,
2769
+ v.type,
2770
+ new Date(v.updatedAt).toLocaleString()
2771
+ ])
2772
+ );
2773
+ }
2774
+ await reportCliUsage("cli.deployments.env.list", true);
2775
+ } catch (err) {
2776
+ await reportCliUsage("cli.deployments.env.list", false);
2777
+ handleError(err, json);
2778
+ }
2779
+ });
2780
+ envCmd.command("set <key> <value>").description("Create or update a deployment environment variable").action(async (key, value, _opts, cmd) => {
2781
+ const { json } = getRootOpts(cmd);
2782
+ try {
2783
+ await requireAuth();
2784
+ if (!getProjectConfig()) throw new ProjectNotLinkedError();
2785
+ const res = await ossFetch("/api/deployments/env-vars", {
2786
+ method: "POST",
2787
+ body: JSON.stringify({ envVars: [{ key, value }] })
2788
+ });
2789
+ const data = await res.json();
2790
+ if (json) {
2791
+ outputJson(data);
2792
+ } else {
2793
+ outputSuccess(data.message);
2794
+ }
2795
+ await reportCliUsage("cli.deployments.env.set", true);
2796
+ } catch (err) {
2797
+ await reportCliUsage("cli.deployments.env.set", false);
2798
+ handleError(err, json);
2799
+ }
2800
+ });
2801
+ envCmd.command("delete <id>").description("Delete a deployment environment variable by ID").action(async (id, _opts, cmd) => {
2802
+ const { json } = getRootOpts(cmd);
2803
+ try {
2804
+ await requireAuth();
2805
+ if (!getProjectConfig()) throw new ProjectNotLinkedError();
2806
+ const res = await ossFetch(`/api/deployments/env-vars/${encodeURIComponent(id)}`, {
2807
+ method: "DELETE"
2808
+ });
2809
+ const data = await res.json();
2810
+ if (json) {
2811
+ outputJson(data);
2812
+ } else {
2813
+ outputSuccess(data.message);
2814
+ }
2815
+ await reportCliUsage("cli.deployments.env.delete", true);
2816
+ } catch (err) {
2817
+ await reportCliUsage("cli.deployments.env.delete", false);
2818
+ handleError(err, json);
2819
+ }
2820
+ });
2821
+ }
2822
+
2716
2823
  // src/commands/docs.ts
2717
2824
  var FEATURES = ["db", "storage", "functions", "auth", "ai", "realtime"];
2718
2825
  var LANGUAGES = ["typescript", "swift", "kotlin", "rest-api"];
@@ -3155,10 +3262,18 @@ function registerSchedulesLogsCommand(schedulesCmd2) {
3155
3262
  }
3156
3263
 
3157
3264
  // src/commands/logs.ts
3158
- var VALID_SOURCES = ["insforge.logs", "postgREST.logs", "postgres.logs", "function.logs"];
3265
+ var VALID_SOURCES = ["insforge.logs", "postgREST.logs", "postgres.logs", "function.logs", "function-deploy.logs"];
3159
3266
  var SOURCE_LOOKUP = new Map(VALID_SOURCES.map((s) => [s.toLowerCase(), s]));
3267
+ var SOURCE_PATH = {
3268
+ "function-deploy.logs": "/api/logs/functions/build-logs"
3269
+ };
3270
+ function getLogPath(source, limit) {
3271
+ const custom = SOURCE_PATH[source];
3272
+ if (custom) return `${custom}?limit=${limit}`;
3273
+ return `/api/logs/${encodeURIComponent(source)}?limit=${limit}`;
3274
+ }
3160
3275
  function registerLogsCommand(program2) {
3161
- program2.command("logs <source>").description("Fetch backend container logs (insforge.logs | postgREST.logs | postgres.logs | function.logs)").option("--limit <n>", "Number of log entries to return", "20").action(async (source, opts, cmd) => {
3276
+ program2.command("logs <source>").description("Fetch backend container logs (insforge.logs | postgREST.logs | postgres.logs | function.logs | function-deploy.logs)").option("--limit <n>", "Number of log entries to return", "20").action(async (source, opts, cmd) => {
3162
3277
  const { json } = getRootOpts(cmd);
3163
3278
  try {
3164
3279
  await requireAuth();
@@ -3167,7 +3282,7 @@ function registerLogsCommand(program2) {
3167
3282
  throw new CLIError(`Invalid log source "${source}". Valid sources: ${VALID_SOURCES.join(", ")}`);
3168
3283
  }
3169
3284
  const limit = parseInt(opts.limit, 10) || 20;
3170
- const res = await ossFetch(`/api/logs/${encodeURIComponent(resolved)}?limit=${limit}`);
3285
+ const res = await ossFetch(getLogPath(resolved, limit));
3171
3286
  const data = await res.json();
3172
3287
  if (json) {
3173
3288
  outputJson(data);
@@ -3644,8 +3759,11 @@ function registerDiagnoseDbCommand(diagnoseCmd2) {
3644
3759
  }
3645
3760
 
3646
3761
  // src/commands/diagnose/logs.ts
3647
- var LOG_SOURCES = ["insforge.logs", "postgREST.logs", "postgres.logs", "function.logs"];
3762
+ var LOG_SOURCES = ["insforge.logs", "postgREST.logs", "postgres.logs", "function.logs", "function-deploy.logs"];
3648
3763
  var ERROR_PATTERN = /\b(error|fatal|panic)\b/i;
3764
+ var SOURCE_PATH2 = {
3765
+ "function-deploy.logs": "/api/logs/functions/build-logs"
3766
+ };
3649
3767
  function parseLogEntry(entry) {
3650
3768
  if (typeof entry === "string") {
3651
3769
  return { ts: "", msg: entry };
@@ -3655,8 +3773,13 @@ function parseLogEntry(entry) {
3655
3773
  const msg = String(e.message ?? e.msg ?? e.log ?? JSON.stringify(e));
3656
3774
  return { ts, msg };
3657
3775
  }
3776
+ function getLogPath2(source, limit) {
3777
+ const custom = SOURCE_PATH2[source];
3778
+ if (custom) return `${custom}?limit=${limit}`;
3779
+ return `/api/logs/${encodeURIComponent(source)}?limit=${limit}`;
3780
+ }
3658
3781
  async function fetchSourceLogs(source, limit) {
3659
- const res = await ossFetch(`/api/logs/${encodeURIComponent(source)}?limit=${limit}`);
3782
+ const res = await ossFetch(getLogPath2(source, limit));
3660
3783
  const data = await res.json();
3661
3784
  const logs = Array.isArray(data) ? data : data.logs ?? [];
3662
3785
  const errors = [];
@@ -3926,6 +4049,7 @@ registerDeploymentsDeployCommand(deploymentsCmd);
3926
4049
  registerDeploymentsListCommand(deploymentsCmd);
3927
4050
  registerDeploymentsStatusCommand(deploymentsCmd);
3928
4051
  registerDeploymentsCancelCommand(deploymentsCmd);
4052
+ registerDeploymentsEnvVarsCommand(deploymentsCmd);
3929
4053
  var secretsCmd = program.command("secrets").description("Manage secrets");
3930
4054
  registerSecretsListCommand(secretsCmd);
3931
4055
  registerSecretsGetCommand(secretsCmd);