/**
 * Application Brief Store Implementation
 *
 * Concrete adapter for {@link IApplicationBriefStore}. Writes briefs
 * under `<SHEP_HOME>/application-briefs/<applicationId>.md`.
 *
 * Keeping briefs in the Shep home directory (instead of inside the
 * scaffolded project) gives us three wins:
 *   1. The user's project stays clean — no stray `SHEP_BRIEF.md`
 *      committed alongside their source code.
 *   2. Briefs are auditable and survive project deletion.
 *   3. Test isolation via `SHEP_HOME=<tmp>` works automatically.
 */
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { mkdir, writeFile } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import { injectable } from 'tsyringe';
import { getShepHomeDir } from './shep-directory.service.js';
/** Subdirectory (under Shep home) that holds one file per application. */
export const APPLICATION_BRIEFS_DIRNAME = 'application-briefs';
let ApplicationBriefStore = class ApplicationBriefStore {
    async write(applicationId, content) {
        if (!applicationId?.trim()) {
            throw new Error('ApplicationBriefStore.write: applicationId is required');
        }
        const briefPath = join(getShepHomeDir(), APPLICATION_BRIEFS_DIRNAME, `${applicationId}.md`);
        await mkdir(dirname(briefPath), { recursive: true });
        await writeFile(briefPath, content, 'utf-8');
        return briefPath;
    }
};
ApplicationBriefStore = __decorate([
    injectable()
], ApplicationBriefStore);
export { ApplicationBriefStore };
