@starlein/paperclip-plugin-company-wizard 0.4.11 → 0.4.13

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/ui/index.js CHANGED
@@ -581,7 +581,7 @@ var __iconNode45 = [
581
581
  var Zap = createLucideIcon("zap", __iconNode45);
582
582
 
583
583
  // src/ui/components/WizardShell.tsx
584
- import { useEffect as useEffect8 } from "react";
584
+ import { useEffect as useEffect9 } from "react";
585
585
 
586
586
  // src/ui/context/WizardContext.tsx
587
587
  import { createContext, useCallback, useContext, useState } from "react";
@@ -4133,9 +4133,9 @@ function StepOnboarding() {
4133
4133
  title: "Update existing company",
4134
4134
  description: "Re-provision or modify an existing org",
4135
4135
  details: [
4136
- "Select company by ID",
4137
- "Choose preset, modules, and roles",
4138
- "Preview changes before applying",
4136
+ "Pick from your existing companies",
4137
+ "Re-sync instructions, docs, and routines",
4138
+ "Name, goals, and repository stay untouched",
4139
4139
  "Preserves individual skill assignments"
4140
4140
  ],
4141
4141
  onClick: () => dispatch({ type: "SET_PATH", path: "update" })
@@ -5662,6 +5662,7 @@ function FileEntry({
5662
5662
  function ConfigReview() {
5663
5663
  const state = useWizard();
5664
5664
  const dispatch = useWizardDispatch();
5665
+ const isUpdate = state.path === "update";
5665
5666
  const [editing, setEditing] = useState6(null);
5666
5667
  const [showDetails, setShowDetails] = useState6(false);
5667
5668
  const [showFiles, setShowFiles] = useState6(false);
@@ -5774,26 +5775,37 @@ function ConfigReview() {
5774
5775
  };
5775
5776
  return /* @__PURE__ */ jsxs8(Fragment3, { children: [
5776
5777
  /* @__PURE__ */ jsx14(Card, { children: /* @__PURE__ */ jsxs8(CardContent, { className: "divide-y p-0", children: [
5777
- /* @__PURE__ */ jsx14("div", { className: "px-4", children: /* @__PURE__ */ jsx14(SummaryRow, { icon: Building2, label: "Company", onEdit: () => setEditing("name"), children: editing === "name" ? /* @__PURE__ */ jsx14(
5778
- InlineEdit,
5778
+ /* @__PURE__ */ jsx14("div", { className: "px-4", children: /* @__PURE__ */ jsx14(
5779
+ SummaryRow,
5779
5780
  {
5780
- value: state.companyName,
5781
- onSave: (v) => {
5782
- dispatch({ type: "SET_COMPANY_NAME", value: v });
5783
- setEditing(null);
5784
- },
5785
- onCancel: () => setEditing(null),
5786
- placeholder: "Company name"
5781
+ icon: Building2,
5782
+ label: isUpdate ? "Company (updating)" : "Company",
5783
+ onEdit: isUpdate ? void 0 : () => setEditing("name"),
5784
+ children: !isUpdate && editing === "name" ? /* @__PURE__ */ jsx14(
5785
+ InlineEdit,
5786
+ {
5787
+ value: state.companyName,
5788
+ onSave: (v) => {
5789
+ dispatch({ type: "SET_COMPANY_NAME", value: v });
5790
+ setEditing(null);
5791
+ },
5792
+ onCancel: () => setEditing(null),
5793
+ placeholder: "Company name"
5794
+ }
5795
+ ) : isUpdate ? /* @__PURE__ */ jsxs8(Fragment3, { children: [
5796
+ /* @__PURE__ */ jsx14("span", { className: "font-medium", children: state.companyName || "(unnamed)" }),
5797
+ /* @__PURE__ */ jsx14("span", { className: "text-muted-foreground ml-2 font-mono text-xs", children: state.existingCompanyId })
5798
+ ] }) : /* @__PURE__ */ jsxs8(Fragment3, { children: [
5799
+ /* @__PURE__ */ jsx14("span", { className: "font-medium", children: state.companyName || "(unnamed)" }),
5800
+ /* @__PURE__ */ jsxs8("span", { className: "text-muted-foreground ml-2", children: [
5801
+ "\u2192 ",
5802
+ toPascalCase2(state.companyName || "Company"),
5803
+ "/"
5804
+ ] })
5805
+ ] })
5787
5806
  }
5788
- ) : /* @__PURE__ */ jsxs8(Fragment3, { children: [
5789
- /* @__PURE__ */ jsx14("span", { className: "font-medium", children: state.companyName || "(unnamed)" }),
5790
- /* @__PURE__ */ jsxs8("span", { className: "text-muted-foreground ml-2", children: [
5791
- "\u2192 ",
5792
- toPascalCase2(state.companyName || "Company"),
5793
- "/"
5794
- ] })
5795
- ] }) }) }),
5796
- /* @__PURE__ */ jsx14("div", { className: "px-4", children: /* @__PURE__ */ jsx14(
5807
+ ) }),
5808
+ !isUpdate && /* @__PURE__ */ jsx14("div", { className: "px-4", children: /* @__PURE__ */ jsx14(
5797
5809
  SummaryRow,
5798
5810
  {
5799
5811
  icon: ArrowUpRight,
@@ -5816,41 +5828,49 @@ function ConfigReview() {
5816
5828
  ] }) : /* @__PURE__ */ jsx14("span", { className: "text-muted-foreground", children: "Create a new company" })
5817
5829
  }
5818
5830
  ) }),
5819
- /* @__PURE__ */ jsx14("div", { className: "px-4", children: /* @__PURE__ */ jsx14(SummaryRow, { icon: GitBranch, label: "Repository", onEdit: () => setEditing("repository"), children: editing === "repository" ? /* @__PURE__ */ jsx14(
5820
- RepositoryEdit,
5821
- {
5822
- project: primaryProject ?? null,
5823
- onSave: (repo) => {
5824
- saveRepository(repo);
5825
- },
5826
- onCancel: () => setEditing(null)
5827
- }
5828
- ) : /* @__PURE__ */ jsx14(
5829
- "button",
5831
+ !isUpdate && /* @__PURE__ */ jsx14("div", { className: "px-4", children: /* @__PURE__ */ jsx14(
5832
+ SummaryRow,
5830
5833
  {
5831
- type: "button",
5832
- onClick: () => setEditing("repository"),
5833
- className: "group/repo w-full text-left rounded-md -mx-1 px-1 py-0.5 hover:bg-accent/50 transition-colors",
5834
- children: isExternalRepo ? /* @__PURE__ */ jsxs8(Fragment3, { children: [
5835
- /* @__PURE__ */ jsx14("span", { className: "font-medium", children: "External Git repository" }),
5836
- /* @__PURE__ */ jsx14("span", { className: "ml-2 text-xs text-muted-foreground underline decoration-dotted underline-offset-2 group-hover/repo:text-foreground", children: "Change" }),
5837
- primaryRepoUrl && /* @__PURE__ */ jsx14("p", { className: "text-xs text-muted-foreground mt-0.5 wrap-break-word", children: primaryRepoUrl }),
5838
- primaryRepoRef && /* @__PURE__ */ jsxs8("p", { className: "text-xs text-muted-foreground mt-0.5", children: [
5839
- "Ref: ",
5840
- primaryRepoRef
5841
- ] })
5842
- ] }) : /* @__PURE__ */ jsxs8(Fragment3, { children: [
5843
- /* @__PURE__ */ jsx14("span", { className: "font-medium", children: "Create a new Git repository" }),
5844
- /* @__PURE__ */ jsx14("span", { className: "ml-2 text-xs text-muted-foreground underline decoration-dotted underline-offset-2 group-hover/repo:text-foreground", children: "Change \u2014 use an existing repository" }),
5845
- /* @__PURE__ */ jsxs8("p", { className: "text-xs text-muted-foreground mt-0.5", children: [
5846
- "Fresh local workspace",
5847
- primaryRepoRef ? ` on ${primaryRepoRef}` : "",
5848
- primaryWorkspace?.setupCommand ? ` \xB7 ${primaryWorkspace.setupCommand}` : ""
5849
- ] })
5850
- ] })
5834
+ icon: GitBranch,
5835
+ label: "Repository",
5836
+ onEdit: () => setEditing("repository"),
5837
+ children: editing === "repository" ? /* @__PURE__ */ jsx14(
5838
+ RepositoryEdit,
5839
+ {
5840
+ project: primaryProject ?? null,
5841
+ onSave: (repo) => {
5842
+ saveRepository(repo);
5843
+ },
5844
+ onCancel: () => setEditing(null)
5845
+ }
5846
+ ) : /* @__PURE__ */ jsx14(
5847
+ "button",
5848
+ {
5849
+ type: "button",
5850
+ onClick: () => setEditing("repository"),
5851
+ className: "group/repo w-full text-left rounded-md -mx-1 px-1 py-0.5 hover:bg-accent/50 transition-colors",
5852
+ children: isExternalRepo ? /* @__PURE__ */ jsxs8(Fragment3, { children: [
5853
+ /* @__PURE__ */ jsx14("span", { className: "font-medium", children: "External Git repository" }),
5854
+ /* @__PURE__ */ jsx14("span", { className: "ml-2 text-xs text-muted-foreground underline decoration-dotted underline-offset-2 group-hover/repo:text-foreground", children: "Change" }),
5855
+ primaryRepoUrl && /* @__PURE__ */ jsx14("p", { className: "text-xs text-muted-foreground mt-0.5 wrap-break-word", children: primaryRepoUrl }),
5856
+ primaryRepoRef && /* @__PURE__ */ jsxs8("p", { className: "text-xs text-muted-foreground mt-0.5", children: [
5857
+ "Ref: ",
5858
+ primaryRepoRef
5859
+ ] })
5860
+ ] }) : /* @__PURE__ */ jsxs8(Fragment3, { children: [
5861
+ /* @__PURE__ */ jsx14("span", { className: "font-medium", children: "Create a new Git repository" }),
5862
+ /* @__PURE__ */ jsx14("span", { className: "ml-2 text-xs text-muted-foreground underline decoration-dotted underline-offset-2 group-hover/repo:text-foreground", children: "Change \u2014 use an existing repository" }),
5863
+ /* @__PURE__ */ jsxs8("p", { className: "text-xs text-muted-foreground mt-0.5", children: [
5864
+ "Fresh local workspace",
5865
+ primaryRepoRef ? ` on ${primaryRepoRef}` : "",
5866
+ primaryWorkspace?.setupCommand ? ` \xB7 ${primaryWorkspace.setupCommand}` : ""
5867
+ ] })
5868
+ ] })
5869
+ }
5870
+ )
5851
5871
  }
5852
- ) }) }),
5853
- /* @__PURE__ */ jsx14("div", { className: "px-4", children: /* @__PURE__ */ jsx14(SummaryRow, { icon: Target, label: "Goal", onEdit: () => setEditing("goal"), children: editing === "goal" ? /* @__PURE__ */ jsx14(
5872
+ ) }),
5873
+ !isUpdate && /* @__PURE__ */ jsx14("div", { className: "px-4", children: /* @__PURE__ */ jsx14(SummaryRow, { icon: Target, label: "Goal", onEdit: () => setEditing("goal"), children: editing === "goal" ? /* @__PURE__ */ jsx14(
5854
5874
  InlineEdit,
5855
5875
  {
5856
5876
  value: state.goals[0]?.title || "",
@@ -7287,12 +7307,43 @@ function StepPreview() {
7287
7307
  }
7288
7308
 
7289
7309
  // src/ui/components/steps/StepExistingCompany.tsx
7290
- import { useState as useState10 } from "react";
7310
+ import { useEffect as useEffect8, useRef as useRef7, useState as useState10 } from "react";
7311
+ import { usePluginAction as usePluginAction7 } from "@paperclipai/plugin-sdk/ui";
7291
7312
  import { jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
7292
7313
  function StepExistingCompany() {
7293
7314
  const state = useWizard();
7294
7315
  const dispatch = useWizardDispatch();
7316
+ const listCompanies = usePluginAction7("list-companies");
7317
+ const [companies, setCompanies] = useState10(null);
7318
+ const [loading, setLoading] = useState10(true);
7319
+ const [loadError, setLoadError] = useState10(null);
7320
+ const [manual, setManual] = useState10(false);
7295
7321
  const [touched, setTouched] = useState10(false);
7322
+ const requested = useRef7(false);
7323
+ const load = () => {
7324
+ setLoading(true);
7325
+ setLoadError(null);
7326
+ listCompanies({}).then((result) => {
7327
+ if (result?.error) {
7328
+ setLoadError(result.error);
7329
+ setCompanies(null);
7330
+ return;
7331
+ }
7332
+ setCompanies(Array.isArray(result?.companies) ? result.companies : []);
7333
+ }).catch((err) => {
7334
+ setLoadError(err?.message || "Could not load companies");
7335
+ setCompanies(null);
7336
+ }).finally(() => setLoading(false));
7337
+ };
7338
+ useEffect8(() => {
7339
+ if (requested.current) return;
7340
+ requested.current = true;
7341
+ load();
7342
+ }, []);
7343
+ const selectCompany = (company) => {
7344
+ dispatch({ type: "SET_EXISTING_COMPANY_ID", value: company.id });
7345
+ dispatch({ type: "SET_COMPANY_NAME", value: company.name || "" });
7346
+ };
7296
7347
  const isEmpty = !state.existingCompanyId.trim();
7297
7348
  const handleNext = () => {
7298
7349
  if (isEmpty) {
@@ -7304,9 +7355,81 @@ function StepExistingCompany() {
7304
7355
  return /* @__PURE__ */ jsxs13("div", { className: "space-y-6", children: [
7305
7356
  /* @__PURE__ */ jsxs13("div", { className: "space-y-2", children: [
7306
7357
  /* @__PURE__ */ jsx19("h2", { className: "text-xl font-semibold tracking-tight", children: "Update existing company" }),
7307
- /* @__PURE__ */ jsx19("p", { className: "text-sm text-muted-foreground", children: "Enter the ID of the company you want to update. This will load the existing configuration and allow you to modify modules, roles, and settings." })
7358
+ /* @__PURE__ */ jsx19("p", { className: "text-sm text-muted-foreground", children: "Pick the company you want to update. The wizard re-syncs its agent instructions, docs, modules, roles, and routines \u2014 the company name, goals, and repository stay untouched." })
7359
+ ] }),
7360
+ loading && /* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground", children: [
7361
+ /* @__PURE__ */ jsx19(LoaderCircle, { className: "h-4 w-4 animate-spin" }),
7362
+ "Loading your companies\u2026"
7363
+ ] }),
7364
+ !loading && loadError && !manual && /* @__PURE__ */ jsx19("div", { className: "space-y-3", children: /* @__PURE__ */ jsxs13("div", { className: "flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-4", children: [
7365
+ /* @__PURE__ */ jsx19(TriangleAlert, { className: "h-4 w-4 text-amber-500 shrink-0 mt-0.5" }),
7366
+ /* @__PURE__ */ jsxs13("div", { className: "space-y-2 flex-1 min-w-0", children: [
7367
+ /* @__PURE__ */ jsx19("p", { className: "text-sm font-medium text-amber-800 dark:text-amber-200", children: "Could not load companies" }),
7368
+ /* @__PURE__ */ jsx19("p", { className: "text-xs text-amber-700 dark:text-amber-300 wrap-break-word", children: loadError }),
7369
+ /* @__PURE__ */ jsxs13("div", { className: "flex gap-2", children: [
7370
+ /* @__PURE__ */ jsxs13(Button, { variant: "outline", size: "sm", className: "text-xs", onClick: load, children: [
7371
+ /* @__PURE__ */ jsx19(RefreshCw, { className: "h-3 w-3 mr-1.5" }),
7372
+ "Retry"
7373
+ ] }),
7374
+ /* @__PURE__ */ jsx19(
7375
+ Button,
7376
+ {
7377
+ variant: "ghost",
7378
+ size: "sm",
7379
+ className: "text-xs",
7380
+ onClick: () => setManual(true),
7381
+ children: "Enter ID manually"
7382
+ }
7383
+ )
7384
+ ] })
7385
+ ] })
7386
+ ] }) }),
7387
+ !loading && !manual && companies && /* @__PURE__ */ jsxs13("div", { className: "space-y-3", children: [
7388
+ companies.length === 0 ? /* @__PURE__ */ jsxs13("div", { className: "rounded-lg border border-dashed p-6 text-center text-sm text-muted-foreground", children: [
7389
+ "No companies found on this instance.",
7390
+ /* @__PURE__ */ jsx19(
7391
+ "button",
7392
+ {
7393
+ type: "button",
7394
+ onClick: () => setManual(true),
7395
+ className: "ml-1 underline decoration-dotted underline-offset-2 hover:text-foreground",
7396
+ children: "Enter an ID manually"
7397
+ }
7398
+ )
7399
+ ] }) : /* @__PURE__ */ jsx19("div", { className: "space-y-2 max-h-[360px] overflow-y-auto pr-1", children: companies.map((company) => {
7400
+ const selected = state.existingCompanyId === company.id;
7401
+ return /* @__PURE__ */ jsxs13(
7402
+ "button",
7403
+ {
7404
+ type: "button",
7405
+ onClick: () => selectCompany(company),
7406
+ className: cn(
7407
+ "w-full flex items-start gap-3 rounded-lg border p-3 text-left transition-colors",
7408
+ selected ? "border-foreground/30 bg-accent" : "border-border hover:border-foreground/20 hover:bg-accent/50"
7409
+ ),
7410
+ children: [
7411
+ /* @__PURE__ */ jsx19("div", { className: "h-8 w-8 rounded-md bg-secondary flex items-center justify-center shrink-0", children: /* @__PURE__ */ jsx19(Building2, { className: "h-4 w-4" }) }),
7412
+ /* @__PURE__ */ jsxs13("div", { className: "flex-1 min-w-0", children: [
7413
+ /* @__PURE__ */ jsx19("p", { className: "text-sm font-medium truncate", children: company.name || "(unnamed)" }),
7414
+ company.description ? /* @__PURE__ */ jsx19("p", { className: "text-xs text-muted-foreground line-clamp-2", children: company.description }) : /* @__PURE__ */ jsx19("p", { className: "text-xs text-muted-foreground font-mono truncate", children: company.id })
7415
+ ] }),
7416
+ selected && /* @__PURE__ */ jsx19(Check, { className: "h-4 w-4 text-foreground shrink-0 mt-0.5" })
7417
+ ]
7418
+ },
7419
+ company.id
7420
+ );
7421
+ }) }),
7422
+ companies.length > 0 && /* @__PURE__ */ jsx19(
7423
+ "button",
7424
+ {
7425
+ type: "button",
7426
+ onClick: () => setManual(true),
7427
+ className: "text-xs text-muted-foreground hover:text-foreground underline decoration-dotted underline-offset-2",
7428
+ children: "Company not listed? Enter an ID manually"
7429
+ }
7430
+ )
7308
7431
  ] }),
7309
- /* @__PURE__ */ jsxs13("div", { className: "space-y-3", children: [
7432
+ !loading && manual && /* @__PURE__ */ jsxs13("div", { className: "space-y-3", children: [
7310
7433
  /* @__PURE__ */ jsx19(
7311
7434
  Input,
7312
7435
  {
@@ -7315,10 +7438,19 @@ function StepExistingCompany() {
7315
7438
  onChange: (e) => dispatch({ type: "SET_EXISTING_COMPANY_ID", value: e.target.value }),
7316
7439
  onKeyDown: (e) => e.key === "Enter" && handleNext(),
7317
7440
  autoFocus: true,
7318
- className: "text-base h-11"
7441
+ className: "text-base h-11 font-mono"
7319
7442
  }
7320
7443
  ),
7321
- touched && isEmpty && /* @__PURE__ */ jsx19("p", { className: "text-sm text-destructive", children: "Please enter a company ID." })
7444
+ touched && isEmpty && /* @__PURE__ */ jsx19("p", { className: "text-sm text-destructive", children: "Please enter a company ID." }),
7445
+ companies && companies.length > 0 && /* @__PURE__ */ jsx19(
7446
+ "button",
7447
+ {
7448
+ type: "button",
7449
+ onClick: () => setManual(false),
7450
+ className: "text-xs text-muted-foreground hover:text-foreground underline decoration-dotted underline-offset-2",
7451
+ children: "Back to the company list"
7452
+ }
7453
+ )
7322
7454
  ] }),
7323
7455
  /* @__PURE__ */ jsxs13("div", { className: "flex justify-end gap-3", children: [
7324
7456
  /* @__PURE__ */ jsx19(Button, { variant: "outline", onClick: () => dispatch({ type: "GO_TO", step: "onboarding" }), children: "Back" }),
@@ -7448,7 +7580,7 @@ function WizardShell() {
7448
7580
  const state = useWizard();
7449
7581
  const dispatch = useWizardDispatch();
7450
7582
  const StepComponent = STEP_COMPONENTS[state.step];
7451
- useEffect8(() => {
7583
+ useEffect9(() => {
7452
7584
  window.scrollTo({ top: 0 });
7453
7585
  }, [state.step]);
7454
7586
  return /* @__PURE__ */ jsxs15("div", { className: "flex flex-col", children: [