@tuned-tensor/cli 0.13.1-beta.3 → 0.13.1-beta.4

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/index.js CHANGED
@@ -1,15 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ DEFAULT_ARTIFACT_ROOT,
4
+ DEFAULT_FOUNDATION_RUNS_DIR,
3
5
  TRAINING_MODELS,
4
6
  assertFoundationSpecReady,
5
7
  assertLocalRunInputReady,
6
8
  buildFoundationPythonCommand,
9
+ defaultStoreRoot,
10
+ expandUserPath,
11
+ getAgentConfigDir,
12
+ getConfigDir,
13
+ hardenExistingLocalStore,
7
14
  loadLocalRunInput,
8
15
  loadLocalRunnerConfig,
9
16
  runLocalPipeline,
10
17
  runLoggedProcess,
11
18
  withFoundationPythonEnvironment
12
- } from "./chunk-2P2RL23O.js";
19
+ } from "./chunk-7VIUHQBI.js";
13
20
 
14
21
  // src/cli.ts
15
22
  import { spawn as spawn2 } from "child_process";
@@ -591,7 +598,6 @@ import {
591
598
  readFileSync,
592
599
  writeFileSync
593
600
  } from "fs";
594
- import { homedir } from "os";
595
601
  import { join as join2 } from "path";
596
602
  var AGENT_THINKING_LEVELS = [
597
603
  "off",
@@ -602,16 +608,7 @@ var AGENT_THINKING_LEVELS = [
602
608
  "xhigh",
603
609
  "max"
604
610
  ];
605
- var CONFIG_DIR_NAME = "tuned-tensor";
606
611
  var CONFIG_FILE_NAME = "config.json";
607
- function getConfigDir() {
608
- const xdg = process.env.XDG_CONFIG_HOME;
609
- const base = xdg || join2(homedir(), ".config");
610
- return join2(base, CONFIG_DIR_NAME);
611
- }
612
- function getAgentConfigDir() {
613
- return join2(getConfigDir(), "agent");
614
- }
615
612
  function getConfigPath() {
616
613
  return join2(getConfigDir(), CONFIG_FILE_NAME);
617
614
  }
@@ -1073,10 +1070,10 @@ var TRAINING_SOURCE_FILES = {
1073
1070
  common: "training/foundation/src/common.py"
1074
1071
  },
1075
1072
  adapter: {
1076
- train: "training/local-runner/src/train.py",
1077
- data: "training/local-runner/src/sft_data.py",
1078
- model_contract: "training/local-runner/src/model_contract.py",
1079
- evaluate: "training/local-runner/src/evaluate.py"
1073
+ train: "training/adapter/src/train.py",
1074
+ data: "training/adapter/src/sft_data.py",
1075
+ model_contract: "training/adapter/src/model_contract.py",
1076
+ evaluate: "training/adapter/src/evaluate.py"
1080
1077
  }
1081
1078
  };
1082
1079
  var UUID_PATTERN = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$";
@@ -2009,8 +2006,8 @@ import { stripVTControlCharacters as stripVTControlCharacters3 } from "util";
2009
2006
  // src/shell.ts
2010
2007
  import chalk from "chalk";
2011
2008
  import { stat as stat3 } from "fs/promises";
2012
- import { homedir as homedir3 } from "os";
2013
- import { isAbsolute as isAbsolute2, resolve as resolve2 } from "path";
2009
+ import { homedir } from "os";
2010
+ import { isAbsolute, resolve as resolve2 } from "path";
2014
2011
  import { createInterface as createInterface2 } from "readline";
2015
2012
  import { stripVTControlCharacters } from "util";
2016
2013
 
