@workit-dev/codex 2.22.0 → 2.22.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "2.22.0",
3
+ "version": "2.22.2",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -10,7 +10,8 @@
10
10
  // POSIX shell launchers embed the *_SH functions below verbatim, and a test
11
11
  // runs them against the JavaScript for the same environment.
12
12
  // Side-effect free on import; only migrateLegacyDirs touches the disk.
13
- import { existsSync, lstatSync, mkdirSync, renameSync, writeFileSync } from "node:fs";
13
+ import { createHash } from "node:crypto";
14
+ import { existsSync, lstatSync, mkdirSync, realpathSync, renameSync, writeFileSync } from "node:fs";
14
15
  import os from "node:os";
15
16
  import path from "node:path";
16
17
 
@@ -100,6 +101,37 @@ export const runtimeDir = (env, platform) => workitDir("runtime", env, platform)
100
101
  */
101
102
  export const worktreesDir = (env, platform) => path.join(stateDir(env, platform), "worktrees");
102
103
 
104
+ /**
105
+ * A filesystem-safe name for one directory, from its canonical path, so every
106
+ * spelling of it (symlinks, Windows short names, drive-letter case) maps to one
107
+ * name: `<basename>-<12 hex of its sha256>`. The task store keys checkouts by it.
108
+ * @param {string} dir @param {string} [platform]
109
+ */
110
+ export const folderSlug = (dir, platform = process.platform) => {
111
+ let canonical = dir;
112
+ try {
113
+ canonical = realpathSync.native(dir);
114
+ } catch {
115
+ // A missing path keys by its spelling.
116
+ }
117
+ if (platform === "win32") canonical = canonical.toLowerCase();
118
+ const base =
119
+ path
120
+ .basename(canonical)
121
+ .replace(/[^A-Za-z0-9._-]/g, "_")
122
+ .slice(0, 40) || "root";
123
+ return `${base}-${createHash("sha256").update(canonical).digest("hex").slice(0, 12)}`;
124
+ };
125
+
126
+ /**
127
+ * Where a folder outside every git repository keeps its Workit store (ledger,
128
+ * tasks, plans, retros, handoffs, notes): `<state>/folders/<folderSlug(dir)>`,
129
+ * never inside the folder itself.
130
+ * @param {string} dir @param {NodeJS.ProcessEnv} [env] @param {string} [platform]
131
+ */
132
+ export const folderStoreDir = (dir, env, platform) =>
133
+ path.join(stateDir(env, platform), "folders", folderSlug(dir, platform));
134
+
103
135
  /**
104
136
  * The managed worktree root before it moved to worktreesDir:
105
137
  * `$XDG_CACHE_HOME/workit-wt`, else `~/.cache/workit-wt` (on every platform).