@codebyplan/cli 3.4.0 → 3.5.0

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.
Files changed (2) hide show
  1. package/dist/cli.js +764 -243
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -37,7 +37,7 @@ var VERSION, PACKAGE_NAME;
37
37
  var init_version = __esm({
38
38
  "src/lib/version.ts"() {
39
39
  "use strict";
40
- VERSION = "3.4.0";
40
+ VERSION = "3.5.0";
41
41
  PACKAGE_NAME = "@codebyplan/cli";
42
42
  }
43
43
  });
@@ -1396,7 +1396,10 @@ async function discoverMonorepoApps(projectPath) {
1396
1396
  const apps = [];
1397
1397
  const patterns = [];
1398
1398
  try {
1399
- const raw = await readFile6(join6(projectPath, "pnpm-workspace.yaml"), "utf-8");
1399
+ const raw = await readFile6(
1400
+ join6(projectPath, "pnpm-workspace.yaml"),
1401
+ "utf-8"
1402
+ );
1400
1403
  const matches = raw.match(/^\s*-\s*['"]?([^'"#\n]+)['"]?/gm);
1401
1404
  if (matches) {
1402
1405
  for (const m of matches) {
@@ -1455,7 +1458,10 @@ async function detectFromDirectory(dirPath) {
1455
1458
  if (depName.startsWith(prefix)) {
1456
1459
  const key = prefixRule.name.toLowerCase();
1457
1460
  if (!seen.has(key)) {
1458
- seen.set(key, { name: prefixRule.name, category: prefixRule.category });
1461
+ seen.set(key, {
1462
+ name: prefixRule.name,
1463
+ category: prefixRule.category
1464
+ });
1459
1465
  }
1460
1466
  break;
1461
1467
  }
@@ -1708,26 +1714,50 @@ var init_tech_detect = __esm({
1708
1714
  expo: { name: "Expo", category: "mobile" }
1709
1715
  };
1710
1716
  PACKAGE_PREFIX_MAP = [
1711
- { prefix: "@radix-ui/", rule: { name: "Radix UI", category: "component-lib" } },
1717
+ {
1718
+ prefix: "@radix-ui/",
1719
+ rule: { name: "Radix UI", category: "component-lib" }
1720
+ },
1712
1721
  { prefix: "@storybook/", rule: { name: "Storybook", category: "tool" } },
1713
- { prefix: "@testing-library/", rule: { name: "Testing Library", category: "testing" } }
1722
+ {
1723
+ prefix: "@testing-library/",
1724
+ rule: { name: "Testing Library", category: "testing" }
1725
+ }
1714
1726
  ];
1715
1727
  CONFIG_FILE_MAP = [
1716
1728
  { file: "tsconfig.json", rule: { name: "TypeScript", category: "language" } },
1717
1729
  { file: "next.config.js", rule: { name: "Next.js", category: "framework" } },
1718
1730
  { file: "next.config.mjs", rule: { name: "Next.js", category: "framework" } },
1719
1731
  { file: "next.config.ts", rule: { name: "Next.js", category: "framework" } },
1720
- { file: "tailwind.config.js", rule: { name: "Tailwind CSS", category: "styling" } },
1721
- { file: "tailwind.config.ts", rule: { name: "Tailwind CSS", category: "styling" } },
1732
+ {
1733
+ file: "tailwind.config.js",
1734
+ rule: { name: "Tailwind CSS", category: "styling" }
1735
+ },
1736
+ {
1737
+ file: "tailwind.config.ts",
1738
+ rule: { name: "Tailwind CSS", category: "styling" }
1739
+ },
1722
1740
  { file: "turbo.json", rule: { name: "Turborepo", category: "build" } },
1723
- { file: "docker-compose.yml", rule: { name: "Docker", category: "deployment" } },
1724
- { file: "docker-compose.yaml", rule: { name: "Docker", category: "deployment" } },
1741
+ {
1742
+ file: "docker-compose.yml",
1743
+ rule: { name: "Docker", category: "deployment" }
1744
+ },
1745
+ {
1746
+ file: "docker-compose.yaml",
1747
+ rule: { name: "Docker", category: "deployment" }
1748
+ },
1725
1749
  { file: "Dockerfile", rule: { name: "Docker", category: "deployment" } },
1726
1750
  { file: "vercel.json", rule: { name: "Vercel", category: "deployment" } },
1727
1751
  { file: ".storybook/main.js", rule: { name: "Storybook", category: "tool" } },
1728
1752
  { file: ".storybook/main.ts", rule: { name: "Storybook", category: "tool" } },
1729
- { file: ".storybook/main.mjs", rule: { name: "Storybook", category: "tool" } },
1730
- { file: "components.json", rule: { name: "shadcn/ui", category: "component-lib" } },
1753
+ {
1754
+ file: ".storybook/main.mjs",
1755
+ rule: { name: "Storybook", category: "tool" }
1756
+ },
1757
+ {
1758
+ file: "components.json",
1759
+ rule: { name: "shadcn/ui", category: "component-lib" }
1760
+ },
1731
1761
  { file: "nx.json", rule: { name: "Nx", category: "build" } },
1732
1762
  { file: "lerna.json", rule: { name: "Lerna", category: "build" } }
1733
1763
  ];
@@ -1746,13 +1776,117 @@ var init_tech_detect = __esm({
1746
1776
  }
1747
1777
  });
1748
1778
 
1779
+ // src/lib/server-detect.ts
1780
+ function detectFramework(pkg) {
1781
+ const deps = pkg.dependencies ?? {};
1782
+ const devDeps = pkg.devDependencies ?? {};
1783
+ const hasDep = (name) => name in deps || name in devDeps;
1784
+ if (hasDep("next")) return "nextjs";
1785
+ if (hasDep("@tauri-apps/api") || hasDep("@tauri-apps/cli")) return "tauri";
1786
+ if (hasDep("expo")) return "expo";
1787
+ if (hasDep("vite")) return "vite";
1788
+ if (hasDep("express")) return "express";
1789
+ if (hasDep("@nestjs/core")) return "nestjs";
1790
+ return "custom";
1791
+ }
1792
+ function detectPortFromScripts(pkg) {
1793
+ const scripts = pkg.scripts;
1794
+ if (!scripts?.dev) return null;
1795
+ const parts = scripts.dev.split(/\s+/);
1796
+ for (let i = 0; i < parts.length - 1; i++) {
1797
+ if (parts[i] === "--port" || parts[i] === "-p") {
1798
+ const next = parts[i + 1];
1799
+ if (next) {
1800
+ const port = parseInt(next, 10);
1801
+ if (!isNaN(port)) return port;
1802
+ }
1803
+ }
1804
+ }
1805
+ return null;
1806
+ }
1807
+ var init_server_detect = __esm({
1808
+ "src/lib/server-detect.ts"() {
1809
+ "use strict";
1810
+ }
1811
+ });
1812
+
1813
+ // src/lib/port-verify.ts
1814
+ import { readFile as readFile7 } from "node:fs/promises";
1815
+ async function verifyPorts(projectPath, portAllocations) {
1816
+ const mismatches = [];
1817
+ const allocatedPorts = new Set(portAllocations.map((a) => a.port));
1818
+ const packageJsonPaths = await findPackageJsonFiles(projectPath, projectPath);
1819
+ for (const pkgPath of packageJsonPaths) {
1820
+ try {
1821
+ const raw = await readFile7(pkgPath, "utf-8");
1822
+ const pkg = JSON.parse(raw);
1823
+ const scriptPort = detectPortFromScripts(pkg);
1824
+ if (scriptPort !== null && !allocatedPorts.has(scriptPort)) {
1825
+ const relativePath = pkgPath.replace(projectPath + "/", "");
1826
+ const matchingAlloc = portAllocations.find(
1827
+ (a) => a.label === getAppLabel(relativePath)
1828
+ );
1829
+ mismatches.push({
1830
+ packageJsonPath: relativePath,
1831
+ scriptPort,
1832
+ allocation: matchingAlloc ?? null,
1833
+ reason: matchingAlloc ? `Script uses port ${scriptPort} but allocation has port ${matchingAlloc.port}` : `Port ${scriptPort} in scripts is not in any allocation`
1834
+ });
1835
+ }
1836
+ } catch {
1837
+ }
1838
+ }
1839
+ return mismatches;
1840
+ }
1841
+ async function findUnallocatedApps(projectPath, portAllocations) {
1842
+ const apps = await discoverMonorepoApps(projectPath);
1843
+ if (apps.length === 0) {
1844
+ return [];
1845
+ }
1846
+ const allocatedLabels = new Set(portAllocations.map((a) => a.label));
1847
+ const unallocated = [];
1848
+ for (const app of apps) {
1849
+ if (allocatedLabels.has(app.name)) continue;
1850
+ try {
1851
+ const raw = await readFile7(`${app.absPath}/package.json`, "utf-8");
1852
+ const pkg = JSON.parse(raw);
1853
+ const framework = detectFramework(pkg);
1854
+ const detectedPort = detectPortFromScripts(pkg);
1855
+ const command = `pnpm --filter ${app.name} dev`;
1856
+ unallocated.push({
1857
+ name: app.name,
1858
+ path: app.path,
1859
+ framework,
1860
+ detectedPort,
1861
+ command
1862
+ });
1863
+ } catch {
1864
+ }
1865
+ }
1866
+ return unallocated;
1867
+ }
1868
+ function getAppLabel(relativePath) {
1869
+ const parts = relativePath.split("/");
1870
+ if (parts.length >= 3 && parts[0] === "apps") {
1871
+ return parts[1];
1872
+ }
1873
+ return "root";
1874
+ }
1875
+ var init_port_verify = __esm({
1876
+ "src/lib/port-verify.ts"() {
1877
+ "use strict";
1878
+ init_tech_detect();
1879
+ init_server_detect();
1880
+ }
1881
+ });
1882
+
1749
1883
  // src/cli/sync.ts
1750
1884
  var sync_exports = {};
1751
1885
  __export(sync_exports, {
1752
1886
  runSync: () => runSync
1753
1887
  });
1754
1888
  import { createHash } from "node:crypto";
1755
- import { readFile as readFile7, writeFile as writeFile3, mkdir as mkdir2, chmod as chmod2, unlink as unlink2 } from "node:fs/promises";
1889
+ import { readFile as readFile8, writeFile as writeFile3, mkdir as mkdir2, chmod as chmod2, unlink as unlink2 } from "node:fs/promises";
1756
1890
  import { join as join7, dirname as dirname2 } from "node:path";
1757
1891
  function contentHash(content) {
1758
1892
  return createHash("sha256").update(content).digest("hex");
@@ -1761,6 +1895,7 @@ async function runSync() {
1761
1895
  const flags = parseFlags(3);
1762
1896
  const dryRun = hasFlag("dry-run", 3);
1763
1897
  const force = hasFlag("force", 3);
1898
+ const fix = hasFlag("fix", 3);
1764
1899
  validateApiKey();
1765
1900
  const config2 = await resolveConfig(flags);
1766
1901
  const { repoId, projectPath } = config2;
@@ -1785,7 +1920,9 @@ async function runSync() {
1785
1920
  const lockStatus = await apiGet("/sync/lock", { repo_id: repoId });
1786
1921
  if (lockStatus.data.locked && lockStatus.data.lock) {
1787
1922
  const lock = lockStatus.data.lock;
1788
- console.log(` Sync locked by ${lock.locked_by} since ${lock.locked_at}.`);
1923
+ console.log(
1924
+ ` Sync locked by ${lock.locked_by} since ${lock.locked_at}.`
1925
+ );
1789
1926
  console.log(` Expires: ${lock.expires_at}`);
1790
1927
  console.log(` Use --force to override, or wait for lock to expire.
1791
1928
  `);
@@ -1803,7 +1940,7 @@ async function runSync() {
1803
1940
  }
1804
1941
  }
1805
1942
  try {
1806
- await runSyncInner(repoId, projectPath, dryRun, force);
1943
+ await runSyncInner(repoId, projectPath, dryRun, force, fix);
1807
1944
  } finally {
1808
1945
  if (!dryRun) {
1809
1946
  try {
@@ -1813,7 +1950,7 @@ async function runSync() {
1813
1950
  }
1814
1951
  }
1815
1952
  }
1816
- async function runSyncInner(repoId, projectPath, dryRun, force) {
1953
+ async function runSyncInner(repoId, projectPath, dryRun, force, fix = false) {
1817
1954
  console.log(" Reading local and remote state...");
1818
1955
  const claudeDir = join7(projectPath, ".claude");
1819
1956
  let localFiles = /* @__PURE__ */ new Map();
@@ -1825,8 +1962,12 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
1825
1962
  apiGet("/sync/defaults"),
1826
1963
  apiGet("/sync/files", { repo_id: repoId }),
1827
1964
  apiGet(`/repos/${repoId}`),
1828
- apiGet("/sync/state", { repo_id: repoId }),
1829
- apiGet("/sync/file-repos", { repo_id: repoId })
1965
+ apiGet("/sync/state", {
1966
+ repo_id: repoId
1967
+ }),
1968
+ apiGet("/sync/file-repos", {
1969
+ repo_id: repoId
1970
+ })
1830
1971
  ]);
1831
1972
  const syncStartTime = Date.now();
1832
1973
  const repoData = repoRes.data;
@@ -1837,14 +1978,23 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
1837
1978
  const fileRepoByClaudeFileId = /* @__PURE__ */ new Map();
1838
1979
  for (const entry of fileReposRes.data ?? []) {
1839
1980
  if (entry.claude_files) {
1840
- const key = compositeKey(entry.claude_files.type, entry.claude_files.name, entry.claude_files.category);
1981
+ const key = compositeKey(
1982
+ entry.claude_files.type,
1983
+ entry.claude_files.name,
1984
+ entry.claude_files.category
1985
+ );
1841
1986
  fileRepoHashes.set(key, entry.last_synced_content_hash);
1842
1987
  }
1843
- fileRepoByClaudeFileId.set(entry.claude_file_id, entry.last_synced_content_hash);
1988
+ fileRepoByClaudeFileId.set(
1989
+ entry.claude_file_id,
1990
+ entry.last_synced_content_hash
1991
+ );
1844
1992
  }
1845
1993
  const remoteFiles = new Map([...remoteDefaults, ...remoteRepoFiles]);
1846
- console.log(` Local: ${localFiles.size} files, Remote: ${remoteFiles.size} files
1847
- `);
1994
+ console.log(
1995
+ ` Local: ${localFiles.size} files, Remote: ${remoteFiles.size} files
1996
+ `
1997
+ );
1848
1998
  const plan = [];
1849
1999
  const allKeys = /* @__PURE__ */ new Set([...localFiles.keys(), ...remoteFiles.keys()]);
1850
2000
  for (const key of allKeys) {
@@ -1859,7 +2009,11 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
1859
2009
  localContent: local.content,
1860
2010
  remoteContent: null,
1861
2011
  pushContent: reverseSubstituteVariables(local.content, repoData),
1862
- filePath: getLocalFilePath(claudeDir, projectPath, { type: local.type, name: local.name, category: local.category }),
2012
+ filePath: getLocalFilePath(claudeDir, projectPath, {
2013
+ type: local.type,
2014
+ name: local.name,
2015
+ category: local.category
2016
+ }),
1863
2017
  type: local.type,
1864
2018
  name: local.name,
1865
2019
  category: local.category,
@@ -1930,8 +2084,12 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
1930
2084
  const pushes = plan.filter((p) => p.action === "push");
1931
2085
  const conflicts = plan.filter((p) => p.action === "conflict");
1932
2086
  const contentPulls = pulls.filter((p) => p.localContent !== null);
1933
- const dbOnlyPull = plan.filter((p) => p.localContent === null && p.action === "pull");
1934
- const dbOnlyDelete = plan.filter((p) => p.localContent === null && p.action === "delete");
2087
+ const dbOnlyPull = plan.filter(
2088
+ (p) => p.localContent === null && p.action === "pull"
2089
+ );
2090
+ const dbOnlyDelete = plan.filter(
2091
+ (p) => p.localContent === null && p.action === "delete"
2092
+ );
1935
2093
  if (contentPulls.length > 0) {
1936
2094
  console.log(` Pull (DB \u2192 local): ${contentPulls.length}`);
1937
2095
  for (const p of contentPulls) console.log(` \u2193 ${p.displayPath}`);
@@ -1946,8 +2104,10 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
1946
2104
  for (const p of dbOnlyPull) console.log(` \u2193 ${p.displayPath}`);
1947
2105
  }
1948
2106
  if (dbOnlyDelete.length > 0) {
1949
- console.log(`
1950
- DB-only (previously synced, will delete): ${dbOnlyDelete.length}`);
2107
+ console.log(
2108
+ `
2109
+ DB-only (previously synced, will delete): ${dbOnlyDelete.length}`
2110
+ );
1951
2111
  for (const p of dbOnlyDelete) console.log(` \u2715 ${p.displayPath}`);
1952
2112
  }
1953
2113
  if (conflicts.length > 0) {
@@ -2064,8 +2224,10 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
2064
2224
  }
2065
2225
  }
2066
2226
  if (stored > 0) {
2067
- console.log(`
2068
- ${stored} conflict(s) stored in DB for later resolution.`);
2227
+ console.log(
2228
+ `
2229
+ ${stored} conflict(s) stored in DB for later resolution.`
2230
+ );
2069
2231
  }
2070
2232
  }
2071
2233
  const syncDurationMs = Date.now() - syncStartTime;
@@ -2121,11 +2283,19 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
2121
2283
  console.log("\n (dry-run \u2014 no changes)");
2122
2284
  }
2123
2285
  console.log("\n Settings sync...");
2124
- await syncSettings(claudeDir, projectPath, defaultsRes.data, repoData, dryRun);
2286
+ await syncSettings(
2287
+ claudeDir,
2288
+ projectPath,
2289
+ defaultsRes.data,
2290
+ repoData,
2291
+ dryRun
2292
+ );
2125
2293
  console.log(" Config sync...");
2126
2294
  await syncConfig(repoId, projectPath, dryRun);
2127
2295
  console.log(" Tech stack...");
2128
2296
  await syncTechStack(repoId, projectPath, dryRun);
2297
+ console.log(" Port verification...");
2298
+ await syncPortVerification(repoId, projectPath, dryRun, fix);
2129
2299
  console.log("\n Sync complete.\n");
2130
2300
  }
2131
2301
  async function syncSettings(claudeDir, projectPath, syncData, repoData, dryRun) {
@@ -2133,20 +2303,27 @@ async function syncSettings(claudeDir, projectPath, syncData, repoData, dryRun)
2133
2303
  const globalSettingsFiles = syncData.global_settings ?? [];
2134
2304
  let globalSettings = {};
2135
2305
  for (const gf of globalSettingsFiles) {
2136
- const parsed = JSON.parse(substituteVariables(gf.content, repoData));
2306
+ const parsed = JSON.parse(
2307
+ substituteVariables(gf.content, repoData)
2308
+ );
2137
2309
  globalSettings = { ...globalSettings, ...parsed };
2138
2310
  }
2139
2311
  const repoSettingsFiles = syncData.settings ?? [];
2140
2312
  let repoSettings = {};
2141
2313
  for (const rf of repoSettingsFiles) {
2142
- repoSettings = JSON.parse(substituteVariables(rf.content, repoData));
2314
+ repoSettings = JSON.parse(
2315
+ substituteVariables(rf.content, repoData)
2316
+ );
2143
2317
  }
2144
- const combinedTemplate = mergeGlobalAndRepoSettings(globalSettings, repoSettings);
2318
+ const combinedTemplate = mergeGlobalAndRepoSettings(
2319
+ globalSettings,
2320
+ repoSettings
2321
+ );
2145
2322
  const hooksDir = join7(projectPath, ".claude", "hooks");
2146
2323
  const discovered = await discoverHooks(hooksDir);
2147
2324
  let localSettings = {};
2148
2325
  try {
2149
- const raw = await readFile7(settingsPath, "utf-8");
2326
+ const raw = await readFile8(settingsPath, "utf-8");
2150
2327
  localSettings = JSON.parse(raw);
2151
2328
  } catch {
2152
2329
  }
@@ -2161,7 +2338,7 @@ async function syncSettings(claudeDir, projectPath, syncData, repoData, dryRun)
2161
2338
  const mergedContent = JSON.stringify(merged, null, 2) + "\n";
2162
2339
  let currentContent = "";
2163
2340
  try {
2164
- currentContent = await readFile7(settingsPath, "utf-8");
2341
+ currentContent = await readFile8(settingsPath, "utf-8");
2165
2342
  } catch {
2166
2343
  }
2167
2344
  if (currentContent === mergedContent) {
@@ -2180,7 +2357,7 @@ async function syncConfig(repoId, projectPath, dryRun) {
2180
2357
  const configPath = join7(projectPath, ".codebyplan.json");
2181
2358
  let currentConfig = {};
2182
2359
  try {
2183
- const raw = await readFile7(configPath, "utf-8");
2360
+ const raw = await readFile8(configPath, "utf-8");
2184
2361
  currentConfig = JSON.parse(raw);
2185
2362
  } catch {
2186
2363
  currentConfig = { repo_id: repoId };
@@ -2189,10 +2366,35 @@ async function syncConfig(repoId, projectPath, dryRun) {
2189
2366
  const repo = repoRes.data;
2190
2367
  let portAllocations = [];
2191
2368
  try {
2192
- const portsRes = await apiGet(`/port-allocations`, { repo_id: repoId });
2369
+ const portsRes = await apiGet(
2370
+ `/port-allocations`,
2371
+ { repo_id: repoId }
2372
+ );
2193
2373
  const allAllocations = portsRes.data ?? [];
2194
2374
  const worktreeId2 = currentConfig.worktree_id;
2195
- portAllocations = worktreeId2 ? allAllocations.filter((a) => a.worktree_id === worktreeId2) : allAllocations.filter((a) => !a.worktree_id);
2375
+ const filtered = worktreeId2 ? allAllocations.filter((a) => a.worktree_id === worktreeId2) : allAllocations.filter((a) => !a.worktree_id);
2376
+ const ALLOWED_FIELDS = [
2377
+ "id",
2378
+ "repo_id",
2379
+ "port",
2380
+ "label",
2381
+ "server_type",
2382
+ "auto_start",
2383
+ "command",
2384
+ "working_dir",
2385
+ "env_vars",
2386
+ "external_refs",
2387
+ "worktree_id",
2388
+ "created_at",
2389
+ "updated_at"
2390
+ ];
2391
+ portAllocations = filtered.map((a) => {
2392
+ const clean = {};
2393
+ for (const key of ALLOWED_FIELDS) {
2394
+ if (key in a) clean[key] = a[key];
2395
+ }
2396
+ return clean;
2397
+ });
2196
2398
  } catch {
2197
2399
  }
2198
2400
  const worktreeId = currentConfig.worktree_id;
@@ -2227,14 +2429,15 @@ async function syncTechStack(repoId, projectPath, dryRun) {
2227
2429
  return;
2228
2430
  }
2229
2431
  const sourcePaths = new Set(dependencies.map((d) => d.source_path));
2230
- console.log(` ${dependencies.length} dependencies from ${sourcePaths.size} package.json file${sourcePaths.size !== 1 ? "s" : ""}`);
2432
+ console.log(
2433
+ ` ${dependencies.length} dependencies from ${sourcePaths.size} package.json file${sourcePaths.size !== 1 ? "s" : ""}`
2434
+ );
2231
2435
  if (!dryRun) {
2232
- const result = await apiPost(
2233
- `/repos/${repoId}/tech-stack`,
2234
- { dependencies }
2235
- );
2436
+ const result = await apiPost(`/repos/${repoId}/tech-stack`, { dependencies });
2236
2437
  if (result.data.stale_removed > 0) {
2237
- console.log(` ${result.data.stale_removed} stale dependencies removed`);
2438
+ console.log(
2439
+ ` ${result.data.stale_removed} stale dependencies removed`
2440
+ );
2238
2441
  }
2239
2442
  }
2240
2443
  const detected = await detectTechStack(projectPath);
@@ -2253,6 +2456,71 @@ async function syncTechStack(repoId, projectPath, dryRun) {
2253
2456
  console.log(" Tech stack detection skipped.");
2254
2457
  }
2255
2458
  }
2459
+ async function syncPortVerification(repoId, projectPath, dryRun, fix) {
2460
+ try {
2461
+ const portsRes = await apiGet(
2462
+ `/port-allocations`,
2463
+ { repo_id: repoId }
2464
+ );
2465
+ const allocations = portsRes.data ?? [];
2466
+ if (allocations.length === 0) {
2467
+ console.log(" No port allocations found \u2014 skipping verification.");
2468
+ return;
2469
+ }
2470
+ const mismatches = await verifyPorts(projectPath, allocations);
2471
+ if (mismatches.length > 0) {
2472
+ console.log(` Port mismatches: ${mismatches.length}`);
2473
+ for (const m of mismatches) {
2474
+ console.log(` ! ${m.packageJsonPath}: ${m.reason}`);
2475
+ }
2476
+ }
2477
+ const unallocated = await findUnallocatedApps(projectPath, allocations);
2478
+ if (unallocated.length > 0) {
2479
+ console.log(` Unallocated apps: ${unallocated.length}`);
2480
+ for (const app of unallocated) {
2481
+ console.log(
2482
+ ` + ${app.name} (${app.framework}${app.detectedPort ? `, port ${app.detectedPort}` : ""})`
2483
+ );
2484
+ }
2485
+ if (fix && !dryRun) {
2486
+ const maxPort = Math.max(...allocations.map((a) => a.port), 2999);
2487
+ let nextPort = maxPort + 1;
2488
+ for (const app of unallocated) {
2489
+ const port = app.detectedPort ?? nextPort++;
2490
+ try {
2491
+ await apiPost("/port-allocations", {
2492
+ repo_id: repoId,
2493
+ port,
2494
+ label: app.name,
2495
+ server_type: app.framework,
2496
+ auto_start: "manual",
2497
+ command: app.command,
2498
+ working_dir: app.path
2499
+ });
2500
+ console.log(` Created allocation: ${app.name} \u2192 port ${port}`);
2501
+ } catch (err) {
2502
+ const msg = err instanceof Error ? err.message : String(err);
2503
+ console.log(
2504
+ ` Failed to create allocation for ${app.name}: ${msg}`
2505
+ );
2506
+ }
2507
+ if (app.detectedPort && app.detectedPort >= nextPort) {
2508
+ nextPort = app.detectedPort + 1;
2509
+ }
2510
+ }
2511
+ } else if (fix && dryRun) {
2512
+ console.log(" (dry-run \u2014 would create allocations with --fix)");
2513
+ } else {
2514
+ console.log(" Run with --fix to auto-create allocations.");
2515
+ }
2516
+ }
2517
+ if (mismatches.length === 0 && unallocated.length === 0) {
2518
+ console.log(" Ports verified.");
2519
+ }
2520
+ } catch {
2521
+ console.log(" Port verification skipped.");
2522
+ }
2523
+ }
2256
2524
  function groupByType(items) {
2257
2525
  const groups = /* @__PURE__ */ new Map();
2258
2526
  const typeLabels = {
@@ -2288,14 +2556,16 @@ function getLocalFilePath(claudeDir, projectPath, remote) {
2288
2556
  const cfg = typeConfig2[remote.type];
2289
2557
  if (!cfg) return join7(claudeDir, remote.name);
2290
2558
  const typeDir = remote.type === "command" ? join7(claudeDir, cfg.dir, "cbp") : join7(claudeDir, cfg.dir);
2291
- if (cfg.subfolder) return join7(typeDir, remote.name, `${cfg.subfolder}${cfg.ext}`);
2292
- if (remote.type === "command" && remote.category) return join7(typeDir, remote.category, `${remote.name}${cfg.ext}`);
2559
+ if (cfg.subfolder)
2560
+ return join7(typeDir, remote.name, `${cfg.subfolder}${cfg.ext}`);
2561
+ if (remote.type === "command" && remote.category)
2562
+ return join7(typeDir, remote.category, `${remote.name}${cfg.ext}`);
2293
2563
  if (remote.type === "template") return join7(typeDir, remote.name);
2294
2564
  return join7(typeDir, `${remote.name}${cfg.ext}`);
2295
2565
  }
2296
2566
  function getSyncVersion() {
2297
2567
  try {
2298
- return "3.4.0";
2568
+ return "3.5.0";
2299
2569
  } catch {
2300
2570
  return "unknown";
2301
2571
  }
@@ -2339,6 +2609,7 @@ var init_sync = __esm({
2339
2609
  init_tech_detect();
2340
2610
  init_settings_merge();
2341
2611
  init_hook_registry();
2612
+ init_port_verify();
2342
2613
  }
2343
2614
  });
2344
2615
 
@@ -15519,9 +15790,9 @@ var init_protocol = __esm({
15519
15790
  }
15520
15791
  });
15521
15792
 
15522
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/codegen/code.js
15793
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js
15523
15794
  var require_code = __commonJS({
15524
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/codegen/code.js"(exports) {
15795
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js"(exports) {
15525
15796
  "use strict";
15526
15797
  Object.defineProperty(exports, "__esModule", { value: true });
15527
15798
  exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
@@ -15673,9 +15944,9 @@ var require_code = __commonJS({
15673
15944
  }
15674
15945
  });
15675
15946
 
15676
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/codegen/scope.js
15947
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js
15677
15948
  var require_scope = __commonJS({
15678
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/codegen/scope.js"(exports) {
15949
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js"(exports) {
15679
15950
  "use strict";
15680
15951
  Object.defineProperty(exports, "__esModule", { value: true });
15681
15952
  exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
@@ -15818,9 +16089,9 @@ var require_scope = __commonJS({
15818
16089
  }
15819
16090
  });
15820
16091
 
15821
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/codegen/index.js
16092
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js
15822
16093
  var require_codegen = __commonJS({
15823
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/codegen/index.js"(exports) {
16094
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js"(exports) {
15824
16095
  "use strict";
15825
16096
  Object.defineProperty(exports, "__esModule", { value: true });
15826
16097
  exports.or = exports.and = exports.not = exports.CodeGen = exports.operators = exports.varKinds = exports.ValueScopeName = exports.ValueScope = exports.Scope = exports.Name = exports.regexpCode = exports.stringify = exports.getProperty = exports.nil = exports.strConcat = exports.str = exports._ = void 0;
@@ -16538,9 +16809,9 @@ var require_codegen = __commonJS({
16538
16809
  }
16539
16810
  });
16540
16811
 
16541
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/util.js
16812
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js
16542
16813
  var require_util = __commonJS({
16543
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/util.js"(exports) {
16814
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js"(exports) {
16544
16815
  "use strict";
16545
16816
  Object.defineProperty(exports, "__esModule", { value: true });
16546
16817
  exports.checkStrictMode = exports.getErrorPath = exports.Type = exports.useFunc = exports.setEvaluated = exports.evaluatedPropsToName = exports.mergeEvaluated = exports.eachItem = exports.unescapeJsonPointer = exports.escapeJsonPointer = exports.escapeFragment = exports.unescapeFragment = exports.schemaRefOrVal = exports.schemaHasRulesButRef = exports.schemaHasRules = exports.checkUnknownRules = exports.alwaysValidSchema = exports.toHash = void 0;
@@ -16705,9 +16976,9 @@ var require_util = __commonJS({
16705
16976
  }
16706
16977
  });
16707
16978
 
16708
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/names.js
16979
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js
16709
16980
  var require_names = __commonJS({
16710
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/names.js"(exports) {
16981
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js"(exports) {
16711
16982
  "use strict";
16712
16983
  Object.defineProperty(exports, "__esModule", { value: true });
16713
16984
  var codegen_1 = require_codegen();
@@ -16744,9 +17015,9 @@ var require_names = __commonJS({
16744
17015
  }
16745
17016
  });
16746
17017
 
16747
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/errors.js
17018
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js
16748
17019
  var require_errors = __commonJS({
16749
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/errors.js"(exports) {
17020
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js"(exports) {
16750
17021
  "use strict";
16751
17022
  Object.defineProperty(exports, "__esModule", { value: true });
16752
17023
  exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0;
@@ -16866,9 +17137,9 @@ var require_errors = __commonJS({
16866
17137
  }
16867
17138
  });
16868
17139
 
16869
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/boolSchema.js
17140
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js
16870
17141
  var require_boolSchema = __commonJS({
16871
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/boolSchema.js"(exports) {
17142
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js"(exports) {
16872
17143
  "use strict";
16873
17144
  Object.defineProperty(exports, "__esModule", { value: true });
16874
17145
  exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0;
@@ -16917,9 +17188,9 @@ var require_boolSchema = __commonJS({
16917
17188
  }
16918
17189
  });
16919
17190
 
16920
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/rules.js
17191
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js
16921
17192
  var require_rules = __commonJS({
16922
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/rules.js"(exports) {
17193
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js"(exports) {
16923
17194
  "use strict";
16924
17195
  Object.defineProperty(exports, "__esModule", { value: true });
16925
17196
  exports.getRules = exports.isJSONType = void 0;
@@ -16948,9 +17219,9 @@ var require_rules = __commonJS({
16948
17219
  }
16949
17220
  });
16950
17221
 
16951
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/applicability.js
17222
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js
16952
17223
  var require_applicability = __commonJS({
16953
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/applicability.js"(exports) {
17224
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js"(exports) {
16954
17225
  "use strict";
16955
17226
  Object.defineProperty(exports, "__esModule", { value: true });
16956
17227
  exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = void 0;
@@ -16971,9 +17242,9 @@ var require_applicability = __commonJS({
16971
17242
  }
16972
17243
  });
16973
17244
 
16974
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/dataType.js
17245
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js
16975
17246
  var require_dataType = __commonJS({
16976
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/dataType.js"(exports) {
17247
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js"(exports) {
16977
17248
  "use strict";
16978
17249
  Object.defineProperty(exports, "__esModule", { value: true });
16979
17250
  exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0;
@@ -17155,9 +17426,9 @@ var require_dataType = __commonJS({
17155
17426
  }
17156
17427
  });
17157
17428
 
17158
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/defaults.js
17429
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js
17159
17430
  var require_defaults = __commonJS({
17160
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/defaults.js"(exports) {
17431
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js"(exports) {
17161
17432
  "use strict";
17162
17433
  Object.defineProperty(exports, "__esModule", { value: true });
17163
17434
  exports.assignDefaults = void 0;
@@ -17192,9 +17463,9 @@ var require_defaults = __commonJS({
17192
17463
  }
17193
17464
  });
17194
17465
 
17195
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/code.js
17466
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js
17196
17467
  var require_code2 = __commonJS({
17197
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/code.js"(exports) {
17468
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js"(exports) {
17198
17469
  "use strict";
17199
17470
  Object.defineProperty(exports, "__esModule", { value: true });
17200
17471
  exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.isOwnProperty = exports.hasPropFunc = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0;
@@ -17325,9 +17596,9 @@ var require_code2 = __commonJS({
17325
17596
  }
17326
17597
  });
17327
17598
 
17328
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/keyword.js
17599
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js
17329
17600
  var require_keyword = __commonJS({
17330
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/keyword.js"(exports) {
17601
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js"(exports) {
17331
17602
  "use strict";
17332
17603
  Object.defineProperty(exports, "__esModule", { value: true });
17333
17604
  exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = void 0;
@@ -17443,9 +17714,9 @@ var require_keyword = __commonJS({
17443
17714
  }
17444
17715
  });
17445
17716
 
17446
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/subschema.js
17717
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js
17447
17718
  var require_subschema = __commonJS({
17448
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/subschema.js"(exports) {
17719
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js"(exports) {
17449
17720
  "use strict";
17450
17721
  Object.defineProperty(exports, "__esModule", { value: true });
17451
17722
  exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = void 0;
@@ -17649,9 +17920,9 @@ var require_json_schema_traverse = __commonJS({
17649
17920
  }
17650
17921
  });
17651
17922
 
17652
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/resolve.js
17923
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js
17653
17924
  var require_resolve = __commonJS({
17654
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/resolve.js"(exports) {
17925
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js"(exports) {
17655
17926
  "use strict";
17656
17927
  Object.defineProperty(exports, "__esModule", { value: true });
17657
17928
  exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = void 0;
@@ -17805,9 +18076,9 @@ var require_resolve = __commonJS({
17805
18076
  }
17806
18077
  });
17807
18078
 
17808
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/index.js
18079
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js
17809
18080
  var require_validate = __commonJS({
17810
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/validate/index.js"(exports) {
18081
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js"(exports) {
17811
18082
  "use strict";
17812
18083
  Object.defineProperty(exports, "__esModule", { value: true });
17813
18084
  exports.getData = exports.KeywordCxt = exports.validateFunctionCode = void 0;
@@ -18313,9 +18584,9 @@ var require_validate = __commonJS({
18313
18584
  }
18314
18585
  });
18315
18586
 
18316
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/runtime/validation_error.js
18587
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.js
18317
18588
  var require_validation_error = __commonJS({
18318
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/runtime/validation_error.js"(exports) {
18589
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.js"(exports) {
18319
18590
  "use strict";
18320
18591
  Object.defineProperty(exports, "__esModule", { value: true });
18321
18592
  var ValidationError = class extends Error {
@@ -18329,9 +18600,9 @@ var require_validation_error = __commonJS({
18329
18600
  }
18330
18601
  });
18331
18602
 
18332
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/ref_error.js
18603
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js
18333
18604
  var require_ref_error = __commonJS({
18334
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/ref_error.js"(exports) {
18605
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js"(exports) {
18335
18606
  "use strict";
18336
18607
  Object.defineProperty(exports, "__esModule", { value: true });
18337
18608
  var resolve_1 = require_resolve();
@@ -18346,9 +18617,9 @@ var require_ref_error = __commonJS({
18346
18617
  }
18347
18618
  });
18348
18619
 
18349
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/index.js
18620
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js
18350
18621
  var require_compile = __commonJS({
18351
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/index.js"(exports) {
18622
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js"(exports) {
18352
18623
  "use strict";
18353
18624
  Object.defineProperty(exports, "__esModule", { value: true });
18354
18625
  exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = void 0;
@@ -18570,9 +18841,9 @@ var require_compile = __commonJS({
18570
18841
  }
18571
18842
  });
18572
18843
 
18573
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/refs/data.json
18844
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.json
18574
18845
  var require_data = __commonJS({
18575
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/refs/data.json"(exports, module) {
18846
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.json"(exports, module) {
18576
18847
  module.exports = {
18577
18848
  $id: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
18578
18849
  description: "Meta-schema for $data reference (JSON AnySchema extension proposal)",
@@ -19311,9 +19582,9 @@ var require_fast_uri = __commonJS({
19311
19582
  }
19312
19583
  });
19313
19584
 
19314
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/runtime/uri.js
19585
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js
19315
19586
  var require_uri = __commonJS({
19316
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/runtime/uri.js"(exports) {
19587
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js"(exports) {
19317
19588
  "use strict";
19318
19589
  Object.defineProperty(exports, "__esModule", { value: true });
19319
19590
  var uri = require_fast_uri();
@@ -19322,9 +19593,9 @@ var require_uri = __commonJS({
19322
19593
  }
19323
19594
  });
19324
19595
 
19325
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/core.js
19596
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js
19326
19597
  var require_core = __commonJS({
19327
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/core.js"(exports) {
19598
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js"(exports) {
19328
19599
  "use strict";
19329
19600
  Object.defineProperty(exports, "__esModule", { value: true });
19330
19601
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
@@ -19933,9 +20204,9 @@ var require_core = __commonJS({
19933
20204
  }
19934
20205
  });
19935
20206
 
19936
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/core/id.js
20207
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js
19937
20208
  var require_id = __commonJS({
19938
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/core/id.js"(exports) {
20209
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js"(exports) {
19939
20210
  "use strict";
19940
20211
  Object.defineProperty(exports, "__esModule", { value: true });
19941
20212
  var def = {
@@ -19948,9 +20219,9 @@ var require_id = __commonJS({
19948
20219
  }
19949
20220
  });
19950
20221
 
19951
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/core/ref.js
20222
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js
19952
20223
  var require_ref = __commonJS({
19953
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/core/ref.js"(exports) {
20224
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js"(exports) {
19954
20225
  "use strict";
19955
20226
  Object.defineProperty(exports, "__esModule", { value: true });
19956
20227
  exports.callRef = exports.getValidate = void 0;
@@ -20070,9 +20341,9 @@ var require_ref = __commonJS({
20070
20341
  }
20071
20342
  });
20072
20343
 
20073
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/core/index.js
20344
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js
20074
20345
  var require_core2 = __commonJS({
20075
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/core/index.js"(exports) {
20346
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js"(exports) {
20076
20347
  "use strict";
20077
20348
  Object.defineProperty(exports, "__esModule", { value: true });
20078
20349
  var id_1 = require_id();
@@ -20091,9 +20362,9 @@ var require_core2 = __commonJS({
20091
20362
  }
20092
20363
  });
20093
20364
 
20094
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
20365
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
20095
20366
  var require_limitNumber = __commonJS({
20096
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/limitNumber.js"(exports) {
20367
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js"(exports) {
20097
20368
  "use strict";
20098
20369
  Object.defineProperty(exports, "__esModule", { value: true });
20099
20370
  var codegen_1 = require_codegen();
@@ -20123,9 +20394,9 @@ var require_limitNumber = __commonJS({
20123
20394
  }
20124
20395
  });
20125
20396
 
20126
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
20397
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
20127
20398
  var require_multipleOf = __commonJS({
20128
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/multipleOf.js"(exports) {
20399
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js"(exports) {
20129
20400
  "use strict";
20130
20401
  Object.defineProperty(exports, "__esModule", { value: true });
20131
20402
  var codegen_1 = require_codegen();
@@ -20151,9 +20422,9 @@ var require_multipleOf = __commonJS({
20151
20422
  }
20152
20423
  });
20153
20424
 
20154
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/runtime/ucs2length.js
20425
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js
20155
20426
  var require_ucs2length = __commonJS({
20156
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
20427
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
20157
20428
  "use strict";
20158
20429
  Object.defineProperty(exports, "__esModule", { value: true });
20159
20430
  function ucs2length(str) {
@@ -20177,9 +20448,9 @@ var require_ucs2length = __commonJS({
20177
20448
  }
20178
20449
  });
20179
20450
 
20180
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/limitLength.js
20451
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js
20181
20452
  var require_limitLength = __commonJS({
20182
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/limitLength.js"(exports) {
20453
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js"(exports) {
20183
20454
  "use strict";
20184
20455
  Object.defineProperty(exports, "__esModule", { value: true });
20185
20456
  var codegen_1 = require_codegen();
@@ -20209,12 +20480,13 @@ var require_limitLength = __commonJS({
20209
20480
  }
20210
20481
  });
20211
20482
 
20212
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/pattern.js
20483
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js
20213
20484
  var require_pattern = __commonJS({
20214
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/pattern.js"(exports) {
20485
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js"(exports) {
20215
20486
  "use strict";
20216
20487
  Object.defineProperty(exports, "__esModule", { value: true });
20217
20488
  var code_1 = require_code2();
20489
+ var util_1 = require_util();
20218
20490
  var codegen_1 = require_codegen();
20219
20491
  var error2 = {
20220
20492
  message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
@@ -20227,19 +20499,27 @@ var require_pattern = __commonJS({
20227
20499
  $data: true,
20228
20500
  error: error2,
20229
20501
  code(cxt) {
20230
- const { data, $data, schema, schemaCode, it } = cxt;
20502
+ const { gen, data, $data, schema, schemaCode, it } = cxt;
20231
20503
  const u = it.opts.unicodeRegExp ? "u" : "";
20232
- const regExp = $data ? (0, codegen_1._)`(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema);
20233
- cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
20504
+ if ($data) {
20505
+ const { regExp } = it.opts.code;
20506
+ const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
20507
+ const valid = gen.let("valid");
20508
+ gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
20509
+ cxt.fail$data((0, codegen_1._)`!${valid}`);
20510
+ } else {
20511
+ const regExp = (0, code_1.usePattern)(cxt, schema);
20512
+ cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
20513
+ }
20234
20514
  }
20235
20515
  };
20236
20516
  exports.default = def;
20237
20517
  }
20238
20518
  });
20239
20519
 
20240
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
20520
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
20241
20521
  var require_limitProperties = __commonJS({
20242
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/limitProperties.js"(exports) {
20522
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js"(exports) {
20243
20523
  "use strict";
20244
20524
  Object.defineProperty(exports, "__esModule", { value: true });
20245
20525
  var codegen_1 = require_codegen();
@@ -20266,9 +20546,9 @@ var require_limitProperties = __commonJS({
20266
20546
  }
20267
20547
  });
20268
20548
 
20269
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/required.js
20549
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js
20270
20550
  var require_required = __commonJS({
20271
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/required.js"(exports) {
20551
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js"(exports) {
20272
20552
  "use strict";
20273
20553
  Object.defineProperty(exports, "__esModule", { value: true });
20274
20554
  var code_1 = require_code2();
@@ -20348,9 +20628,9 @@ var require_required = __commonJS({
20348
20628
  }
20349
20629
  });
20350
20630
 
20351
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/limitItems.js
20631
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js
20352
20632
  var require_limitItems = __commonJS({
20353
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/limitItems.js"(exports) {
20633
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js"(exports) {
20354
20634
  "use strict";
20355
20635
  Object.defineProperty(exports, "__esModule", { value: true });
20356
20636
  var codegen_1 = require_codegen();
@@ -20377,9 +20657,9 @@ var require_limitItems = __commonJS({
20377
20657
  }
20378
20658
  });
20379
20659
 
20380
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/runtime/equal.js
20660
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js
20381
20661
  var require_equal = __commonJS({
20382
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/runtime/equal.js"(exports) {
20662
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js"(exports) {
20383
20663
  "use strict";
20384
20664
  Object.defineProperty(exports, "__esModule", { value: true });
20385
20665
  var equal = require_fast_deep_equal();
@@ -20388,9 +20668,9 @@ var require_equal = __commonJS({
20388
20668
  }
20389
20669
  });
20390
20670
 
20391
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
20671
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
20392
20672
  var require_uniqueItems = __commonJS({
20393
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js"(exports) {
20673
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js"(exports) {
20394
20674
  "use strict";
20395
20675
  Object.defineProperty(exports, "__esModule", { value: true });
20396
20676
  var dataType_1 = require_dataType();
@@ -20455,9 +20735,9 @@ var require_uniqueItems = __commonJS({
20455
20735
  }
20456
20736
  });
20457
20737
 
20458
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/const.js
20738
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js
20459
20739
  var require_const = __commonJS({
20460
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/const.js"(exports) {
20740
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js"(exports) {
20461
20741
  "use strict";
20462
20742
  Object.defineProperty(exports, "__esModule", { value: true });
20463
20743
  var codegen_1 = require_codegen();
@@ -20484,9 +20764,9 @@ var require_const = __commonJS({
20484
20764
  }
20485
20765
  });
20486
20766
 
20487
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/enum.js
20767
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js
20488
20768
  var require_enum = __commonJS({
20489
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/enum.js"(exports) {
20769
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js"(exports) {
20490
20770
  "use strict";
20491
20771
  Object.defineProperty(exports, "__esModule", { value: true });
20492
20772
  var codegen_1 = require_codegen();
@@ -20533,9 +20813,9 @@ var require_enum = __commonJS({
20533
20813
  }
20534
20814
  });
20535
20815
 
20536
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/index.js
20816
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js
20537
20817
  var require_validation = __commonJS({
20538
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/validation/index.js"(exports) {
20818
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js"(exports) {
20539
20819
  "use strict";
20540
20820
  Object.defineProperty(exports, "__esModule", { value: true });
20541
20821
  var limitNumber_1 = require_limitNumber();
@@ -20571,9 +20851,9 @@ var require_validation = __commonJS({
20571
20851
  }
20572
20852
  });
20573
20853
 
20574
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
20854
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
20575
20855
  var require_additionalItems = __commonJS({
20576
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js"(exports) {
20856
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js"(exports) {
20577
20857
  "use strict";
20578
20858
  Object.defineProperty(exports, "__esModule", { value: true });
20579
20859
  exports.validateAdditionalItems = void 0;
@@ -20624,9 +20904,9 @@ var require_additionalItems = __commonJS({
20624
20904
  }
20625
20905
  });
20626
20906
 
20627
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/items.js
20907
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js
20628
20908
  var require_items = __commonJS({
20629
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/items.js"(exports) {
20909
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js"(exports) {
20630
20910
  "use strict";
20631
20911
  Object.defineProperty(exports, "__esModule", { value: true });
20632
20912
  exports.validateTuple = void 0;
@@ -20681,9 +20961,9 @@ var require_items = __commonJS({
20681
20961
  }
20682
20962
  });
20683
20963
 
20684
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
20964
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
20685
20965
  var require_prefixItems = __commonJS({
20686
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js"(exports) {
20966
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js"(exports) {
20687
20967
  "use strict";
20688
20968
  Object.defineProperty(exports, "__esModule", { value: true });
20689
20969
  var items_1 = require_items();
@@ -20698,9 +20978,9 @@ var require_prefixItems = __commonJS({
20698
20978
  }
20699
20979
  });
20700
20980
 
20701
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/items2020.js
20981
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js
20702
20982
  var require_items2020 = __commonJS({
20703
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/items2020.js"(exports) {
20983
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js"(exports) {
20704
20984
  "use strict";
20705
20985
  Object.defineProperty(exports, "__esModule", { value: true });
20706
20986
  var codegen_1 = require_codegen();
@@ -20733,9 +21013,9 @@ var require_items2020 = __commonJS({
20733
21013
  }
20734
21014
  });
20735
21015
 
20736
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/contains.js
21016
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js
20737
21017
  var require_contains = __commonJS({
20738
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/contains.js"(exports) {
21018
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js"(exports) {
20739
21019
  "use strict";
20740
21020
  Object.defineProperty(exports, "__esModule", { value: true });
20741
21021
  var codegen_1 = require_codegen();
@@ -20827,9 +21107,9 @@ var require_contains = __commonJS({
20827
21107
  }
20828
21108
  });
20829
21109
 
20830
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
21110
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
20831
21111
  var require_dependencies = __commonJS({
20832
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/dependencies.js"(exports) {
21112
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js"(exports) {
20833
21113
  "use strict";
20834
21114
  Object.defineProperty(exports, "__esModule", { value: true });
20835
21115
  exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0;
@@ -20921,9 +21201,9 @@ var require_dependencies = __commonJS({
20921
21201
  }
20922
21202
  });
20923
21203
 
20924
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
21204
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
20925
21205
  var require_propertyNames = __commonJS({
20926
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js"(exports) {
21206
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js"(exports) {
20927
21207
  "use strict";
20928
21208
  Object.defineProperty(exports, "__esModule", { value: true });
20929
21209
  var codegen_1 = require_codegen();
@@ -20964,9 +21244,9 @@ var require_propertyNames = __commonJS({
20964
21244
  }
20965
21245
  });
20966
21246
 
20967
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
21247
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
20968
21248
  var require_additionalProperties = __commonJS({
20969
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js"(exports) {
21249
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js"(exports) {
20970
21250
  "use strict";
20971
21251
  Object.defineProperty(exports, "__esModule", { value: true });
20972
21252
  var code_1 = require_code2();
@@ -21070,9 +21350,9 @@ var require_additionalProperties = __commonJS({
21070
21350
  }
21071
21351
  });
21072
21352
 
21073
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/properties.js
21353
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js
21074
21354
  var require_properties = __commonJS({
21075
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/properties.js"(exports) {
21355
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js"(exports) {
21076
21356
  "use strict";
21077
21357
  Object.defineProperty(exports, "__esModule", { value: true });
21078
21358
  var validate_1 = require_validate();
@@ -21128,9 +21408,9 @@ var require_properties = __commonJS({
21128
21408
  }
21129
21409
  });
21130
21410
 
21131
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
21411
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
21132
21412
  var require_patternProperties = __commonJS({
21133
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js"(exports) {
21413
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js"(exports) {
21134
21414
  "use strict";
21135
21415
  Object.defineProperty(exports, "__esModule", { value: true });
21136
21416
  var code_1 = require_code2();
@@ -21202,9 +21482,9 @@ var require_patternProperties = __commonJS({
21202
21482
  }
21203
21483
  });
21204
21484
 
21205
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/not.js
21485
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js
21206
21486
  var require_not = __commonJS({
21207
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/not.js"(exports) {
21487
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js"(exports) {
21208
21488
  "use strict";
21209
21489
  Object.defineProperty(exports, "__esModule", { value: true });
21210
21490
  var util_1 = require_util();
@@ -21233,9 +21513,9 @@ var require_not = __commonJS({
21233
21513
  }
21234
21514
  });
21235
21515
 
21236
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
21516
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
21237
21517
  var require_anyOf = __commonJS({
21238
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/anyOf.js"(exports) {
21518
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js"(exports) {
21239
21519
  "use strict";
21240
21520
  Object.defineProperty(exports, "__esModule", { value: true });
21241
21521
  var code_1 = require_code2();
@@ -21250,9 +21530,9 @@ var require_anyOf = __commonJS({
21250
21530
  }
21251
21531
  });
21252
21532
 
21253
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
21533
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
21254
21534
  var require_oneOf = __commonJS({
21255
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/oneOf.js"(exports) {
21535
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js"(exports) {
21256
21536
  "use strict";
21257
21537
  Object.defineProperty(exports, "__esModule", { value: true });
21258
21538
  var codegen_1 = require_codegen();
@@ -21308,9 +21588,9 @@ var require_oneOf = __commonJS({
21308
21588
  }
21309
21589
  });
21310
21590
 
21311
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/allOf.js
21591
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js
21312
21592
  var require_allOf = __commonJS({
21313
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/allOf.js"(exports) {
21593
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js"(exports) {
21314
21594
  "use strict";
21315
21595
  Object.defineProperty(exports, "__esModule", { value: true });
21316
21596
  var util_1 = require_util();
@@ -21335,9 +21615,9 @@ var require_allOf = __commonJS({
21335
21615
  }
21336
21616
  });
21337
21617
 
21338
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/if.js
21618
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js
21339
21619
  var require_if = __commonJS({
21340
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/if.js"(exports) {
21620
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js"(exports) {
21341
21621
  "use strict";
21342
21622
  Object.defineProperty(exports, "__esModule", { value: true });
21343
21623
  var codegen_1 = require_codegen();
@@ -21404,9 +21684,9 @@ var require_if = __commonJS({
21404
21684
  }
21405
21685
  });
21406
21686
 
21407
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
21687
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
21408
21688
  var require_thenElse = __commonJS({
21409
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/thenElse.js"(exports) {
21689
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js"(exports) {
21410
21690
  "use strict";
21411
21691
  Object.defineProperty(exports, "__esModule", { value: true });
21412
21692
  var util_1 = require_util();
@@ -21422,9 +21702,9 @@ var require_thenElse = __commonJS({
21422
21702
  }
21423
21703
  });
21424
21704
 
21425
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/index.js
21705
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js
21426
21706
  var require_applicator = __commonJS({
21427
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/applicator/index.js"(exports) {
21707
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js"(exports) {
21428
21708
  "use strict";
21429
21709
  Object.defineProperty(exports, "__esModule", { value: true });
21430
21710
  var additionalItems_1 = require_additionalItems();
@@ -21470,9 +21750,9 @@ var require_applicator = __commonJS({
21470
21750
  }
21471
21751
  });
21472
21752
 
21473
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/format/format.js
21753
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js
21474
21754
  var require_format = __commonJS({
21475
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/format/format.js"(exports) {
21755
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js"(exports) {
21476
21756
  "use strict";
21477
21757
  Object.defineProperty(exports, "__esModule", { value: true });
21478
21758
  var codegen_1 = require_codegen();
@@ -21560,9 +21840,9 @@ var require_format = __commonJS({
21560
21840
  }
21561
21841
  });
21562
21842
 
21563
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/format/index.js
21843
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js
21564
21844
  var require_format2 = __commonJS({
21565
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/format/index.js"(exports) {
21845
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js"(exports) {
21566
21846
  "use strict";
21567
21847
  Object.defineProperty(exports, "__esModule", { value: true });
21568
21848
  var format_1 = require_format();
@@ -21571,9 +21851,9 @@ var require_format2 = __commonJS({
21571
21851
  }
21572
21852
  });
21573
21853
 
21574
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/metadata.js
21854
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js
21575
21855
  var require_metadata = __commonJS({
21576
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/metadata.js"(exports) {
21856
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js"(exports) {
21577
21857
  "use strict";
21578
21858
  Object.defineProperty(exports, "__esModule", { value: true });
21579
21859
  exports.contentVocabulary = exports.metadataVocabulary = void 0;
@@ -21594,9 +21874,9 @@ var require_metadata = __commonJS({
21594
21874
  }
21595
21875
  });
21596
21876
 
21597
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/draft7.js
21877
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js
21598
21878
  var require_draft7 = __commonJS({
21599
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/draft7.js"(exports) {
21879
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js"(exports) {
21600
21880
  "use strict";
21601
21881
  Object.defineProperty(exports, "__esModule", { value: true });
21602
21882
  var core_1 = require_core2();
@@ -21616,9 +21896,9 @@ var require_draft7 = __commonJS({
21616
21896
  }
21617
21897
  });
21618
21898
 
21619
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/discriminator/types.js
21899
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js
21620
21900
  var require_types = __commonJS({
21621
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/discriminator/types.js"(exports) {
21901
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js"(exports) {
21622
21902
  "use strict";
21623
21903
  Object.defineProperty(exports, "__esModule", { value: true });
21624
21904
  exports.DiscrError = void 0;
@@ -21630,9 +21910,9 @@ var require_types = __commonJS({
21630
21910
  }
21631
21911
  });
21632
21912
 
21633
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/discriminator/index.js
21913
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js
21634
21914
  var require_discriminator = __commonJS({
21635
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/vocabularies/discriminator/index.js"(exports) {
21915
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js"(exports) {
21636
21916
  "use strict";
21637
21917
  Object.defineProperty(exports, "__esModule", { value: true });
21638
21918
  var codegen_1 = require_codegen();
@@ -21735,9 +22015,9 @@ var require_discriminator = __commonJS({
21735
22015
  }
21736
22016
  });
21737
22017
 
21738
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/refs/json-schema-draft-07.json
22018
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.json
21739
22019
  var require_json_schema_draft_07 = __commonJS({
21740
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/refs/json-schema-draft-07.json"(exports, module) {
22020
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.json"(exports, module) {
21741
22021
  module.exports = {
21742
22022
  $schema: "http://json-schema.org/draft-07/schema#",
21743
22023
  $id: "http://json-schema.org/draft-07/schema#",
@@ -21892,9 +22172,9 @@ var require_json_schema_draft_07 = __commonJS({
21892
22172
  }
21893
22173
  });
21894
22174
 
21895
- // ../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/ajv.js
22175
+ // ../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js
21896
22176
  var require_ajv = __commonJS({
21897
- "../../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/ajv.js"(exports, module) {
22177
+ "../../node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js"(exports, module) {
21898
22178
  "use strict";
21899
22179
  Object.defineProperty(exports, "__esModule", { value: true });
21900
22180
  exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = void 0;
@@ -21962,9 +22242,9 @@ var require_ajv = __commonJS({
21962
22242
  }
21963
22243
  });
21964
22244
 
21965
- // ../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.17.1/node_modules/ajv-formats/dist/formats.js
22245
+ // ../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js
21966
22246
  var require_formats = __commonJS({
21967
- "../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.17.1/node_modules/ajv-formats/dist/formats.js"(exports) {
22247
+ "../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js"(exports) {
21968
22248
  "use strict";
21969
22249
  Object.defineProperty(exports, "__esModule", { value: true });
21970
22250
  exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
@@ -22165,9 +22445,9 @@ var require_formats = __commonJS({
22165
22445
  }
22166
22446
  });
22167
22447
 
22168
- // ../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.17.1/node_modules/ajv-formats/dist/limit.js
22448
+ // ../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js
22169
22449
  var require_limit = __commonJS({
22170
- "../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.17.1/node_modules/ajv-formats/dist/limit.js"(exports) {
22450
+ "../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js"(exports) {
22171
22451
  "use strict";
22172
22452
  Object.defineProperty(exports, "__esModule", { value: true });
22173
22453
  exports.formatLimitDefinition = void 0;
@@ -22237,9 +22517,9 @@ var require_limit = __commonJS({
22237
22517
  }
22238
22518
  });
22239
22519
 
22240
- // ../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.17.1/node_modules/ajv-formats/dist/index.js
22520
+ // ../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js
22241
22521
  var require_dist = __commonJS({
22242
- "../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.17.1/node_modules/ajv-formats/dist/index.js"(exports, module) {
22522
+ "../../node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js"(exports, module) {
22243
22523
  "use strict";
22244
22524
  Object.defineProperty(exports, "__esModule", { value: true });
22245
22525
  var formats_1 = require_formats();
@@ -24063,7 +24343,7 @@ function registerReadTools(server) {
24063
24343
  server.registerTool(
24064
24344
  "get_current_task",
24065
24345
  {
24066
- description: "Get the current in-progress task for a repo. Finds the active checkpoint, then the in-progress task within it.",
24346
+ description: "Get the current in-progress task for a repo. Finds the active checkpoint, then the in-progress task within it. Also checks for standalone in-progress tasks (no checkpoint).",
24067
24347
  inputSchema: {
24068
24348
  repo_id: external_exports.string().uuid().describe("The repo UUID"),
24069
24349
  worktree_id: external_exports.string().uuid().optional().describe(
@@ -24087,11 +24367,34 @@ function registerReadTools(server) {
24087
24367
  );
24088
24368
  }
24089
24369
  if (activeCheckpoints.length === 0) {
24370
+ const standaloneRes = await apiGet("/tasks", {
24371
+ repo_id,
24372
+ status: "in_progress",
24373
+ standalone: "true"
24374
+ });
24375
+ if (standaloneRes.data.length > 0) {
24376
+ return {
24377
+ content: [
24378
+ {
24379
+ type: "text",
24380
+ text: JSON.stringify(
24381
+ {
24382
+ checkpoint: null,
24383
+ task: standaloneRes.data[0],
24384
+ is_standalone: true
24385
+ },
24386
+ null,
24387
+ 2
24388
+ )
24389
+ }
24390
+ ]
24391
+ };
24392
+ }
24090
24393
  return {
24091
24394
  content: [
24092
24395
  {
24093
24396
  type: "text",
24094
- text: "No active checkpoint found for this repo."
24397
+ text: "No active checkpoint or standalone task found for this repo."
24095
24398
  }
24096
24399
  ]
24097
24400
  };
@@ -24513,6 +24816,124 @@ function registerReadTools(server) {
24513
24816
  }
24514
24817
  }
24515
24818
  );
24819
+ server.registerTool(
24820
+ "get_task_templates",
24821
+ {
24822
+ description: "List task templates. Optionally filter by repo (returns repo-scoped + global templates) or by trigger_type.",
24823
+ inputSchema: {
24824
+ repo_id: external_exports.string().uuid().optional().describe("Filter by repo UUID (also includes global templates)"),
24825
+ trigger_type: external_exports.string().optional().describe(
24826
+ "Filter by trigger type (e.g. port_changed, repo_created, tech_stack_changed)"
24827
+ )
24828
+ }
24829
+ },
24830
+ async ({ repo_id, trigger_type }) => {
24831
+ try {
24832
+ const res = await apiGet(
24833
+ "/task-templates",
24834
+ {
24835
+ repo_id,
24836
+ trigger_type
24837
+ }
24838
+ );
24839
+ return {
24840
+ content: [
24841
+ { type: "text", text: JSON.stringify(res.data, null, 2) }
24842
+ ]
24843
+ };
24844
+ } catch (err) {
24845
+ return {
24846
+ content: [
24847
+ {
24848
+ type: "text",
24849
+ text: `Error: ${err instanceof Error ? err.message : String(err)}`
24850
+ }
24851
+ ],
24852
+ isError: true
24853
+ };
24854
+ }
24855
+ }
24856
+ );
24857
+ server.registerTool(
24858
+ "get_task_template",
24859
+ {
24860
+ description: "Get a single task template by ID.",
24861
+ inputSchema: {
24862
+ template_id: external_exports.string().uuid().describe("The task template UUID")
24863
+ }
24864
+ },
24865
+ async ({ template_id }) => {
24866
+ try {
24867
+ const res = await apiGet(
24868
+ `/task-templates/${template_id}`
24869
+ );
24870
+ if (!res.data) {
24871
+ return {
24872
+ content: [
24873
+ {
24874
+ type: "text",
24875
+ text: `Error: Task template ${template_id} not found`
24876
+ }
24877
+ ],
24878
+ isError: true
24879
+ };
24880
+ }
24881
+ return {
24882
+ content: [
24883
+ { type: "text", text: JSON.stringify(res.data, null, 2) }
24884
+ ]
24885
+ };
24886
+ } catch (err) {
24887
+ return {
24888
+ content: [
24889
+ {
24890
+ type: "text",
24891
+ text: `Error: ${err instanceof Error ? err.message : String(err)}`
24892
+ }
24893
+ ],
24894
+ isError: true
24895
+ };
24896
+ }
24897
+ }
24898
+ );
24899
+ server.registerTool(
24900
+ "list_tech_stack_sync_sessions",
24901
+ {
24902
+ description: "List recent tech_stack_sync_sessions for a repo. Each session represents a single POST to /api/repos/[id]/tech-stack and tracks added/removed/version-changed dependencies.",
24903
+ inputSchema: {
24904
+ repo_id: external_exports.string().uuid().describe("The repo UUID"),
24905
+ limit: external_exports.number().int().min(1).max(100).optional().describe("Max sessions to return (default 20)"),
24906
+ status: external_exports.enum(["in_progress", "completed", "failed"]).optional().describe("Filter by session status")
24907
+ }
24908
+ },
24909
+ async ({ repo_id, limit, status }) => {
24910
+ try {
24911
+ const res = await apiGet(
24912
+ "/tech-stack-sync-sessions",
24913
+ {
24914
+ repo_id,
24915
+ limit: String(limit ?? 20),
24916
+ status
24917
+ }
24918
+ );
24919
+ return {
24920
+ content: [
24921
+ { type: "text", text: JSON.stringify(res.data, null, 2) }
24922
+ ]
24923
+ };
24924
+ } catch (err) {
24925
+ return {
24926
+ content: [
24927
+ {
24928
+ type: "text",
24929
+ text: `Error: ${err instanceof Error ? err.message : String(err)}`
24930
+ }
24931
+ ],
24932
+ isError: true
24933
+ };
24934
+ }
24935
+ }
24936
+ );
24516
24937
  server.registerTool(
24517
24938
  "get_file_changes",
24518
24939
  {
@@ -24529,7 +24950,15 @@ function registerReadTools(server) {
24529
24950
  )
24530
24951
  }
24531
24952
  },
24532
- async ({ repo_id, checkpoint_id, task_id, round_id, file_path, source, aggregate }) => {
24953
+ async ({
24954
+ repo_id,
24955
+ checkpoint_id,
24956
+ task_id,
24957
+ round_id,
24958
+ file_path,
24959
+ source,
24960
+ aggregate
24961
+ }) => {
24533
24962
  try {
24534
24963
  const res = await apiGet(
24535
24964
  "/file-changes",
@@ -24837,6 +25266,27 @@ var init_promotion = __esm({
24837
25266
  });
24838
25267
 
24839
25268
  // src/tools/write.ts
25269
+ async function resolveTaskRepoId(taskId) {
25270
+ try {
25271
+ const taskRes = await apiGet(`/tasks/${taskId}`);
25272
+ const task = taskRes.data;
25273
+ if (task.checkpoint_id) {
25274
+ const checkpointRes = await apiGet(
25275
+ `/checkpoints/${task.checkpoint_id}`
25276
+ );
25277
+ return {
25278
+ repoId: checkpointRes.data.repo_id,
25279
+ checkpointId: task.checkpoint_id
25280
+ };
25281
+ }
25282
+ if (task.repo_id) {
25283
+ return { repoId: task.repo_id, checkpointId: null };
25284
+ }
25285
+ return null;
25286
+ } catch {
25287
+ return null;
25288
+ }
25289
+ }
24840
25290
  function registerWriteTools(server) {
24841
25291
  server.registerTool(
24842
25292
  "create_repo",
@@ -25171,6 +25621,12 @@ function registerWriteTools(server) {
25171
25621
  ),
25172
25622
  resources: external_exports.any().optional().describe(
25173
25623
  "Resources JSONB array [{url, description, type, added_by}]"
25624
+ ),
25625
+ deadline: external_exports.string().optional().describe(
25626
+ "Deadline date (ISO format, e.g. 2026-04-15). Used for standalone task priority ordering."
25627
+ ),
25628
+ branch_name: external_exports.string().optional().describe(
25629
+ "Git branch name for standalone tasks. Use 'development' for main branch, 'create_new' for auto-creating a feat branch, or a specific branch name."
25174
25630
  )
25175
25631
  }
25176
25632
  },
@@ -25187,7 +25643,9 @@ function registerWriteTools(server) {
25187
25643
  user_context,
25188
25644
  is_claude_written,
25189
25645
  context_development,
25190
- resources
25646
+ resources,
25647
+ deadline,
25648
+ branch_name
25191
25649
  }) => {
25192
25650
  try {
25193
25651
  const body = {
@@ -25207,6 +25665,8 @@ function registerWriteTools(server) {
25207
25665
  if (context_development !== void 0)
25208
25666
  body.context_development = context_development;
25209
25667
  if (resources !== void 0) body.resources = resources;
25668
+ if (deadline !== void 0) body.deadline = deadline;
25669
+ if (branch_name !== void 0) body.branch_name = branch_name;
25210
25670
  const res = await apiPost("/tasks", body);
25211
25671
  return {
25212
25672
  content: [
@@ -25349,25 +25809,21 @@ function registerWriteTools(server) {
25349
25809
  try {
25350
25810
  let hasUnapproved = false;
25351
25811
  let unapprovedCount = 0;
25352
- let resolvedRepoId = null;
25353
- try {
25354
- const taskRes = await apiGet(
25355
- `/tasks/${task_id}`
25356
- );
25357
- const checkpointRes = await apiGet(
25358
- `/checkpoints/${taskRes.data.checkpoint_id}`
25359
- );
25360
- resolvedRepoId = checkpointRes.data.repo_id;
25361
- const fileChangesRes = await apiGet("/file-changes", {
25362
- repo_id: resolvedRepoId,
25363
- task_id
25364
- });
25365
- const unapproved = (fileChangesRes.data ?? []).filter(
25366
- (f) => !f.user_approved
25367
- );
25368
- unapprovedCount = unapproved.length;
25369
- hasUnapproved = unapprovedCount > 0;
25370
- } catch {
25812
+ const resolved = await resolveTaskRepoId(task_id);
25813
+ const resolvedRepoId = resolved?.repoId ?? null;
25814
+ if (resolvedRepoId) {
25815
+ try {
25816
+ const fileChangesRes = await apiGet("/file-changes", {
25817
+ repo_id: resolvedRepoId,
25818
+ task_id
25819
+ });
25820
+ const unapproved = (fileChangesRes.data ?? []).filter(
25821
+ (f) => !f.user_approved
25822
+ );
25823
+ unapprovedCount = unapproved.length;
25824
+ hasUnapproved = unapprovedCount > 0;
25825
+ } catch {
25826
+ }
25371
25827
  }
25372
25828
  if (hasUnapproved) {
25373
25829
  return {
@@ -25570,28 +26026,25 @@ function registerWriteTools(server) {
25570
26026
  );
25571
26027
  if (files_changed && files_changed.length > 0) {
25572
26028
  try {
25573
- const taskRes = await apiGet(
25574
- `/tasks/${res.data.task_id}`
25575
- );
25576
- const checkpointRes = await apiGet(
25577
- `/checkpoints/${taskRes.data.checkpoint_id}`
25578
- );
25579
- await apiPatch("/file-changes", {
25580
- action: "replace_round_files",
25581
- round_id,
25582
- repo_id: checkpointRes.data.repo_id,
25583
- checkpoint_id: taskRes.data.checkpoint_id,
25584
- task_id: res.data.task_id,
25585
- source: "round",
25586
- files: files_changed.map(
25587
- (f) => ({
25588
- file_path: f.path,
25589
- action: f.action,
25590
- claude_approved: f.claude_approved ?? false,
25591
- user_approved: f.user_approved ?? false
25592
- })
25593
- )
25594
- });
26029
+ const resolved = await resolveTaskRepoId(res.data.task_id);
26030
+ if (resolved) {
26031
+ await apiPatch("/file-changes", {
26032
+ action: "replace_round_files",
26033
+ round_id,
26034
+ repo_id: resolved.repoId,
26035
+ checkpoint_id: resolved.checkpointId,
26036
+ task_id: res.data.task_id,
26037
+ source: "round",
26038
+ files: files_changed.map(
26039
+ (f) => ({
26040
+ file_path: f.path,
26041
+ action: f.action,
26042
+ claude_approved: f.claude_approved ?? false,
26043
+ user_approved: f.user_approved ?? false
26044
+ })
26045
+ )
26046
+ });
26047
+ }
25595
26048
  } catch {
25596
26049
  }
25597
26050
  }
@@ -25636,23 +26089,20 @@ function registerWriteTools(server) {
25636
26089
  );
25637
26090
  let unapprovedFiles = [];
25638
26091
  try {
25639
- const taskRes = await apiGet(
25640
- `/tasks/${res.data.task_id}`
25641
- );
25642
- const checkpointRes = await apiGet(
25643
- `/checkpoints/${taskRes.data.checkpoint_id}`
25644
- );
25645
- const repoId = checkpointRes.data.repo_id;
25646
- await apiPatch("/file-changes", {
25647
- action: "lock_round",
25648
- round_id,
25649
- repo_id: repoId
25650
- });
25651
- const fileChangesRes = await apiGet("/file-changes", {
25652
- repo_id: repoId,
25653
- round_id
25654
- });
25655
- unapprovedFiles = (fileChangesRes.data ?? []).filter((f) => !f.user_approved).map((f) => ({ file_path: f.file_path, action: f.action }));
26092
+ const resolved = await resolveTaskRepoId(res.data.task_id);
26093
+ if (resolved) {
26094
+ const repoId = resolved.repoId;
26095
+ await apiPatch("/file-changes", {
26096
+ action: "lock_round",
26097
+ round_id,
26098
+ repo_id: repoId
26099
+ });
26100
+ const fileChangesRes = await apiGet("/file-changes", {
26101
+ repo_id: repoId,
26102
+ round_id
26103
+ });
26104
+ unapprovedFiles = (fileChangesRes.data ?? []).filter((f) => !f.user_approved).map((f) => ({ file_path: f.file_path, action: f.action }));
26105
+ }
25656
26106
  } catch {
25657
26107
  }
25658
26108
  const result = {
@@ -26423,6 +26873,76 @@ ${dbOnlyFiles.length} file(s) exist in DB but were missing locally (recreated).
26423
26873
  }
26424
26874
  }
26425
26875
  );
26876
+ server.registerTool(
26877
+ "update_task_template",
26878
+ {
26879
+ description: "Update a task template (auto-trigger config, instructions, requirements, etc). Only provided fields are updated.",
26880
+ inputSchema: {
26881
+ template_id: external_exports.string().uuid().describe("The task template UUID"),
26882
+ name: external_exports.string().optional().describe("Template name"),
26883
+ description: external_exports.string().optional().describe("Template description (max 300 chars)"),
26884
+ requirements: external_exports.string().optional().describe(
26885
+ "Default requirements text for tasks created from this template"
26886
+ ),
26887
+ trigger_config: external_exports.any().optional().describe(
26888
+ "Trigger config JSONB (e.g. { conditions: { port_changed: true } })"
26889
+ ),
26890
+ instructions: external_exports.string().optional().describe(
26891
+ "Instructions shown to Claude when working on tasks from this template"
26892
+ ),
26893
+ priority: external_exports.number().int().optional().describe("Priority (lower = higher priority)"),
26894
+ auto_create: external_exports.boolean().optional().describe("If true, tasks are auto-created when the trigger fires")
26895
+ }
26896
+ },
26897
+ async ({
26898
+ template_id,
26899
+ name,
26900
+ description,
26901
+ requirements,
26902
+ trigger_config,
26903
+ instructions,
26904
+ priority,
26905
+ auto_create
26906
+ }) => {
26907
+ const body = {};
26908
+ if (name !== void 0) body.name = name;
26909
+ if (description !== void 0) body.description = description;
26910
+ if (requirements !== void 0) body.requirements = requirements;
26911
+ if (trigger_config !== void 0) body.trigger_config = trigger_config;
26912
+ if (instructions !== void 0) body.instructions = instructions;
26913
+ if (priority !== void 0) body.priority = priority;
26914
+ if (auto_create !== void 0) body.auto_create = auto_create;
26915
+ if (Object.keys(body).length === 0) {
26916
+ return {
26917
+ content: [
26918
+ { type: "text", text: "Error: No fields to update" }
26919
+ ],
26920
+ isError: true
26921
+ };
26922
+ }
26923
+ try {
26924
+ const res = await apiPatch(
26925
+ `/task-templates/${template_id}`,
26926
+ body
26927
+ );
26928
+ return {
26929
+ content: [
26930
+ { type: "text", text: JSON.stringify(res.data, null, 2) }
26931
+ ]
26932
+ };
26933
+ } catch (err) {
26934
+ return {
26935
+ content: [
26936
+ {
26937
+ type: "text",
26938
+ text: `Error: ${err instanceof Error ? err.message : String(err)}`
26939
+ }
26940
+ ],
26941
+ isError: true
26942
+ };
26943
+ }
26944
+ }
26945
+ );
26426
26946
  }
26427
26947
  var init_write = __esm({
26428
26948
  "src/tools/write.ts"() {
@@ -26634,6 +27154,7 @@ if (arg === "help" || arg === "--help" || arg === "-h") {
26634
27154
  --repo-id <uuid> Repository ID (or set via .codebyplan.json)
26635
27155
  --dry-run Preview changes without writing
26636
27156
  --force Skip confirmation and conflict prompts
27157
+ --fix Auto-create missing port allocations
26637
27158
 
26638
27159
  Learn more: https://codebyplan.com
26639
27160
  `);