turntax 0.3.0 → 0.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.
- package/README.md +53 -7
- package/dist/cli.js +147 -21
- package/dist/core/advice.js +79 -25
- package/dist/core/fix.js +442 -0
- package/dist/core/glob.js +34 -0
- package/dist/core/render.js +63 -6
- package/dist/node/apply.js +43 -0
- package/dist/node/config.js +52 -0
- package/dist/node/discover.js +35 -2
- package/package.json +1 -1
package/dist/node/discover.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { existsSync, lstatSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
1
|
+
import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
2
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
3
3
|
import { MAX_DEPTH, addImports, isInstructionFile, isSkippedDir } from '../core/files.js';
|
|
4
4
|
import { MCP_CONFIGS, USER_MCP_PATHS } from '../core/mcp.js';
|
|
5
5
|
import { USER_ROOTS, isUserInstructionFile } from '../core/user.js';
|
|
@@ -106,3 +106,36 @@ export function discoverUser(home) {
|
|
|
106
106
|
});
|
|
107
107
|
return { files: [...files.values()].sort((a, b) => a.path.localeCompare(b.path)), mcpConfigs };
|
|
108
108
|
}
|
|
109
|
+
/** The real location of `p`, following symlinks in the part of the path that exists; null behind a dangling symlink. */
|
|
110
|
+
export function realLocation(p) {
|
|
111
|
+
if (lstatSync(p, { throwIfNoEntry: false })) {
|
|
112
|
+
try {
|
|
113
|
+
return realpathSync(p);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const parent = dirname(p);
|
|
120
|
+
if (parent === p)
|
|
121
|
+
return p;
|
|
122
|
+
const real = realLocation(parent);
|
|
123
|
+
return real === null ? null : resolve(real, relative(parent, p));
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A check for paths that must not be changed: paths that are symlinks or lie under a symlinked folder
|
|
127
|
+
* (existing or not), and repository files that such a link points to.
|
|
128
|
+
*/
|
|
129
|
+
export function linkedPaths(root, files) {
|
|
130
|
+
const realRoot = realpathSync(root);
|
|
131
|
+
const linked = (path) => realLocation(join(root, path)) !== join(realRoot, path);
|
|
132
|
+
const targets = new Set();
|
|
133
|
+
for (const f of files) {
|
|
134
|
+
if (!linked(f.path))
|
|
135
|
+
continue;
|
|
136
|
+
const rel = relative(realRoot, realLocation(join(root, f.path)) ?? realRoot);
|
|
137
|
+
if (!rel.startsWith('..') && !isAbsolute(rel))
|
|
138
|
+
targets.add(rel.split(sep).join('/'));
|
|
139
|
+
}
|
|
140
|
+
return (path) => targets.has(path) || linked(path);
|
|
141
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turntax",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Measure the per-turn token cost of AI coding-agent instruction files (AGENTS.md, CLAUDE.md, Cursor, Copilot, Cline, Roo, Kiro, Windsurf and more) for every agent that reads them.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "TORUT LTD",
|