{"version":"2.1.247","anchor":"hook-helper-that-collects-memory-files-from-every-parent-dir","canonical_anchor":"hook-helper-that-collects-memory-files-from-every-parent-dir","heading":"Hook helper that collects memory files from every parent directory","tier":"use","area":"Hooks","scope":null,"heads_up":null,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.247\/e\/hook-helper-that-collects-memory-files-from-every-parent-dir","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.247","markdown":"### Hook helper that collects memory files from every parent directory\n\nFunction hooks can call $.fs.ancestors to gather memory files from every parent directory.\n\n**What**\n\nFunction hooks can call `$.fs.ancestors`, which walks from the project directory up to the filesystem root and gathers named memory files along the way. It returns an empty list when project memory is turned off.\n\n**Details**\n\n- Skips the walk entirely when project memory is disabled, so the result is `[]` rather than an error.\n- Honours the approval flag for including files from outside the project.\n- Logs how many of the walked directories actually contained a match.\n\n**Evidence**\n\n`$.fs.ancestors`\n\n- Area: Hooks\n- Names: `$.fs.ancestors`\n- Tier: Use it now\n- Useful: 3\/5\n- Signal: 3\/5"}