catenext 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,28 @@ tag yang versinya belum ada di file ini. Perbarui juga [docs/STATUS.md](docs/STA
10
10
 
11
11
  ## [Belum dirilis]
12
12
 
13
+ ### Diperbaiki
14
+ - Workflow Release CLI: typecheck/test lewat turbo sehingga `@catenext/shared` di-build lebih dulu;
15
+ root monorepo diganti nama `catenext-monorepo` agar `--filter catenext` tidak ikut menjalankan root.
16
+ - `scripts/build-cli-mirror.mjs` menyalin file dengan baca/tulis biasa, bukan `fs.cpSync`, yang gagal
17
+ EACCES di workspace runner self-hosted.
18
+ - CI dan Release CLI memakai `shell: bash` (di container, default `sh` gagal "Bad substitution"
19
+ pada `${GITHUB_SHA::7}` saat push ke mirror).
20
+
21
+ ### Diubah
22
+ - CI dan Release CLI di repo `catenext` berjalan di runner self-hosted (`docs/runner.md`);
23
+ job berjalan di container `node:22-bookworm` (Postgres lewat nama service, store pnpm di volume Docker lokal tanpa cache GitHub). Publish npm tetap di runner GitHub demi provenance.
24
+
25
+ ## [0.1.2] - 2026-11-25
26
+
27
+ ### Diperbaiki
28
+ - `npx catenext init` kini menulis entri MCP `npx -y catenext mcp`. Di 0.1.1 entri menunjuk ke
29
+ skrip di cache `~/.npm/_npx/...` yang bisa terhapus kapan saja, sehingga server MCP berhenti
30
+ jalan. Pasang ulang dengan `npx -y catenext@latest sync --fix` atau `init` ulang.
31
+
32
+ ### Diubah
33
+ - README CLI: alur pemasangan per repo tanpa instalasi global.
34
+
13
35
  ## [0.1.1] - 2026-11-25
14
36
 
15
37
  ### Diperbaiki
package/dist/index.js CHANGED
@@ -1734,14 +1734,51 @@ async function applyInit(root, changes) {
1734
1734
  // src/maintenance.ts
1735
1735
  import { existsSync } from "node:fs";
1736
1736
  import { copyFile, mkdir as mkdir4, readFile as readFile7, rename as rename4, rm, rmdir, writeFile as writeFile4 } from "node:fs/promises";
1737
- import { dirname as dirname3, isAbsolute, join as join6, resolve as resolve3 } from "node:path";
1737
+ import { dirname as dirname3, isAbsolute, join as join7, resolve as resolve3 } from "node:path";
1738
1738
  import { applyEdits as applyEdits2, modify as modify2, parse as parse4, visit } from "jsonc-parser";
1739
1739
 
1740
+ // src/node-command.ts
1741
+ import { accessSync, constants, realpathSync } from "node:fs";
1742
+ import { delimiter, join as join5 } from "node:path";
1743
+ function stableNodeCommand(execPath, pathEnv, resolveReal = realpathSync, isExecutable = defaultIsExecutable) {
1744
+ const target = safeReal(execPath, resolveReal);
1745
+ for (const dir of (pathEnv ?? "").split(delimiter)) {
1746
+ if (!dir) continue;
1747
+ for (const name of process.platform === "win32" ? ["node.exe", "node"] : ["node"]) {
1748
+ const candidate = join5(dir, name);
1749
+ if (!isExecutable(candidate)) continue;
1750
+ return safeReal(candidate, resolveReal) === target ? "node" : execPath;
1751
+ }
1752
+ }
1753
+ return execPath;
1754
+ }
1755
+ function hasVersionedSegment(path) {
1756
+ return /[\\/]v?\d+\.\d+\.\d+[\\/]/.test(path);
1757
+ }
1758
+ function safeReal(p, resolveReal) {
1759
+ try {
1760
+ return resolveReal(p);
1761
+ } catch {
1762
+ return p;
1763
+ }
1764
+ }
1765
+ function defaultIsExecutable(p) {
1766
+ try {
1767
+ accessSync(p, constants.X_OK);
1768
+ return true;
1769
+ } catch {
1770
+ return false;
1771
+ }
1772
+ }
1773
+ function npxLaunch(entry) {
1774
+ return /[\\/]_npx[\\/]/.test(entry) ? { command: "npx", args: ["-y", "catenext"] } : null;
1775
+ }
1776
+
1740
1777
  // src/skills.ts
1741
1778
  import { mkdir as mkdir3, readdir, readFile as readFile6, rename as rename3, writeFile as writeFile3 } from "node:fs/promises";
1742
- import { join as join5 } from "node:path";
1779
+ import { join as join6 } from "node:path";
1743
1780
  import { parse as parse3, stringify } from "yaml";
1744
- var SKILLS_DIR = join5(".catenext", "skills");
1781
+ var SKILLS_DIR = join6(".catenext", "skills");
1745
1782
  var SkillError = class extends Error {
1746
1783
  constructor(message) {
1747
1784
  super(message);
@@ -1781,7 +1818,7 @@ ${skill.content.trim()}
1781
1818
  async function listSkills(root) {
1782
1819
  let files;
1783
1820
  try {
1784
- files = await readdir(join5(root, SKILLS_DIR));
1821
+ files = await readdir(join6(root, SKILLS_DIR));
1785
1822
  } catch {
1786
1823
  return { skills: [], invalid: [] };
1787
1824
  }
@@ -1789,7 +1826,7 @@ async function listSkills(root) {
1789
1826
  const invalid = [];
1790
1827
  for (const file of files.filter((f) => f.endsWith(".md")).sort()) {
1791
1828
  try {
1792
- const skill = parseSkill(await readFile6(join5(root, SKILLS_DIR, file), "utf8"), file);
1829
+ const skill = parseSkill(await readFile6(join6(root, SKILLS_DIR, file), "utf8"), file);
1793
1830
  if (`${skill.name}.md` !== file) {
1794
1831
  throw new SkillError(`${file}: name "${skill.name}" harus sama dengan nama file.`);
1795
1832
  }
@@ -1809,7 +1846,7 @@ async function loadSkill(root, name) {
1809
1846
  const file = `${parsedName.data}.md`;
1810
1847
  let source;
1811
1848
  try {
1812
- source = await readFile6(join5(root, SKILLS_DIR, file), "utf8");
1849
+ source = await readFile6(join6(root, SKILLS_DIR, file), "utf8");
1813
1850
  } catch {
1814
1851
  const { skills } = await listSkills(root);
1815
1852
  const names = skills.map((s) => s.name).join(", ") || "(belum ada)";
@@ -1824,9 +1861,9 @@ async function saveSkill(root, input, now = /* @__PURE__ */ new Date()) {
1824
1861
  if (!when || when.length > SKILL_LIMITS.maxWhenToUseLength) {
1825
1862
  throw new SkillError(`when_to_use wajib, maks ${SKILL_LIMITS.maxWhenToUseLength} karakter.`);
1826
1863
  }
1827
- const dir = join5(root, SKILLS_DIR);
1864
+ const dir = join6(root, SKILLS_DIR);
1828
1865
  await mkdir3(dir, { recursive: true });
1829
- const target = join5(dir, `${name}.md`);
1866
+ const target = join6(dir, `${name}.md`);
1830
1867
  let created = true;
1831
1868
  try {
1832
1869
  await readFile6(target);
@@ -1837,7 +1874,7 @@ async function saveSkill(root, input, now = /* @__PURE__ */ new Date()) {
1837
1874
  const tmp = `${target}.${process.pid}.tmp`;
1838
1875
  await writeFile3(tmp, renderSkill(skill), "utf8");
1839
1876
  await rename3(tmp, target);
1840
- return { path: join5(SKILLS_DIR, `${name}.md`), created, skill };
1877
+ return { path: join6(SKILLS_DIR, `${name}.md`), created, skill };
1841
1878
  }
1842
1879
 
1843
1880
  // src/maintenance.ts
@@ -1888,7 +1925,8 @@ function isValidJsonObject(source) {
1888
1925
  function entryIsStale(entry) {
1889
1926
  if (isAbsolute(entry.command) && !existsSync(entry.command)) return true;
1890
1927
  const script = entry.args[0];
1891
- return Boolean(script && isAbsolute(script) && /\.[cm]?js$/.test(script) && !existsSync(script));
1928
+ if (!script || !isAbsolute(script) || !/\.[cm]?js$/.test(script)) return false;
1929
+ return !existsSync(script) || npxLaunch(script) !== null;
1892
1930
  }
1893
1931
  function baseCommand(entry, adapter) {
1894
1932
  const suffix = ["mcp", ...adapter.extraArgs];
@@ -1901,7 +1939,7 @@ async function planSync(opts) {
1901
1939
  const edits = [];
1902
1940
  const findings = [];
1903
1941
  for (const adapter of ADAPTERS) {
1904
- const before = await readOrNull2(join6(root, adapter.path));
1942
+ const before = await readOrNull2(join7(root, adapter.path));
1905
1943
  if (before !== null && before.trim() !== "" && !isValidJsonObject(before)) {
1906
1944
  if (!opts.fix) {
1907
1945
  findings.push({
@@ -1964,12 +2002,12 @@ async function planSync(opts) {
1964
2002
  );
1965
2003
  if (after !== before) edits.push({ path: adapter.path, before, after });
1966
2004
  }
1967
- const gitignore = await readOrNull2(join6(root, ".gitignore"));
2005
+ const gitignore = await readOrNull2(join7(root, ".gitignore"));
1968
2006
  const gitignoreAfter = ensureGitignore(gitignore);
1969
2007
  if (gitignoreAfter !== gitignore) {
1970
2008
  edits.push({ path: ".gitignore", before: gitignore, after: gitignoreAfter });
1971
2009
  }
1972
- const agents = await readOrNull2(join6(root, AGENTS_MD));
2010
+ const agents = await readOrNull2(join7(root, AGENTS_MD));
1973
2011
  if (agents?.includes(BLOCK_START)) {
1974
2012
  const after = upsertAgentsBlock(agents);
1975
2013
  if (after !== agents) edits.push({ path: AGENTS_MD, before: agents, after });
@@ -1985,7 +2023,7 @@ async function planRemove(opts) {
1985
2023
  const root = resolve3(opts.root);
1986
2024
  const edits = [];
1987
2025
  for (const adapter of ADAPTERS) {
1988
- const before = await readOrNull2(join6(root, adapter.path));
2026
+ const before = await readOrNull2(join7(root, adapter.path));
1989
2027
  if (before === null || countEntries(before) === 0) continue;
1990
2028
  const stripped = removeMcpEntries(before);
1991
2029
  const doc = parse4(stripped, [], { allowTrailingComma: true });
@@ -1993,7 +2031,7 @@ async function planRemove(opts) {
1993
2031
  const emptyDoc = Object.keys(doc ?? {}).every((k) => k === "mcpServers") && Object.keys(servers ?? {}).length === 0 && !/\/\/|\/\*/.test(stripped);
1994
2032
  edits.push({ path: adapter.path, before, after: emptyDoc ? null : stripped });
1995
2033
  }
1996
- const gitignore = await readOrNull2(join6(root, ".gitignore"));
2034
+ const gitignore = await readOrNull2(join7(root, ".gitignore"));
1997
2035
  if (gitignore !== null) {
1998
2036
  const eol = gitignore.includes("\r\n") ? "\r\n" : "\n";
1999
2037
  const lines = gitignore.split(/\r?\n/);
@@ -2005,19 +2043,19 @@ async function planRemove(opts) {
2005
2043
  edits.push({ path: ".gitignore", before: gitignore, after: text2 ? `${text2}${eol}` : null });
2006
2044
  }
2007
2045
  }
2008
- const agents = await readOrNull2(join6(root, AGENTS_MD));
2046
+ const agents = await readOrNull2(join7(root, AGENTS_MD));
2009
2047
  if (agents?.includes(BLOCK_START)) {
2010
2048
  edits.push({ path: AGENTS_MD, before: agents, after: removeAgentsBlock(agents) });
2011
2049
  }
2012
- for (const p of [CONFIG_PATH, join6(".catenext", "cache.json")]) {
2013
- const before = await readOrNull2(join6(root, p));
2050
+ for (const p of [CONFIG_PATH, join7(".catenext", "cache.json")]) {
2051
+ const before = await readOrNull2(join7(root, p));
2014
2052
  if (before !== null) edits.push({ path: p, before, after: null });
2015
2053
  }
2016
2054
  if (opts.all) {
2017
2055
  const { skills, invalid } = await listSkills(root);
2018
2056
  for (const f of [...skills.map((s) => `${s.name}.md`), ...invalid.map((i) => i.file)]) {
2019
- const p = join6(SKILLS_DIR, f);
2020
- edits.push({ path: p, before: await readOrNull2(join6(root, p)), after: null });
2057
+ const p = join7(SKILLS_DIR, f);
2058
+ edits.push({ path: p, before: await readOrNull2(join7(root, p)), after: null });
2021
2059
  }
2022
2060
  }
2023
2061
  return edits;
@@ -2025,7 +2063,7 @@ async function planRemove(opts) {
2025
2063
  async function applyFileEdits(root, edits) {
2026
2064
  const base = resolve3(root);
2027
2065
  for (const e of edits) {
2028
- const target = join6(base, e.path);
2066
+ const target = join7(base, e.path);
2029
2067
  if (e.after === null) {
2030
2068
  await rm(target, { force: true });
2031
2069
  continue;
@@ -2037,7 +2075,7 @@ async function applyFileEdits(root, edits) {
2037
2075
  await rename4(tmp, target);
2038
2076
  }
2039
2077
  for (const dir of [SKILLS_DIR, ".catenext", ".cursor"]) {
2040
- await rmdir(join6(base, dir)).catch(() => {
2078
+ await rmdir(join7(base, dir)).catch(() => {
2041
2079
  });
2042
2080
  }
2043
2081
  }
@@ -2342,40 +2380,6 @@ async function runMcpServer(opts) {
2342
2380
  await server.connect(new StdioServerTransport());
2343
2381
  }
2344
2382
 
2345
- // src/node-command.ts
2346
- import { accessSync, constants, realpathSync } from "node:fs";
2347
- import { delimiter, join as join7 } from "node:path";
2348
- function stableNodeCommand(execPath, pathEnv, resolveReal = realpathSync, isExecutable = defaultIsExecutable) {
2349
- const target = safeReal(execPath, resolveReal);
2350
- for (const dir of (pathEnv ?? "").split(delimiter)) {
2351
- if (!dir) continue;
2352
- for (const name of process.platform === "win32" ? ["node.exe", "node"] : ["node"]) {
2353
- const candidate = join7(dir, name);
2354
- if (!isExecutable(candidate)) continue;
2355
- return safeReal(candidate, resolveReal) === target ? "node" : execPath;
2356
- }
2357
- }
2358
- return execPath;
2359
- }
2360
- function hasVersionedSegment(path) {
2361
- return /[\\/]v?\d+\.\d+\.\d+[\\/]/.test(path);
2362
- }
2363
- function safeReal(p, resolveReal) {
2364
- try {
2365
- return resolveReal(p);
2366
- } catch {
2367
- return p;
2368
- }
2369
- }
2370
- function defaultIsExecutable(p) {
2371
- try {
2372
- accessSync(p, constants.X_OK);
2373
- return true;
2374
- } catch {
2375
- return false;
2376
- }
2377
- }
2378
-
2379
2383
  // src/verify.ts
2380
2384
  import { readFile as readFile8 } from "node:fs/promises";
2381
2385
  import { join as join8 } from "node:path";
@@ -2442,7 +2446,7 @@ function formatChecks(lines) {
2442
2446
  }
2443
2447
 
2444
2448
  // src/index.ts
2445
- var VERSION = "0.1.1";
2449
+ var VERSION = "0.1.2";
2446
2450
  var program = new Command();
2447
2451
  program.name("catenext").description("Estafet tugas & konteks antar-agen AI coding").version(VERSION);
2448
2452
  async function friendly(fn) {
@@ -2467,6 +2471,8 @@ async function friendly(fn) {
2467
2471
  function defaultMcpCommand() {
2468
2472
  const self = fileURLToPath(import.meta.url);
2469
2473
  const entry = self.endsWith(".ts") ? resolve4(dirname4(self), "../dist/index.js") : self;
2474
+ const viaNpx = npxLaunch(entry);
2475
+ if (viaNpx) return viaNpx;
2470
2476
  if (!existsSync2(entry)) {
2471
2477
  console.error(
2472
2478
  `! ${entry} belum ada. Jalankan \`pnpm --filter catenext build\` agar IDE bisa menjalankan server MCP.`