@codebyplan/cli 3.3.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 +808 -254
  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.3.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,17 +1776,126 @@ 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
- import { readFile as readFile7, writeFile as writeFile3, mkdir as mkdir2, chmod as chmod2, unlink as unlink2 } from "node:fs/promises";
1888
+ import { createHash } from "node:crypto";
1889
+ import { readFile as readFile8, writeFile as writeFile3, mkdir as mkdir2, chmod as chmod2, unlink as unlink2 } from "node:fs/promises";
1755
1890
  import { join as join7, dirname as dirname2 } from "node:path";
1891
+ function contentHash(content) {
1892
+ return createHash("sha256").update(content).digest("hex");
1893
+ }
1756
1894
  async function runSync() {
1757
1895
  const flags = parseFlags(3);
1758
1896
  const dryRun = hasFlag("dry-run", 3);
1759
1897
  const force = hasFlag("force", 3);
1898
+ const fix = hasFlag("fix", 3);
1760
1899
  validateApiKey();
1761
1900
  const config2 = await resolveConfig(flags);
1762
1901
  const { repoId, projectPath } = config2;
@@ -1781,7 +1920,9 @@ async function runSync() {
1781
1920
  const lockStatus = await apiGet("/sync/lock", { repo_id: repoId });
1782
1921
  if (lockStatus.data.locked && lockStatus.data.lock) {
1783
1922
  const lock = lockStatus.data.lock;
1784
- 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
+ );
1785
1926
  console.log(` Expires: ${lock.expires_at}`);
1786
1927
  console.log(` Use --force to override, or wait for lock to expire.
1787
1928
  `);
@@ -1799,7 +1940,7 @@ async function runSync() {
1799
1940
  }
1800
1941
  }
1801
1942
  try {
1802
- await runSyncInner(repoId, projectPath, dryRun, force);
1943
+ await runSyncInner(repoId, projectPath, dryRun, force, fix);
1803
1944
  } finally {
1804
1945
  if (!dryRun) {
1805
1946
  try {
@@ -1809,7 +1950,7 @@ async function runSync() {
1809
1950
  }
1810
1951
  }
1811
1952
  }
1812
- async function runSyncInner(repoId, projectPath, dryRun, force) {
1953
+ async function runSyncInner(repoId, projectPath, dryRun, force, fix = false) {
1813
1954
  console.log(" Reading local and remote state...");
1814
1955
  const claudeDir = join7(projectPath, ".claude");
1815
1956
  let localFiles = /* @__PURE__ */ new Map();
@@ -1817,20 +1958,43 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
1817
1958
  localFiles = await scanLocalFiles(claudeDir, projectPath);
1818
1959
  } catch {
1819
1960
  }
1820
- const [defaultsRes, repoSyncRes, repoRes, syncStateRes] = await Promise.all([
1961
+ const [defaultsRes, repoSyncRes, repoRes, syncStateRes, fileReposRes] = await Promise.all([
1821
1962
  apiGet("/sync/defaults"),
1822
1963
  apiGet("/sync/files", { repo_id: repoId }),
1823
1964
  apiGet(`/repos/${repoId}`),
1824
- apiGet("/sync/state", { repo_id: repoId })
1965
+ apiGet("/sync/state", {
1966
+ repo_id: repoId
1967
+ }),
1968
+ apiGet("/sync/file-repos", {
1969
+ repo_id: repoId
1970
+ })
1825
1971
  ]);
1826
1972
  const syncStartTime = Date.now();
1827
1973
  const repoData = repoRes.data;
1828
1974
  const remoteDefaults = flattenSyncData(defaultsRes.data);
1829
1975
  const remoteRepoFiles = flattenSyncData(repoSyncRes.data);
1830
1976
  const syncState = syncStateRes.data;
1977
+ const fileRepoHashes = /* @__PURE__ */ new Map();
1978
+ const fileRepoByClaudeFileId = /* @__PURE__ */ new Map();
1979
+ for (const entry of fileReposRes.data ?? []) {
1980
+ if (entry.claude_files) {
1981
+ const key = compositeKey(
1982
+ entry.claude_files.type,
1983
+ entry.claude_files.name,
1984
+ entry.claude_files.category
1985
+ );
1986
+ fileRepoHashes.set(key, entry.last_synced_content_hash);
1987
+ }
1988
+ fileRepoByClaudeFileId.set(
1989
+ entry.claude_file_id,
1990
+ entry.last_synced_content_hash
1991
+ );
1992
+ }
1831
1993
  const remoteFiles = new Map([...remoteDefaults, ...remoteRepoFiles]);
1832
- console.log(` Local: ${localFiles.size} files, Remote: ${remoteFiles.size} files
1833
- `);
1994
+ console.log(
1995
+ ` Local: ${localFiles.size} files, Remote: ${remoteFiles.size} files
1996
+ `
1997
+ );
1834
1998
  const plan = [];
1835
1999
  const allKeys = /* @__PURE__ */ new Set([...localFiles.keys(), ...remoteFiles.keys()]);
1836
2000
  for (const key of allKeys) {
@@ -1845,7 +2009,11 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
1845
2009
  localContent: local.content,
1846
2010
  remoteContent: null,
1847
2011
  pushContent: reverseSubstituteVariables(local.content, repoData),
1848
- 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
+ }),
1849
2017
  type: local.type,
1850
2018
  name: local.name,
1851
2019
  category: local.category,
@@ -1854,9 +2022,8 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
1854
2022
  });
1855
2023
  } else if (!local && remote) {
1856
2024
  const resolvedContent = substituteVariables(remote.content, repoData);
1857
- const isDefaultOnly = remoteDefaults.has(key) && !remoteRepoFiles.has(key);
1858
- const hasSyncedBefore = syncState?.last_synced_at != null;
1859
- const recommended = !isDefaultOnly && hasSyncedBefore ? "delete" : "pull";
2025
+ const hadSyncedThisFile = remote.id ? fileRepoByClaudeFileId.has(remote.id) : fileRepoHashes.has(key);
2026
+ const recommended = hadSyncedThisFile ? "delete" : "pull";
1860
2027
  plan.push({
1861
2028
  key,
1862
2029
  displayPath: `${remote.type}/${remote.category ? remote.category + "/" : ""}${remote.name}`,
@@ -1877,16 +2044,24 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
1877
2044
  if (local.content === resolvedRemote) {
1878
2045
  continue;
1879
2046
  }
1880
- const lastSyncedAt = syncState?.last_synced_at;
1881
- const remoteUpdatedAt = remote.updated_at;
1882
- const remoteChanged = remoteUpdatedAt && lastSyncedAt ? new Date(remoteUpdatedAt) > new Date(lastSyncedAt) : true;
2047
+ const localHash = contentHash(local.content);
2048
+ const lastSyncedHash = fileRepoHashes.get(key) ?? null;
2049
+ const localChanged = lastSyncedHash ? localHash !== lastSyncedHash : true;
1883
2050
  let action;
1884
- if (remoteChanged && force) {
2051
+ if (force) {
1885
2052
  action = "pull";
1886
- } else if (!remoteChanged) {
1887
- action = "push";
1888
- } else {
2053
+ } else if (!localChanged) {
2054
+ action = "pull";
2055
+ } else if (lastSyncedHash === null) {
1889
2056
  action = "conflict";
2057
+ } else {
2058
+ const remoteDbHash = remote.content_hash ?? null;
2059
+ const remoteChanged = remoteDbHash ? remoteDbHash !== lastSyncedHash : true;
2060
+ if (remoteChanged) {
2061
+ action = "conflict";
2062
+ } else {
2063
+ action = "push";
2064
+ }
1890
2065
  }
1891
2066
  plan.push({
1892
2067
  key,
@@ -1909,8 +2084,12 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
1909
2084
  const pushes = plan.filter((p) => p.action === "push");
1910
2085
  const conflicts = plan.filter((p) => p.action === "conflict");
1911
2086
  const contentPulls = pulls.filter((p) => p.localContent !== null);
1912
- const dbOnlyPull = plan.filter((p) => p.localContent === null && p.action === "pull");
1913
- 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
+ );
1914
2093
  if (contentPulls.length > 0) {
1915
2094
  console.log(` Pull (DB \u2192 local): ${contentPulls.length}`);
1916
2095
  for (const p of contentPulls) console.log(` \u2193 ${p.displayPath}`);
@@ -1925,8 +2104,10 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
1925
2104
  for (const p of dbOnlyPull) console.log(` \u2193 ${p.displayPath}`);
1926
2105
  }
1927
2106
  if (dbOnlyDelete.length > 0) {
1928
- console.log(`
1929
- DB-only (previously synced, will delete): ${dbOnlyDelete.length}`);
2107
+ console.log(
2108
+ `
2109
+ DB-only (previously synced, will delete): ${dbOnlyDelete.length}`
2110
+ );
1930
2111
  for (const p of dbOnlyDelete) console.log(` \u2715 ${p.displayPath}`);
1931
2112
  }
1932
2113
  if (conflicts.length > 0) {
@@ -2043,8 +2224,10 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
2043
2224
  }
2044
2225
  }
2045
2226
  if (stored > 0) {
2046
- console.log(`
2047
- ${stored} conflict(s) stored in DB for later resolution.`);
2227
+ console.log(
2228
+ `
2229
+ ${stored} conflict(s) stored in DB for later resolution.`
2230
+ );
2048
2231
  }
2049
2232
  }
2050
2233
  const syncDurationMs = Date.now() - syncStartTime;
@@ -2062,11 +2245,22 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
2062
2245
  });
2063
2246
  const syncTimestamp = (/* @__PURE__ */ new Date()).toISOString();
2064
2247
  const fileRepoUpdates = [];
2065
- for (const p of [...toPull, ...toPush]) {
2066
- if (p.claudeFileId) {
2248
+ for (const p of toPull) {
2249
+ if (p.claudeFileId && p.remoteContent !== null) {
2250
+ fileRepoUpdates.push({
2251
+ claude_file_id: p.claudeFileId,
2252
+ last_synced_at: syncTimestamp,
2253
+ last_synced_content_hash: contentHash(p.remoteContent),
2254
+ sync_status: "synced"
2255
+ });
2256
+ }
2257
+ }
2258
+ for (const p of toPush) {
2259
+ if (p.claudeFileId && p.localContent !== null) {
2067
2260
  fileRepoUpdates.push({
2068
2261
  claude_file_id: p.claudeFileId,
2069
2262
  last_synced_at: syncTimestamp,
2263
+ last_synced_content_hash: contentHash(p.localContent),
2070
2264
  sync_status: "synced"
2071
2265
  });
2072
2266
  }
@@ -2089,11 +2283,19 @@ async function runSyncInner(repoId, projectPath, dryRun, force) {
2089
2283
  console.log("\n (dry-run \u2014 no changes)");
2090
2284
  }
2091
2285
  console.log("\n Settings sync...");
2092
- await syncSettings(claudeDir, projectPath, defaultsRes.data, repoData, dryRun);
2286
+ await syncSettings(
2287
+ claudeDir,
2288
+ projectPath,
2289
+ defaultsRes.data,
2290
+ repoData,
2291
+ dryRun
2292
+ );
2093
2293
  console.log(" Config sync...");
2094
2294
  await syncConfig(repoId, projectPath, dryRun);
2095
2295
  console.log(" Tech stack...");
2096
2296
  await syncTechStack(repoId, projectPath, dryRun);
2297
+ console.log(" Port verification...");
2298
+ await syncPortVerification(repoId, projectPath, dryRun, fix);
2097
2299
  console.log("\n Sync complete.\n");
2098
2300
  }
2099
2301
  async function syncSettings(claudeDir, projectPath, syncData, repoData, dryRun) {
@@ -2101,20 +2303,27 @@ async function syncSettings(claudeDir, projectPath, syncData, repoData, dryRun)
2101
2303
  const globalSettingsFiles = syncData.global_settings ?? [];
2102
2304
  let globalSettings = {};
2103
2305
  for (const gf of globalSettingsFiles) {
2104
- const parsed = JSON.parse(substituteVariables(gf.content, repoData));
2306
+ const parsed = JSON.parse(
2307
+ substituteVariables(gf.content, repoData)
2308
+ );
2105
2309
  globalSettings = { ...globalSettings, ...parsed };
2106
2310
  }
2107
2311
  const repoSettingsFiles = syncData.settings ?? [];
2108
2312
  let repoSettings = {};
2109
2313
  for (const rf of repoSettingsFiles) {
2110
- repoSettings = JSON.parse(substituteVariables(rf.content, repoData));
2314
+ repoSettings = JSON.parse(
2315
+ substituteVariables(rf.content, repoData)
2316
+ );
2111
2317
  }
2112
- const combinedTemplate = mergeGlobalAndRepoSettings(globalSettings, repoSettings);
2318
+ const combinedTemplate = mergeGlobalAndRepoSettings(
2319
+ globalSettings,
2320
+ repoSettings
2321
+ );
2113
2322
  const hooksDir = join7(projectPath, ".claude", "hooks");
2114
2323
  const discovered = await discoverHooks(hooksDir);
2115
2324
  let localSettings = {};
2116
2325
  try {
2117
- const raw = await readFile7(settingsPath, "utf-8");
2326
+ const raw = await readFile8(settingsPath, "utf-8");
2118
2327
  localSettings = JSON.parse(raw);
2119
2328
  } catch {
2120
2329
  }
@@ -2129,7 +2338,7 @@ async function syncSettings(claudeDir, projectPath, syncData, repoData, dryRun)
2129
2338
  const mergedContent = JSON.stringify(merged, null, 2) + "\n";
2130
2339
  let currentContent = "";
2131
2340
  try {
2132
- currentContent = await readFile7(settingsPath, "utf-8");
2341
+ currentContent = await readFile8(settingsPath, "utf-8");
2133
2342
  } catch {
2134
2343
  }
2135
2344
  if (currentContent === mergedContent) {
@@ -2148,7 +2357,7 @@ async function syncConfig(repoId, projectPath, dryRun) {
2148
2357
  const configPath = join7(projectPath, ".codebyplan.json");
2149
2358
  let currentConfig = {};
2150
2359
  try {
2151
- const raw = await readFile7(configPath, "utf-8");
2360
+ const raw = await readFile8(configPath, "utf-8");
2152
2361
  currentConfig = JSON.parse(raw);
2153
2362
  } catch {
2154
2363
  currentConfig = { repo_id: repoId };
@@ -2157,10 +2366,35 @@ async function syncConfig(repoId, projectPath, dryRun) {
2157
2366
  const repo = repoRes.data;
2158
2367
  let portAllocations = [];
2159
2368
  try {
2160
- const portsRes = await apiGet(`/port-allocations`, { repo_id: repoId });
2369
+ const portsRes = await apiGet(
2370
+ `/port-allocations`,
2371
+ { repo_id: repoId }
2372
+ );
2161
2373
  const allAllocations = portsRes.data ?? [];
2162
2374
  const worktreeId2 = currentConfig.worktree_id;
2163
- 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
+ });
2164
2398
  } catch {
2165
2399
  }
2166
2400
  const worktreeId = currentConfig.worktree_id;
@@ -2195,14 +2429,15 @@ async function syncTechStack(repoId, projectPath, dryRun) {
2195
2429
  return;
2196
2430
  }
2197
2431
  const sourcePaths = new Set(dependencies.map((d) => d.source_path));
2198
- 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
+ );
2199
2435
  if (!dryRun) {
2200
- const result = await apiPost(
2201
- `/repos/${repoId}/tech-stack`,
2202
- { dependencies }
2203
- );
2436
+ const result = await apiPost(`/repos/${repoId}/tech-stack`, { dependencies });
2204
2437
  if (result.data.stale_removed > 0) {
2205
- console.log(` ${result.data.stale_removed} stale dependencies removed`);
2438
+ console.log(
2439
+ ` ${result.data.stale_removed} stale dependencies removed`
2440
+ );
2206
2441
  }
2207
2442
  }
2208
2443
  const detected = await detectTechStack(projectPath);
@@ -2221,6 +2456,71 @@ async function syncTechStack(repoId, projectPath, dryRun) {
2221
2456
  console.log(" Tech stack detection skipped.");
2222
2457
  }
2223
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
+ }
2224
2524
  function groupByType(items) {
2225
2525
  const groups = /* @__PURE__ */ new Map();
2226
2526
  const typeLabels = {
@@ -2256,14 +2556,16 @@ function getLocalFilePath(claudeDir, projectPath, remote) {
2256
2556
  const cfg = typeConfig2[remote.type];
2257
2557
  if (!cfg) return join7(claudeDir, remote.name);
2258
2558
  const typeDir = remote.type === "command" ? join7(claudeDir, cfg.dir, "cbp") : join7(claudeDir, cfg.dir);
2259
- if (cfg.subfolder) return join7(typeDir, remote.name, `${cfg.subfolder}${cfg.ext}`);
2260
- 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}`);
2261
2563
  if (remote.type === "template") return join7(typeDir, remote.name);
2262
2564
  return join7(typeDir, `${remote.name}${cfg.ext}`);
2263
2565
  }
2264
2566
  function getSyncVersion() {
2265
2567
  try {
2266
- return "3.3.0";
2568
+ return "3.5.0";
2267
2569
  } catch {
2268
2570
  return "unknown";
2269
2571
  }
@@ -2289,7 +2591,8 @@ function flattenSyncData(data) {
2289
2591
  name: file.name,
2290
2592
  content: file.content,
2291
2593
  category: file.category,
2292
- updated_at: file.updated_at
2594
+ updated_at: file.updated_at,
2595
+ content_hash: file.content_hash
2293
2596
  });
2294
2597
  }
2295
2598
  }
@@ -2306,6 +2609,7 @@ var init_sync = __esm({
2306
2609
  init_tech_detect();
2307
2610
  init_settings_merge();
2308
2611
  init_hook_registry();
2612
+ init_port_verify();
2309
2613
  }
2310
2614
  });
2311
2615
 
@@ -15486,9 +15790,9 @@ var init_protocol = __esm({
15486
15790
  }
15487
15791
  });
15488
15792
 
15489
- // ../../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
15490
15794
  var require_code = __commonJS({
15491
- "../../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) {
15492
15796
  "use strict";
15493
15797
  Object.defineProperty(exports, "__esModule", { value: true });
15494
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;
@@ -15640,9 +15944,9 @@ var require_code = __commonJS({
15640
15944
  }
15641
15945
  });
15642
15946
 
15643
- // ../../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
15644
15948
  var require_scope = __commonJS({
15645
- "../../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) {
15646
15950
  "use strict";
15647
15951
  Object.defineProperty(exports, "__esModule", { value: true });
15648
15952
  exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
@@ -15785,9 +16089,9 @@ var require_scope = __commonJS({
15785
16089
  }
15786
16090
  });
15787
16091
 
15788
- // ../../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
15789
16093
  var require_codegen = __commonJS({
15790
- "../../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) {
15791
16095
  "use strict";
15792
16096
  Object.defineProperty(exports, "__esModule", { value: true });
15793
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;
@@ -16505,9 +16809,9 @@ var require_codegen = __commonJS({
16505
16809
  }
16506
16810
  });
16507
16811
 
16508
- // ../../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
16509
16813
  var require_util = __commonJS({
16510
- "../../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) {
16511
16815
  "use strict";
16512
16816
  Object.defineProperty(exports, "__esModule", { value: true });
16513
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;
@@ -16672,9 +16976,9 @@ var require_util = __commonJS({
16672
16976
  }
16673
16977
  });
16674
16978
 
16675
- // ../../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
16676
16980
  var require_names = __commonJS({
16677
- "../../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) {
16678
16982
  "use strict";
16679
16983
  Object.defineProperty(exports, "__esModule", { value: true });
16680
16984
  var codegen_1 = require_codegen();
@@ -16711,9 +17015,9 @@ var require_names = __commonJS({
16711
17015
  }
16712
17016
  });
16713
17017
 
16714
- // ../../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
16715
17019
  var require_errors = __commonJS({
16716
- "../../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) {
16717
17021
  "use strict";
16718
17022
  Object.defineProperty(exports, "__esModule", { value: true });
16719
17023
  exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0;
@@ -16833,9 +17137,9 @@ var require_errors = __commonJS({
16833
17137
  }
16834
17138
  });
16835
17139
 
16836
- // ../../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
16837
17141
  var require_boolSchema = __commonJS({
16838
- "../../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) {
16839
17143
  "use strict";
16840
17144
  Object.defineProperty(exports, "__esModule", { value: true });
16841
17145
  exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0;
@@ -16884,9 +17188,9 @@ var require_boolSchema = __commonJS({
16884
17188
  }
16885
17189
  });
16886
17190
 
16887
- // ../../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
16888
17192
  var require_rules = __commonJS({
16889
- "../../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) {
16890
17194
  "use strict";
16891
17195
  Object.defineProperty(exports, "__esModule", { value: true });
16892
17196
  exports.getRules = exports.isJSONType = void 0;
@@ -16915,9 +17219,9 @@ var require_rules = __commonJS({
16915
17219
  }
16916
17220
  });
16917
17221
 
16918
- // ../../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
16919
17223
  var require_applicability = __commonJS({
16920
- "../../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) {
16921
17225
  "use strict";
16922
17226
  Object.defineProperty(exports, "__esModule", { value: true });
16923
17227
  exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = void 0;
@@ -16938,9 +17242,9 @@ var require_applicability = __commonJS({
16938
17242
  }
16939
17243
  });
16940
17244
 
16941
- // ../../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
16942
17246
  var require_dataType = __commonJS({
16943
- "../../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) {
16944
17248
  "use strict";
16945
17249
  Object.defineProperty(exports, "__esModule", { value: true });
16946
17250
  exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0;
@@ -17122,9 +17426,9 @@ var require_dataType = __commonJS({
17122
17426
  }
17123
17427
  });
17124
17428
 
17125
- // ../../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
17126
17430
  var require_defaults = __commonJS({
17127
- "../../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) {
17128
17432
  "use strict";
17129
17433
  Object.defineProperty(exports, "__esModule", { value: true });
17130
17434
  exports.assignDefaults = void 0;
@@ -17159,9 +17463,9 @@ var require_defaults = __commonJS({
17159
17463
  }
17160
17464
  });
17161
17465
 
17162
- // ../../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
17163
17467
  var require_code2 = __commonJS({
17164
- "../../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) {
17165
17469
  "use strict";
17166
17470
  Object.defineProperty(exports, "__esModule", { value: true });
17167
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;
@@ -17292,9 +17596,9 @@ var require_code2 = __commonJS({
17292
17596
  }
17293
17597
  });
17294
17598
 
17295
- // ../../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
17296
17600
  var require_keyword = __commonJS({
17297
- "../../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) {
17298
17602
  "use strict";
17299
17603
  Object.defineProperty(exports, "__esModule", { value: true });
17300
17604
  exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = void 0;
@@ -17410,9 +17714,9 @@ var require_keyword = __commonJS({
17410
17714
  }
17411
17715
  });
17412
17716
 
17413
- // ../../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
17414
17718
  var require_subschema = __commonJS({
17415
- "../../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) {
17416
17720
  "use strict";
17417
17721
  Object.defineProperty(exports, "__esModule", { value: true });
17418
17722
  exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = void 0;
@@ -17616,9 +17920,9 @@ var require_json_schema_traverse = __commonJS({
17616
17920
  }
17617
17921
  });
17618
17922
 
17619
- // ../../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
17620
17924
  var require_resolve = __commonJS({
17621
- "../../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) {
17622
17926
  "use strict";
17623
17927
  Object.defineProperty(exports, "__esModule", { value: true });
17624
17928
  exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = void 0;
@@ -17772,9 +18076,9 @@ var require_resolve = __commonJS({
17772
18076
  }
17773
18077
  });
17774
18078
 
17775
- // ../../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
17776
18080
  var require_validate = __commonJS({
17777
- "../../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) {
17778
18082
  "use strict";
17779
18083
  Object.defineProperty(exports, "__esModule", { value: true });
17780
18084
  exports.getData = exports.KeywordCxt = exports.validateFunctionCode = void 0;
@@ -18280,9 +18584,9 @@ var require_validate = __commonJS({
18280
18584
  }
18281
18585
  });
18282
18586
 
18283
- // ../../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
18284
18588
  var require_validation_error = __commonJS({
18285
- "../../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) {
18286
18590
  "use strict";
18287
18591
  Object.defineProperty(exports, "__esModule", { value: true });
18288
18592
  var ValidationError = class extends Error {
@@ -18296,9 +18600,9 @@ var require_validation_error = __commonJS({
18296
18600
  }
18297
18601
  });
18298
18602
 
18299
- // ../../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
18300
18604
  var require_ref_error = __commonJS({
18301
- "../../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) {
18302
18606
  "use strict";
18303
18607
  Object.defineProperty(exports, "__esModule", { value: true });
18304
18608
  var resolve_1 = require_resolve();
@@ -18313,9 +18617,9 @@ var require_ref_error = __commonJS({
18313
18617
  }
18314
18618
  });
18315
18619
 
18316
- // ../../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
18317
18621
  var require_compile = __commonJS({
18318
- "../../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) {
18319
18623
  "use strict";
18320
18624
  Object.defineProperty(exports, "__esModule", { value: true });
18321
18625
  exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = void 0;
@@ -18537,9 +18841,9 @@ var require_compile = __commonJS({
18537
18841
  }
18538
18842
  });
18539
18843
 
18540
- // ../../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
18541
18845
  var require_data = __commonJS({
18542
- "../../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) {
18543
18847
  module.exports = {
18544
18848
  $id: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
18545
18849
  description: "Meta-schema for $data reference (JSON AnySchema extension proposal)",
@@ -19278,9 +19582,9 @@ var require_fast_uri = __commonJS({
19278
19582
  }
19279
19583
  });
19280
19584
 
19281
- // ../../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
19282
19586
  var require_uri = __commonJS({
19283
- "../../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) {
19284
19588
  "use strict";
19285
19589
  Object.defineProperty(exports, "__esModule", { value: true });
19286
19590
  var uri = require_fast_uri();
@@ -19289,9 +19593,9 @@ var require_uri = __commonJS({
19289
19593
  }
19290
19594
  });
19291
19595
 
19292
- // ../../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
19293
19597
  var require_core = __commonJS({
19294
- "../../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) {
19295
19599
  "use strict";
19296
19600
  Object.defineProperty(exports, "__esModule", { value: true });
19297
19601
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
@@ -19900,9 +20204,9 @@ var require_core = __commonJS({
19900
20204
  }
19901
20205
  });
19902
20206
 
19903
- // ../../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
19904
20208
  var require_id = __commonJS({
19905
- "../../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) {
19906
20210
  "use strict";
19907
20211
  Object.defineProperty(exports, "__esModule", { value: true });
19908
20212
  var def = {
@@ -19915,9 +20219,9 @@ var require_id = __commonJS({
19915
20219
  }
19916
20220
  });
19917
20221
 
19918
- // ../../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
19919
20223
  var require_ref = __commonJS({
19920
- "../../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) {
19921
20225
  "use strict";
19922
20226
  Object.defineProperty(exports, "__esModule", { value: true });
19923
20227
  exports.callRef = exports.getValidate = void 0;
@@ -20037,9 +20341,9 @@ var require_ref = __commonJS({
20037
20341
  }
20038
20342
  });
20039
20343
 
20040
- // ../../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
20041
20345
  var require_core2 = __commonJS({
20042
- "../../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) {
20043
20347
  "use strict";
20044
20348
  Object.defineProperty(exports, "__esModule", { value: true });
20045
20349
  var id_1 = require_id();
@@ -20058,9 +20362,9 @@ var require_core2 = __commonJS({
20058
20362
  }
20059
20363
  });
20060
20364
 
20061
- // ../../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
20062
20366
  var require_limitNumber = __commonJS({
20063
- "../../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) {
20064
20368
  "use strict";
20065
20369
  Object.defineProperty(exports, "__esModule", { value: true });
20066
20370
  var codegen_1 = require_codegen();
@@ -20090,9 +20394,9 @@ var require_limitNumber = __commonJS({
20090
20394
  }
20091
20395
  });
20092
20396
 
20093
- // ../../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
20094
20398
  var require_multipleOf = __commonJS({
20095
- "../../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) {
20096
20400
  "use strict";
20097
20401
  Object.defineProperty(exports, "__esModule", { value: true });
20098
20402
  var codegen_1 = require_codegen();
@@ -20118,9 +20422,9 @@ var require_multipleOf = __commonJS({
20118
20422
  }
20119
20423
  });
20120
20424
 
20121
- // ../../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
20122
20426
  var require_ucs2length = __commonJS({
20123
- "../../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) {
20124
20428
  "use strict";
20125
20429
  Object.defineProperty(exports, "__esModule", { value: true });
20126
20430
  function ucs2length(str) {
@@ -20144,9 +20448,9 @@ var require_ucs2length = __commonJS({
20144
20448
  }
20145
20449
  });
20146
20450
 
20147
- // ../../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
20148
20452
  var require_limitLength = __commonJS({
20149
- "../../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) {
20150
20454
  "use strict";
20151
20455
  Object.defineProperty(exports, "__esModule", { value: true });
20152
20456
  var codegen_1 = require_codegen();
@@ -20176,12 +20480,13 @@ var require_limitLength = __commonJS({
20176
20480
  }
20177
20481
  });
20178
20482
 
20179
- // ../../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
20180
20484
  var require_pattern = __commonJS({
20181
- "../../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) {
20182
20486
  "use strict";
20183
20487
  Object.defineProperty(exports, "__esModule", { value: true });
20184
20488
  var code_1 = require_code2();
20489
+ var util_1 = require_util();
20185
20490
  var codegen_1 = require_codegen();
20186
20491
  var error2 = {
20187
20492
  message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
@@ -20194,19 +20499,27 @@ var require_pattern = __commonJS({
20194
20499
  $data: true,
20195
20500
  error: error2,
20196
20501
  code(cxt) {
20197
- const { data, $data, schema, schemaCode, it } = cxt;
20502
+ const { gen, data, $data, schema, schemaCode, it } = cxt;
20198
20503
  const u = it.opts.unicodeRegExp ? "u" : "";
20199
- const regExp = $data ? (0, codegen_1._)`(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema);
20200
- 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
+ }
20201
20514
  }
20202
20515
  };
20203
20516
  exports.default = def;
20204
20517
  }
20205
20518
  });
20206
20519
 
20207
- // ../../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
20208
20521
  var require_limitProperties = __commonJS({
20209
- "../../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) {
20210
20523
  "use strict";
20211
20524
  Object.defineProperty(exports, "__esModule", { value: true });
20212
20525
  var codegen_1 = require_codegen();
@@ -20233,9 +20546,9 @@ var require_limitProperties = __commonJS({
20233
20546
  }
20234
20547
  });
20235
20548
 
20236
- // ../../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
20237
20550
  var require_required = __commonJS({
20238
- "../../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) {
20239
20552
  "use strict";
20240
20553
  Object.defineProperty(exports, "__esModule", { value: true });
20241
20554
  var code_1 = require_code2();
@@ -20315,9 +20628,9 @@ var require_required = __commonJS({
20315
20628
  }
20316
20629
  });
20317
20630
 
20318
- // ../../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
20319
20632
  var require_limitItems = __commonJS({
20320
- "../../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) {
20321
20634
  "use strict";
20322
20635
  Object.defineProperty(exports, "__esModule", { value: true });
20323
20636
  var codegen_1 = require_codegen();
@@ -20344,9 +20657,9 @@ var require_limitItems = __commonJS({
20344
20657
  }
20345
20658
  });
20346
20659
 
20347
- // ../../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
20348
20661
  var require_equal = __commonJS({
20349
- "../../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) {
20350
20663
  "use strict";
20351
20664
  Object.defineProperty(exports, "__esModule", { value: true });
20352
20665
  var equal = require_fast_deep_equal();
@@ -20355,9 +20668,9 @@ var require_equal = __commonJS({
20355
20668
  }
20356
20669
  });
20357
20670
 
20358
- // ../../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
20359
20672
  var require_uniqueItems = __commonJS({
20360
- "../../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) {
20361
20674
  "use strict";
20362
20675
  Object.defineProperty(exports, "__esModule", { value: true });
20363
20676
  var dataType_1 = require_dataType();
@@ -20422,9 +20735,9 @@ var require_uniqueItems = __commonJS({
20422
20735
  }
20423
20736
  });
20424
20737
 
20425
- // ../../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
20426
20739
  var require_const = __commonJS({
20427
- "../../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) {
20428
20741
  "use strict";
20429
20742
  Object.defineProperty(exports, "__esModule", { value: true });
20430
20743
  var codegen_1 = require_codegen();
@@ -20451,9 +20764,9 @@ var require_const = __commonJS({
20451
20764
  }
20452
20765
  });
20453
20766
 
20454
- // ../../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
20455
20768
  var require_enum = __commonJS({
20456
- "../../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) {
20457
20770
  "use strict";
20458
20771
  Object.defineProperty(exports, "__esModule", { value: true });
20459
20772
  var codegen_1 = require_codegen();
@@ -20500,9 +20813,9 @@ var require_enum = __commonJS({
20500
20813
  }
20501
20814
  });
20502
20815
 
20503
- // ../../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
20504
20817
  var require_validation = __commonJS({
20505
- "../../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) {
20506
20819
  "use strict";
20507
20820
  Object.defineProperty(exports, "__esModule", { value: true });
20508
20821
  var limitNumber_1 = require_limitNumber();
@@ -20538,9 +20851,9 @@ var require_validation = __commonJS({
20538
20851
  }
20539
20852
  });
20540
20853
 
20541
- // ../../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
20542
20855
  var require_additionalItems = __commonJS({
20543
- "../../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) {
20544
20857
  "use strict";
20545
20858
  Object.defineProperty(exports, "__esModule", { value: true });
20546
20859
  exports.validateAdditionalItems = void 0;
@@ -20591,9 +20904,9 @@ var require_additionalItems = __commonJS({
20591
20904
  }
20592
20905
  });
20593
20906
 
20594
- // ../../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
20595
20908
  var require_items = __commonJS({
20596
- "../../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) {
20597
20910
  "use strict";
20598
20911
  Object.defineProperty(exports, "__esModule", { value: true });
20599
20912
  exports.validateTuple = void 0;
@@ -20648,9 +20961,9 @@ var require_items = __commonJS({
20648
20961
  }
20649
20962
  });
20650
20963
 
20651
- // ../../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
20652
20965
  var require_prefixItems = __commonJS({
20653
- "../../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) {
20654
20967
  "use strict";
20655
20968
  Object.defineProperty(exports, "__esModule", { value: true });
20656
20969
  var items_1 = require_items();
@@ -20665,9 +20978,9 @@ var require_prefixItems = __commonJS({
20665
20978
  }
20666
20979
  });
20667
20980
 
20668
- // ../../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
20669
20982
  var require_items2020 = __commonJS({
20670
- "../../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) {
20671
20984
  "use strict";
20672
20985
  Object.defineProperty(exports, "__esModule", { value: true });
20673
20986
  var codegen_1 = require_codegen();
@@ -20700,9 +21013,9 @@ var require_items2020 = __commonJS({
20700
21013
  }
20701
21014
  });
20702
21015
 
20703
- // ../../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
20704
21017
  var require_contains = __commonJS({
20705
- "../../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) {
20706
21019
  "use strict";
20707
21020
  Object.defineProperty(exports, "__esModule", { value: true });
20708
21021
  var codegen_1 = require_codegen();
@@ -20794,9 +21107,9 @@ var require_contains = __commonJS({
20794
21107
  }
20795
21108
  });
20796
21109
 
20797
- // ../../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
20798
21111
  var require_dependencies = __commonJS({
20799
- "../../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) {
20800
21113
  "use strict";
20801
21114
  Object.defineProperty(exports, "__esModule", { value: true });
20802
21115
  exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0;
@@ -20888,9 +21201,9 @@ var require_dependencies = __commonJS({
20888
21201
  }
20889
21202
  });
20890
21203
 
20891
- // ../../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
20892
21205
  var require_propertyNames = __commonJS({
20893
- "../../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) {
20894
21207
  "use strict";
20895
21208
  Object.defineProperty(exports, "__esModule", { value: true });
20896
21209
  var codegen_1 = require_codegen();
@@ -20931,9 +21244,9 @@ var require_propertyNames = __commonJS({
20931
21244
  }
20932
21245
  });
20933
21246
 
20934
- // ../../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
20935
21248
  var require_additionalProperties = __commonJS({
20936
- "../../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) {
20937
21250
  "use strict";
20938
21251
  Object.defineProperty(exports, "__esModule", { value: true });
20939
21252
  var code_1 = require_code2();
@@ -21037,9 +21350,9 @@ var require_additionalProperties = __commonJS({
21037
21350
  }
21038
21351
  });
21039
21352
 
21040
- // ../../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
21041
21354
  var require_properties = __commonJS({
21042
- "../../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) {
21043
21356
  "use strict";
21044
21357
  Object.defineProperty(exports, "__esModule", { value: true });
21045
21358
  var validate_1 = require_validate();
@@ -21095,9 +21408,9 @@ var require_properties = __commonJS({
21095
21408
  }
21096
21409
  });
21097
21410
 
21098
- // ../../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
21099
21412
  var require_patternProperties = __commonJS({
21100
- "../../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) {
21101
21414
  "use strict";
21102
21415
  Object.defineProperty(exports, "__esModule", { value: true });
21103
21416
  var code_1 = require_code2();
@@ -21169,9 +21482,9 @@ var require_patternProperties = __commonJS({
21169
21482
  }
21170
21483
  });
21171
21484
 
21172
- // ../../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
21173
21486
  var require_not = __commonJS({
21174
- "../../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) {
21175
21488
  "use strict";
21176
21489
  Object.defineProperty(exports, "__esModule", { value: true });
21177
21490
  var util_1 = require_util();
@@ -21200,9 +21513,9 @@ var require_not = __commonJS({
21200
21513
  }
21201
21514
  });
21202
21515
 
21203
- // ../../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
21204
21517
  var require_anyOf = __commonJS({
21205
- "../../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) {
21206
21519
  "use strict";
21207
21520
  Object.defineProperty(exports, "__esModule", { value: true });
21208
21521
  var code_1 = require_code2();
@@ -21217,9 +21530,9 @@ var require_anyOf = __commonJS({
21217
21530
  }
21218
21531
  });
21219
21532
 
21220
- // ../../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
21221
21534
  var require_oneOf = __commonJS({
21222
- "../../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) {
21223
21536
  "use strict";
21224
21537
  Object.defineProperty(exports, "__esModule", { value: true });
21225
21538
  var codegen_1 = require_codegen();
@@ -21275,9 +21588,9 @@ var require_oneOf = __commonJS({
21275
21588
  }
21276
21589
  });
21277
21590
 
21278
- // ../../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
21279
21592
  var require_allOf = __commonJS({
21280
- "../../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) {
21281
21594
  "use strict";
21282
21595
  Object.defineProperty(exports, "__esModule", { value: true });
21283
21596
  var util_1 = require_util();
@@ -21302,9 +21615,9 @@ var require_allOf = __commonJS({
21302
21615
  }
21303
21616
  });
21304
21617
 
21305
- // ../../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
21306
21619
  var require_if = __commonJS({
21307
- "../../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) {
21308
21621
  "use strict";
21309
21622
  Object.defineProperty(exports, "__esModule", { value: true });
21310
21623
  var codegen_1 = require_codegen();
@@ -21371,9 +21684,9 @@ var require_if = __commonJS({
21371
21684
  }
21372
21685
  });
21373
21686
 
21374
- // ../../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
21375
21688
  var require_thenElse = __commonJS({
21376
- "../../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) {
21377
21690
  "use strict";
21378
21691
  Object.defineProperty(exports, "__esModule", { value: true });
21379
21692
  var util_1 = require_util();
@@ -21389,9 +21702,9 @@ var require_thenElse = __commonJS({
21389
21702
  }
21390
21703
  });
21391
21704
 
21392
- // ../../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
21393
21706
  var require_applicator = __commonJS({
21394
- "../../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) {
21395
21708
  "use strict";
21396
21709
  Object.defineProperty(exports, "__esModule", { value: true });
21397
21710
  var additionalItems_1 = require_additionalItems();
@@ -21437,9 +21750,9 @@ var require_applicator = __commonJS({
21437
21750
  }
21438
21751
  });
21439
21752
 
21440
- // ../../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
21441
21754
  var require_format = __commonJS({
21442
- "../../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) {
21443
21756
  "use strict";
21444
21757
  Object.defineProperty(exports, "__esModule", { value: true });
21445
21758
  var codegen_1 = require_codegen();
@@ -21527,9 +21840,9 @@ var require_format = __commonJS({
21527
21840
  }
21528
21841
  });
21529
21842
 
21530
- // ../../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
21531
21844
  var require_format2 = __commonJS({
21532
- "../../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) {
21533
21846
  "use strict";
21534
21847
  Object.defineProperty(exports, "__esModule", { value: true });
21535
21848
  var format_1 = require_format();
@@ -21538,9 +21851,9 @@ var require_format2 = __commonJS({
21538
21851
  }
21539
21852
  });
21540
21853
 
21541
- // ../../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
21542
21855
  var require_metadata = __commonJS({
21543
- "../../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) {
21544
21857
  "use strict";
21545
21858
  Object.defineProperty(exports, "__esModule", { value: true });
21546
21859
  exports.contentVocabulary = exports.metadataVocabulary = void 0;
@@ -21561,9 +21874,9 @@ var require_metadata = __commonJS({
21561
21874
  }
21562
21875
  });
21563
21876
 
21564
- // ../../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
21565
21878
  var require_draft7 = __commonJS({
21566
- "../../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) {
21567
21880
  "use strict";
21568
21881
  Object.defineProperty(exports, "__esModule", { value: true });
21569
21882
  var core_1 = require_core2();
@@ -21583,9 +21896,9 @@ var require_draft7 = __commonJS({
21583
21896
  }
21584
21897
  });
21585
21898
 
21586
- // ../../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
21587
21900
  var require_types = __commonJS({
21588
- "../../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) {
21589
21902
  "use strict";
21590
21903
  Object.defineProperty(exports, "__esModule", { value: true });
21591
21904
  exports.DiscrError = void 0;
@@ -21597,9 +21910,9 @@ var require_types = __commonJS({
21597
21910
  }
21598
21911
  });
21599
21912
 
21600
- // ../../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
21601
21914
  var require_discriminator = __commonJS({
21602
- "../../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) {
21603
21916
  "use strict";
21604
21917
  Object.defineProperty(exports, "__esModule", { value: true });
21605
21918
  var codegen_1 = require_codegen();
@@ -21702,9 +22015,9 @@ var require_discriminator = __commonJS({
21702
22015
  }
21703
22016
  });
21704
22017
 
21705
- // ../../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
21706
22019
  var require_json_schema_draft_07 = __commonJS({
21707
- "../../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) {
21708
22021
  module.exports = {
21709
22022
  $schema: "http://json-schema.org/draft-07/schema#",
21710
22023
  $id: "http://json-schema.org/draft-07/schema#",
@@ -21859,9 +22172,9 @@ var require_json_schema_draft_07 = __commonJS({
21859
22172
  }
21860
22173
  });
21861
22174
 
21862
- // ../../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
21863
22176
  var require_ajv = __commonJS({
21864
- "../../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) {
21865
22178
  "use strict";
21866
22179
  Object.defineProperty(exports, "__esModule", { value: true });
21867
22180
  exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = void 0;
@@ -21929,9 +22242,9 @@ var require_ajv = __commonJS({
21929
22242
  }
21930
22243
  });
21931
22244
 
21932
- // ../../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
21933
22246
  var require_formats = __commonJS({
21934
- "../../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) {
21935
22248
  "use strict";
21936
22249
  Object.defineProperty(exports, "__esModule", { value: true });
21937
22250
  exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
@@ -22132,9 +22445,9 @@ var require_formats = __commonJS({
22132
22445
  }
22133
22446
  });
22134
22447
 
22135
- // ../../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
22136
22449
  var require_limit = __commonJS({
22137
- "../../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) {
22138
22451
  "use strict";
22139
22452
  Object.defineProperty(exports, "__esModule", { value: true });
22140
22453
  exports.formatLimitDefinition = void 0;
@@ -22204,9 +22517,9 @@ var require_limit = __commonJS({
22204
22517
  }
22205
22518
  });
22206
22519
 
22207
- // ../../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
22208
22521
  var require_dist = __commonJS({
22209
- "../../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) {
22210
22523
  "use strict";
22211
22524
  Object.defineProperty(exports, "__esModule", { value: true });
22212
22525
  var formats_1 = require_formats();
@@ -24030,7 +24343,7 @@ function registerReadTools(server) {
24030
24343
  server.registerTool(
24031
24344
  "get_current_task",
24032
24345
  {
24033
- 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).",
24034
24347
  inputSchema: {
24035
24348
  repo_id: external_exports.string().uuid().describe("The repo UUID"),
24036
24349
  worktree_id: external_exports.string().uuid().optional().describe(
@@ -24054,11 +24367,34 @@ function registerReadTools(server) {
24054
24367
  );
24055
24368
  }
24056
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
+ }
24057
24393
  return {
24058
24394
  content: [
24059
24395
  {
24060
24396
  type: "text",
24061
- text: "No active checkpoint found for this repo."
24397
+ text: "No active checkpoint or standalone task found for this repo."
24062
24398
  }
24063
24399
  ]
24064
24400
  };
@@ -24480,6 +24816,124 @@ function registerReadTools(server) {
24480
24816
  }
24481
24817
  }
24482
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
+ );
24483
24937
  server.registerTool(
24484
24938
  "get_file_changes",
24485
24939
  {
@@ -24496,7 +24950,15 @@ function registerReadTools(server) {
24496
24950
  )
24497
24951
  }
24498
24952
  },
24499
- 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
+ }) => {
24500
24962
  try {
24501
24963
  const res = await apiGet(
24502
24964
  "/file-changes",
@@ -24804,6 +25266,27 @@ var init_promotion = __esm({
24804
25266
  });
24805
25267
 
24806
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
+ }
24807
25290
  function registerWriteTools(server) {
24808
25291
  server.registerTool(
24809
25292
  "create_repo",
@@ -25138,6 +25621,12 @@ function registerWriteTools(server) {
25138
25621
  ),
25139
25622
  resources: external_exports.any().optional().describe(
25140
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."
25141
25630
  )
25142
25631
  }
25143
25632
  },
@@ -25154,7 +25643,9 @@ function registerWriteTools(server) {
25154
25643
  user_context,
25155
25644
  is_claude_written,
25156
25645
  context_development,
25157
- resources
25646
+ resources,
25647
+ deadline,
25648
+ branch_name
25158
25649
  }) => {
25159
25650
  try {
25160
25651
  const body = {
@@ -25174,6 +25665,8 @@ function registerWriteTools(server) {
25174
25665
  if (context_development !== void 0)
25175
25666
  body.context_development = context_development;
25176
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;
25177
25670
  const res = await apiPost("/tasks", body);
25178
25671
  return {
25179
25672
  content: [
@@ -25316,25 +25809,21 @@ function registerWriteTools(server) {
25316
25809
  try {
25317
25810
  let hasUnapproved = false;
25318
25811
  let unapprovedCount = 0;
25319
- let resolvedRepoId = null;
25320
- try {
25321
- const taskRes = await apiGet(
25322
- `/tasks/${task_id}`
25323
- );
25324
- const checkpointRes = await apiGet(
25325
- `/checkpoints/${taskRes.data.checkpoint_id}`
25326
- );
25327
- resolvedRepoId = checkpointRes.data.repo_id;
25328
- const fileChangesRes = await apiGet("/file-changes", {
25329
- repo_id: resolvedRepoId,
25330
- task_id
25331
- });
25332
- const unapproved = (fileChangesRes.data ?? []).filter(
25333
- (f) => !f.user_approved
25334
- );
25335
- unapprovedCount = unapproved.length;
25336
- hasUnapproved = unapprovedCount > 0;
25337
- } 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
+ }
25338
25827
  }
25339
25828
  if (hasUnapproved) {
25340
25829
  return {
@@ -25537,28 +26026,25 @@ function registerWriteTools(server) {
25537
26026
  );
25538
26027
  if (files_changed && files_changed.length > 0) {
25539
26028
  try {
25540
- const taskRes = await apiGet(
25541
- `/tasks/${res.data.task_id}`
25542
- );
25543
- const checkpointRes = await apiGet(
25544
- `/checkpoints/${taskRes.data.checkpoint_id}`
25545
- );
25546
- await apiPatch("/file-changes", {
25547
- action: "replace_round_files",
25548
- round_id,
25549
- repo_id: checkpointRes.data.repo_id,
25550
- checkpoint_id: taskRes.data.checkpoint_id,
25551
- task_id: res.data.task_id,
25552
- source: "round",
25553
- files: files_changed.map(
25554
- (f) => ({
25555
- file_path: f.path,
25556
- action: f.action,
25557
- claude_approved: f.claude_approved ?? false,
25558
- user_approved: f.user_approved ?? false
25559
- })
25560
- )
25561
- });
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
+ }
25562
26048
  } catch {
25563
26049
  }
25564
26050
  }
@@ -25603,23 +26089,20 @@ function registerWriteTools(server) {
25603
26089
  );
25604
26090
  let unapprovedFiles = [];
25605
26091
  try {
25606
- const taskRes = await apiGet(
25607
- `/tasks/${res.data.task_id}`
25608
- );
25609
- const checkpointRes = await apiGet(
25610
- `/checkpoints/${taskRes.data.checkpoint_id}`
25611
- );
25612
- const repoId = checkpointRes.data.repo_id;
25613
- await apiPatch("/file-changes", {
25614
- action: "lock_round",
25615
- round_id,
25616
- repo_id: repoId
25617
- });
25618
- const fileChangesRes = await apiGet("/file-changes", {
25619
- repo_id: repoId,
25620
- round_id
25621
- });
25622
- 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
+ }
25623
26106
  } catch {
25624
26107
  }
25625
26108
  const result = {
@@ -26390,6 +26873,76 @@ ${dbOnlyFiles.length} file(s) exist in DB but were missing locally (recreated).
26390
26873
  }
26391
26874
  }
26392
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
+ );
26393
26946
  }
26394
26947
  var init_write = __esm({
26395
26948
  "src/tools/write.ts"() {
@@ -26601,6 +27154,7 @@ if (arg === "help" || arg === "--help" || arg === "-h") {
26601
27154
  --repo-id <uuid> Repository ID (or set via .codebyplan.json)
26602
27155
  --dry-run Preview changes without writing
26603
27156
  --force Skip confirmation and conflict prompts
27157
+ --fix Auto-create missing port allocations
26604
27158
 
26605
27159
  Learn more: https://codebyplan.com
26606
27160
  `);