@cleocode/cant 2026.5.49 → 2026.5.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/document.js CHANGED
@@ -26,7 +26,9 @@ const native_loader_1 = require("./native-loader");
26
26
  * @returns A {@link CantDocumentResult} with either the AST or parse errors.
27
27
  */
28
28
  async function parseDocument(filePath) {
29
- const content = await (0, promises_1.readFile)(filePath, 'utf-8');
29
+ // Normalize CRLF → LF so the Rust parser sees consistent line endings
30
+ // on Windows runners that check out files with core.autocrlf=true.
31
+ const content = (await (0, promises_1.readFile)(filePath, 'utf-8')).replace(/\r\n/g, '\n');
30
32
  const result = (0, native_loader_1.cantParseDocumentNative)(content);
31
33
  return {
32
34
  file: filePath,
@@ -42,7 +44,9 @@ async function parseDocument(filePath) {
42
44
  * @returns A {@link CantValidationResult} with all diagnostics.
43
45
  */
44
46
  async function validateDocument(filePath) {
45
- const content = await (0, promises_1.readFile)(filePath, 'utf-8');
47
+ // Normalize CRLF → LF so the Rust validator sees consistent line endings
48
+ // on Windows runners that check out files with core.autocrlf=true.
49
+ const content = (await (0, promises_1.readFile)(filePath, 'utf-8')).replace(/\r\n/g, '\n');
46
50
  const result = (0, native_loader_1.cantValidateDocumentNative)(content);
47
51
  return {
48
52
  file: filePath,
@@ -61,7 +65,9 @@ async function validateDocument(filePath) {
61
65
  * @returns A {@link CantListResult} with the matching section names.
62
66
  */
63
67
  async function listSections(filePath, kind = 'agent') {
64
- const content = await (0, promises_1.readFile)(filePath, 'utf-8');
68
+ // Normalize CRLF → LF so the Rust parser sees consistent line endings
69
+ // on Windows runners that check out files with core.autocrlf=true.
70
+ const content = (await (0, promises_1.readFile)(filePath, 'utf-8')).replace(/\r\n/g, '\n');
65
71
  const parsed = (0, native_loader_1.cantParseDocumentNative)(content);
66
72
  if (!parsed.success || parsed.document == null) {
67
73
  return { file: filePath, filter: kind, count: 0, names: [] };
@@ -38,8 +38,8 @@ function ensureLoaded() {
38
38
  return;
39
39
  loadAttempted = true;
40
40
  // The compiled file lives at packages/cant/dist/native-loader.js, so
41
- // ../napi resolves to packages/cant/napi/cant.linux-x64-gnu.node.
42
- const packageBinary = (0, node_path_1.join)(__dirname, '..', 'napi', 'cant.linux-x64-gnu.node');
41
+ // ../napi resolves to packages/cant/napi/cant.<platform>.node.
42
+ const packageBinary = (0, node_path_1.join)(__dirname, '..', 'napi', `cant.${nativePlatformTriple()}.node`);
43
43
  try {
44
44
  nativeModule = require(packageBinary);
45
45
  return;
@@ -56,6 +56,19 @@ function ensureLoaded() {
56
56
  nativeModule = null;
57
57
  }
58
58
  }
59
+ /** Resolve the package-local napi-rs binary suffix for the current platform. */
60
+ function nativePlatformTriple() {
61
+ if (process.platform === 'darwin') {
62
+ return process.arch === 'arm64' ? 'darwin-arm64' : 'darwin-x64';
63
+ }
64
+ if (process.platform === 'linux') {
65
+ return process.arch === 'arm64' ? 'linux-arm64-gnu' : 'linux-x64-gnu';
66
+ }
67
+ if (process.platform === 'win32') {
68
+ return process.arch === 'arm64' ? 'win32-arm64-msvc' : 'win32-x64-msvc';
69
+ }
70
+ return `${process.platform}-${process.arch}`;
71
+ }
59
72
  /**
60
73
  * Check if the native addon is available.
61
74
  *
package/dist/worktree.js CHANGED
@@ -122,6 +122,7 @@ function listWorktrees(config) {
122
122
  });
123
123
  const entries = [];
124
124
  const root = resolveWorktreeRoot(config);
125
+ const canonicalRoot = canonicalPath(root);
125
126
  let currentPath = '';
126
127
  let currentBranch = '';
127
128
  for (const line of output.split('\n')) {
@@ -132,8 +133,12 @@ function listWorktrees(config) {
132
133
  currentBranch = line.slice('branch refs/heads/'.length);
133
134
  }
134
135
  else if (line === '') {
135
- if (currentPath.startsWith(root)) {
136
- entries.push({ path: currentPath, branch: currentBranch });
136
+ const canonicalCurrent = canonicalPath(currentPath);
137
+ const relativeToRoot = (0, node_path_1.relative)(canonicalRoot, canonicalCurrent);
138
+ if (relativeToRoot.length > 0 &&
139
+ !relativeToRoot.startsWith('..') &&
140
+ !(0, node_path_1.isAbsolute)(relativeToRoot)) {
141
+ entries.push({ path: (0, node_path_1.join)(root, relativeToRoot), branch: currentBranch });
137
142
  }
138
143
  currentPath = '';
139
144
  currentBranch = '';
@@ -145,6 +150,22 @@ function listWorktrees(config) {
145
150
  return [];
146
151
  }
147
152
  }
153
+ /**
154
+ * Return a filesystem-canonical path when possible.
155
+ *
156
+ * macOS reports temporary git worktrees via `/private/var/...` even when the
157
+ * test/config path was created under `/var/...`. Canonicalizing both sides for
158
+ * filtering prevents managed worktrees from being dropped, while callers still
159
+ * receive paths rooted at the configured spelling.
160
+ */
161
+ function canonicalPath(path) {
162
+ try {
163
+ return node_fs_1.realpathSync.native(path);
164
+ }
165
+ catch {
166
+ return path;
167
+ }
168
+ }
148
169
  /**
149
170
  * Build a WorktreeHandle with a cleanup closure.
150
171
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleocode/cant",
3
- "version": "2026.5.49",
3
+ "version": "2026.5.51",
4
4
  "description": "CANT protocol parser and runtime for CLEO — wraps cant-core via napi-rs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,9 +9,9 @@
9
9
  "napi/"
10
10
  ],
11
11
  "dependencies": {
12
- "@cleocode/contracts": "2026.5.49",
13
- "@cleocode/core": "2026.5.49",
14
- "@cleocode/lafs": "2026.5.49"
12
+ "@cleocode/contracts": "2026.5.51",
13
+ "@cleocode/core": "2026.5.51",
14
+ "@cleocode/lafs": "2026.5.51"
15
15
  },
16
16
  "devDependencies": {
17
17
  "typescript": "^6.0.2",