@@ -38,6 +38,7 @@ import {
3838 fingerprintPackageDisplayPath ,
3939 inventory ,
4040 normalizeMemoryDir ,
41+ resolveMemoryDirDefault ,
4142 scanStatus ,
4243} from "./scan/index.js" ;
4344import { registerEmitCommand } from "./scan-emit-command.js" ;
@@ -69,7 +70,7 @@ export function registerFingerprintCommands(cli: CAC): void {
6970 )
7071 . option (
7172 "--memory-dir <relative-dir>" ,
72- "Relative fingerprint package directory for --all and default package lookup (flag name retained ; default: .ghost)" ,
73+ "Relative fingerprint package directory for host wrappers, --all, and default package lookup (env: GHOST_MEMORY_DIR ; default: .ghost)" ,
7374 )
7475 . action ( async ( path : string | undefined , opts ) => {
7576 try {
@@ -140,7 +141,7 @@ export function registerFingerprintCommands(cli: CAC): void {
140141 )
141142 . option (
142143 "--memory-dir <relative-dir>" ,
143- "Relative fingerprint package directory for init --scope or default root init (flag name retained ; default: .ghost)" ,
144+ "Relative fingerprint package directory for host wrappers, init --scope, and default root init (env: GHOST_MEMORY_DIR ; default: .ghost)" ,
144145 )
145146 . option (
146147 "--with-intent" ,
@@ -168,22 +169,23 @@ export function registerFingerprintCommands(cli: CAC): void {
168169 process . exit ( 2 ) ;
169170 return ;
170171 }
171- const memoryDir = memoryDirFromOpts ( opts ) ;
172+ const memoryDir =
173+ typeof opts . scope === "string" || dirArg === undefined
174+ ? memoryDirFromOpts ( opts )
175+ : undefined ;
172176 const initOptions = {
173177 withIntent : Boolean ( opts . withIntent ) ,
174178 withConfig : Boolean ( opts . withConfig || opts . reference ) ,
175179 reference :
176180 typeof opts . reference === "string" ? opts . reference : undefined ,
177181 force : Boolean ( opts . force ) ,
178- memoryDir,
179182 } ;
180183 const paths =
181184 typeof opts . scope === "string"
182- ? await initScopedFingerprintPackage (
183- opts . scope ,
184- process . cwd ( ) ,
185- initOptions ,
186- )
185+ ? await initScopedFingerprintPackage ( opts . scope , process . cwd ( ) , {
186+ ...initOptions ,
187+ memoryDir,
188+ } )
187189 : await initFingerprintPackage (
188190 dirArg ?? memoryDir ,
189191 process . cwd ( ) ,
@@ -242,7 +244,7 @@ export function registerFingerprintCommands(cli: CAC): void {
242244 )
243245 . option (
244246 "--memory-dir <relative-dir>" ,
245- "Relative fingerprint package directory for --all and default package lookup (flag name retained ; default: .ghost)" ,
247+ "Relative fingerprint package directory for host wrappers, --all, and default package lookup (env: GHOST_MEMORY_DIR ; default: .ghost)" ,
246248 )
247249 . action ( async ( dirArg : string | undefined , opts ) => {
248250 try {
@@ -295,7 +297,7 @@ export function registerFingerprintCommands(cli: CAC): void {
295297 )
296298 . option (
297299 "--memory-dir <relative-dir>" ,
298- "Relative fingerprint package directory for nested discovery and default scan (flag name retained ; default: .ghost)" ,
300+ "Relative fingerprint package directory for host wrappers, nested discovery, and default scan (env: GHOST_MEMORY_DIR ; default: .ghost)" ,
299301 )
300302 . option ( "--format <fmt>" , "Output format: cli or json" , { default : "cli" } )
301303 . action ( async ( dirArg : string | undefined , opts ) => {
@@ -729,9 +731,7 @@ function dirnameForFingerprintPackageDir(
729731}
730732
731733function memoryDirFromOpts ( opts : { memoryDir ?: unknown } ) : string {
732- return normalizeMemoryDir (
733- typeof opts . memoryDir === "string" ? opts . memoryDir : undefined ,
734- ) ;
734+ return resolveMemoryDirDefault ( opts . memoryDir ) ;
735735}
736736
737737function initCommandOutput (
0 commit comments