@@ -2109,8 +2106,7 @@ function createCommandCompleter(getMode = () => "local") {
2109
2106
 
2110
2107
  // src/shell-context.ts
2111
2108
  import { readFile as readFile2, readdir as readdir2, stat as stat2 } from "fs/promises";
2112
- import { homedir as homedir2 } from "os";
2113
- import { basename, dirname as dirname2, isAbsolute, join as join5, resolve } from "path";
2109
+ import { basename, dirname as dirname2, join as join5, resolve } from "path";
2114
2110
  async function readJsonObject(path) {
2115
2111
  try {
2116
2112
  const parsed = JSON.parse(await readFile2(path, "utf8"));
@@ -2133,17 +2129,11 @@ function stringField(value, key) {
2133
2129
  const field = value?.[key];
2134
2130
  return typeof field === "string" && field.trim() ? field : void 0;
2135
2131
  }
2136
- function expandPath(value, baseDirectory, homeDirectory) {
2137
- if (value === "~") return homeDirectory;
2138
- if (value.startsWith("~/")) return resolve(homeDirectory, value.slice(2));
2139
- return isAbsolute(value) ? resolve(value) : resolve(baseDirectory, value);
2140
- }
2141
- function environmentHome(env) {
2142
- return env.HOME ? resolve(env.HOME) : homedir2();
2132
+ function expandPath(value, baseDirectory, env) {
2133
+ return expandUserPath(value, env, baseDirectory);
2143
2134
  }
2144
- function configPath(env, homeDirectory) {
2145
- const configHome = env.XDG_CONFIG_HOME ? resolve(env.XDG_CONFIG_HOME) : join5(homeDirectory, ".config");
2146
- return join5(configHome, "tuned-tensor", "config.json");
2135
+ function configPath(env) {
2136
+ return join5(getConfigDir(env), "config.json");
2147
2137
  }
2148
2138
  function agentSelectionFrom(env, configAgent) {
2149
2139
  const stored = configAgent && typeof configAgent === "object" && !Array.isArray(configAgent) ? configAgent : {};
@@ -2199,7 +2189,6 @@ async function readLatestRun(storeRoot) {
2199
2189
  async function discoverShellContext(options = {}) {
2200
2190
  const env = options.env ?? process.env;
2201
2191
  const cwd = resolve(options.cwd ?? process.cwd());
2202
- const homeDirectory = environmentHome(env);
2203
2192
  const warnings = [];
2204
2193
  const specPath = join5(cwd, "tunedtensor.json");
2205
2194
  const specJson = await readJsonObject(specPath);
@@ -2229,14 +2218,15 @@ async function discoverShellContext(options = {}) {
2229
2218
  const localConfigDirectory = hasAdjacentLocalConfig ? dirname2(localConfigPath) : cwd;
2230
2219
  const configuredArtifactRoot = stringField(localConfigJson.value, "artifactRoot");
2231
2220
  const configuredStoreRoot = stringField(localConfigJson.value, "storeRoot");
2232
- const artifactRoot = configuredArtifactRoot ? expandPath(configuredArtifactRoot, localConfigDirectory, homeDirectory) : resolve(cwd, ".tt-local", "artifacts");
2233
- const storeRoot = configuredStoreRoot ? expandPath(configuredStoreRoot, localConfigDirectory, homeDirectory) : env.TT_LOCAL_HOME ? expandPath(env.TT_LOCAL_HOME, cwd, homeDirectory) : join5(homeDirectory, ".tuned-tensor-local");
2234
- const storedConfigPath = configPath(env, homeDirectory);
2221
+ const artifactRoot = configuredArtifactRoot ? expandPath(configuredArtifactRoot, localConfigDirectory, env) : resolve(cwd, DEFAULT_ARTIFACT_ROOT);
2222
+ const storeRoot = configuredStoreRoot ? expandPath(configuredStoreRoot, localConfigDirectory, env) : defaultStoreRoot(env);
2223
+ const storedConfigPath = configPath(env);
2235
2224
  const storedConfigJson = await readJsonObject(storedConfigPath);
2236
2225
  if (storedConfigJson.invalid) {
2237
2226
  warnings.push("The Tuned Tensor config could not be parsed.");
2238
2227
  }
2239
2228
  const agent = agentSelectionFrom(env, storedConfigJson.value?.agent);
2229
+ await hardenExistingLocalStore(storeRoot);
2240
2230
  const [activeModelId, latestRun] = await Promise.all([
2241
2231
  readActiveModelId(storeRoot),
2242
2232
  readLatestRun(storeRoot)
@@ -2789,10 +2779,10 @@ function assertNoArgs(command, args2) {
2789
2779
  }
2790
2780
  }
2791
2781
  function expandDirectory(value, cwd, env) {
2792
- const home = env.HOME ? resolve2(env.HOME) : homedir3();
2782
+ const home = env.HOME ? resolve2(env.HOME) : homedir();
2793
2783
  if (value === "~") return home;
2794
2784
  if (value.startsWith("~/")) return resolve2(home, value.slice(2));
2795
- return isAbsolute2(value) ? resolve2(value) : resolve2(cwd, value);
2785
+ return isAbsolute(value) ? resolve2(value) : resolve2(cwd, value);
2796
2786
  }
2797
2787
  function helpText(mode, query, palette = false) {
2798
2788
  const groups = groupedCatalog(mode, query);
@@ -3900,7 +3890,7 @@ import {
3900
3890
  import {
3901
3891
  basename as basename3,
3902
3892
  dirname as dirname3,
3903
- isAbsolute as isAbsolute3,
3893
+ isAbsolute as isAbsolute2,
3904
3894
  join as join6,
3905
3895
  resolve as resolve3
3906
3896
  } from "path";
@@ -4624,7 +4614,7 @@ async function pathIsFile(path) {
4624
4614
  return (await stat4(path).catch(() => null))?.isFile() ?? false;
4625
4615
  }
4626
4616
  function resolveFromCwd(path, cwd) {
4627
- if (isAbsolute3(path)) return path;
4617
+ if (isAbsolute2(path)) return path;
4628
4618
  return resolve3(cwd, path);
4629
4619
  }
4630
4620
  async function projectSpecArguments(originalArgs, cwd) {
@@ -5199,7 +5189,7 @@ ${result2.stderr}` : ""}`
5199
5189
  async function runFoundationPipeline(args2) {
5200
5190
  assertFoundationPlanSupported(args2.spec, args2.plan);
5201
5191
  const outputDir = resolve4(
5202
- args2.outputDir ?? join7(dirname4(resolve4(args2.specPath)), ".tt-foundation-runs", randomUUID5())
5192
+ args2.outputDir ?? join7(dirname4(resolve4(args2.specPath)), DEFAULT_FOUNDATION_RUNS_DIR, randomUUID5())
5203
5193
  );
5204
5194
  await mkdir3(outputDir, { recursive: true, mode: 448 });
5205
5195
  await chmod2(outputDir, 448);
@@ -5909,7 +5899,7 @@ async function runCli(version, runtime = {}) {
5909
5899
  }
5910
5900
 
5911
5901
  // src/index.ts
5912
- runCli("0.13.1-beta.3").catch((err) => {
5902
+ runCli("0.13.1-beta.4").catch((err) => {
5913
5903
  reportError(err);
5914
5904
  process.exit(1);
5915
5905
  });