wingfoil 0.2.1
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/LICENSE +21 -0
- package/README.md +334 -0
- package/dist/cli/error.d.ts +11 -0
- package/dist/cli/error.d.ts.map +1 -0
- package/dist/cli/error.js +27 -0
- package/dist/cli/error.js.map +1 -0
- package/dist/cli/exit.d.ts +19 -0
- package/dist/cli/exit.d.ts.map +1 -0
- package/dist/cli/exit.js +14 -0
- package/dist/cli/exit.js.map +1 -0
- package/dist/cli/index.d.ts +28 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +36 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init-command.d.ts +34 -0
- package/dist/cli/init-command.d.ts.map +1 -0
- package/dist/cli/init-command.js +100 -0
- package/dist/cli/init-command.js.map +1 -0
- package/dist/cli/mcp-command.d.ts +24 -0
- package/dist/cli/mcp-command.d.ts.map +1 -0
- package/dist/cli/mcp-command.js +42 -0
- package/dist/cli/mcp-command.js.map +1 -0
- package/dist/cli/output.d.ts +13 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +28 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/program.d.ts +12 -0
- package/dist/cli/program.d.ts.map +1 -0
- package/dist/cli/program.js +279 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli/registrar.d.ts +69 -0
- package/dist/cli/registrar.d.ts.map +1 -0
- package/dist/cli/registrar.js +82 -0
- package/dist/cli/registrar.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +45 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/approval-authority.d.ts +83 -0
- package/dist/core/approval-authority.d.ts.map +1 -0
- package/dist/core/approval-authority.js +112 -0
- package/dist/core/approval-authority.js.map +1 -0
- package/dist/core/builtin-asset.d.ts +71 -0
- package/dist/core/builtin-asset.d.ts.map +1 -0
- package/dist/core/builtin-asset.js +137 -0
- package/dist/core/builtin-asset.js.map +1 -0
- package/dist/core/builtin-integrity.d.ts +32 -0
- package/dist/core/builtin-integrity.d.ts.map +1 -0
- package/dist/core/builtin-integrity.js +148 -0
- package/dist/core/builtin-integrity.js.map +1 -0
- package/dist/core/confinement.d.ts +57 -0
- package/dist/core/confinement.d.ts.map +1 -0
- package/dist/core/confinement.js +108 -0
- package/dist/core/confinement.js.map +1 -0
- package/dist/core/context.d.ts +187 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/context.js +192 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/directive-assign.d.ts +131 -0
- package/dist/core/directive-assign.d.ts.map +1 -0
- package/dist/core/directive-assign.js +352 -0
- package/dist/core/directive-assign.js.map +1 -0
- package/dist/core/directives-list.d.ts +80 -0
- package/dist/core/directives-list.d.ts.map +1 -0
- package/dist/core/directives-list.js +148 -0
- package/dist/core/directives-list.js.map +1 -0
- package/dist/core/exit-code.d.ts +85 -0
- package/dist/core/exit-code.d.ts.map +1 -0
- package/dist/core/exit-code.js +163 -0
- package/dist/core/exit-code.js.map +1 -0
- package/dist/core/git-identity.d.ts +32 -0
- package/dist/core/git-identity.d.ts.map +1 -0
- package/dist/core/git-identity.js +72 -0
- package/dist/core/git-identity.js.map +1 -0
- package/dist/core/index.d.ts +388 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +1331 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/init.d.ts +78 -0
- package/dist/core/init.d.ts.map +1 -0
- package/dist/core/init.js +167 -0
- package/dist/core/init.js.map +1 -0
- package/dist/core/loaders.d.ts +174 -0
- package/dist/core/loaders.d.ts.map +1 -0
- package/dist/core/loaders.js +364 -0
- package/dist/core/loaders.js.map +1 -0
- package/dist/core/memory-add-type.d.ts +43 -0
- package/dist/core/memory-add-type.d.ts.map +1 -0
- package/dist/core/memory-add-type.js +151 -0
- package/dist/core/memory-add-type.js.map +1 -0
- package/dist/core/memory-transition.d.ts +111 -0
- package/dist/core/memory-transition.d.ts.map +1 -0
- package/dist/core/memory-transition.js +269 -0
- package/dist/core/memory-transition.js.map +1 -0
- package/dist/core/registry.d.ts +189 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +66 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/relevance.d.ts +86 -0
- package/dist/core/relevance.d.ts.map +1 -0
- package/dist/core/relevance.js +258 -0
- package/dist/core/relevance.js.map +1 -0
- package/dist/core/require-reason.d.ts +27 -0
- package/dist/core/require-reason.d.ts.map +1 -0
- package/dist/core/require-reason.js +95 -0
- package/dist/core/require-reason.js.map +1 -0
- package/dist/core/types.d.ts +45 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +22 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/usage-error.d.ts +20 -0
- package/dist/core/usage-error.d.ts.map +1 -0
- package/dist/core/usage-error.js +29 -0
- package/dist/core/usage-error.js.map +1 -0
- package/dist/core/write-guard.d.ts +99 -0
- package/dist/core/write-guard.d.ts.map +1 -0
- package/dist/core/write-guard.js +247 -0
- package/dist/core/write-guard.js.map +1 -0
- package/dist/directives/create.d.ts +47 -0
- package/dist/directives/create.d.ts.map +1 -0
- package/dist/directives/create.js +82 -0
- package/dist/directives/create.js.map +1 -0
- package/dist/directives/index.d.ts +20 -0
- package/dist/directives/index.d.ts.map +1 -0
- package/dist/directives/index.js +32 -0
- package/dist/directives/index.js.map +1 -0
- package/dist/directives/roles-edit.d.ts +53 -0
- package/dist/directives/roles-edit.d.ts.map +1 -0
- package/dist/directives/roles-edit.js +286 -0
- package/dist/directives/roles-edit.js.map +1 -0
- package/dist/directives/schema.d.ts +65 -0
- package/dist/directives/schema.d.ts.map +1 -0
- package/dist/directives/schema.js +68 -0
- package/dist/directives/schema.js.map +1 -0
- package/dist/dna/edit.d.ts +61 -0
- package/dist/dna/edit.d.ts.map +1 -0
- package/dist/dna/edit.js +429 -0
- package/dist/dna/edit.js.map +1 -0
- package/dist/dna/index.d.ts +24 -0
- package/dist/dna/index.d.ts.map +1 -0
- package/dist/dna/index.js +59 -0
- package/dist/dna/index.js.map +1 -0
- package/dist/dna/mutate.d.ts +74 -0
- package/dist/dna/mutate.d.ts.map +1 -0
- package/dist/dna/mutate.js +318 -0
- package/dist/dna/mutate.js.map +1 -0
- package/dist/dna/path.d.ts +175 -0
- package/dist/dna/path.d.ts.map +1 -0
- package/dist/dna/path.js +289 -0
- package/dist/dna/path.js.map +1 -0
- package/dist/dna/roles.d.ts +57 -0
- package/dist/dna/roles.d.ts.map +1 -0
- package/dist/dna/roles.js +50 -0
- package/dist/dna/roles.js.map +1 -0
- package/dist/dna/schema.d.ts +172 -0
- package/dist/dna/schema.d.ts.map +1 -0
- package/dist/dna/schema.js +182 -0
- package/dist/dna/schema.js.map +1 -0
- package/dist/dna/set.d.ts +145 -0
- package/dist/dna/set.d.ts.map +1 -0
- package/dist/dna/set.js +428 -0
- package/dist/dna/set.js.map +1 -0
- package/dist/mcp/dna-resource.d.ts +16 -0
- package/dist/mcp/dna-resource.d.ts.map +1 -0
- package/dist/mcp/dna-resource.js +56 -0
- package/dist/mcp/dna-resource.js.map +1 -0
- package/dist/mcp/index.d.ts +49 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +60 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/memory-resource.d.ts +17 -0
- package/dist/mcp/memory-resource.d.ts.map +1 -0
- package/dist/mcp/memory-resource.js +133 -0
- package/dist/mcp/memory-resource.js.map +1 -0
- package/dist/mcp/prompt.d.ts +48 -0
- package/dist/mcp/prompt.d.ts.map +1 -0
- package/dist/mcp/prompt.js +176 -0
- package/dist/mcp/prompt.js.map +1 -0
- package/dist/mcp/read-only.d.ts +42 -0
- package/dist/mcp/read-only.d.ts.map +1 -0
- package/dist/mcp/read-only.js +93 -0
- package/dist/mcp/read-only.js.map +1 -0
- package/dist/mcp/registrar.d.ts +54 -0
- package/dist/mcp/registrar.d.ts.map +1 -0
- package/dist/mcp/registrar.js +72 -0
- package/dist/mcp/registrar.js.map +1 -0
- package/dist/mcp/server.d.ts +58 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +64 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/workflow-resource.d.ts +17 -0
- package/dist/mcp/workflow-resource.d.ts.map +1 -0
- package/dist/mcp/workflow-resource.js +63 -0
- package/dist/mcp/workflow-resource.js.map +1 -0
- package/dist/memory/add.d.ts +50 -0
- package/dist/memory/add.d.ts.map +1 -0
- package/dist/memory/add.js +131 -0
- package/dist/memory/add.js.map +1 -0
- package/dist/memory/audit.d.ts +177 -0
- package/dist/memory/audit.d.ts.map +1 -0
- package/dist/memory/audit.js +287 -0
- package/dist/memory/audit.js.map +1 -0
- package/dist/memory/commit-message.d.ts +146 -0
- package/dist/memory/commit-message.d.ts.map +1 -0
- package/dist/memory/commit-message.js +203 -0
- package/dist/memory/commit-message.js.map +1 -0
- package/dist/memory/entry.d.ts +56 -0
- package/dist/memory/entry.d.ts.map +1 -0
- package/dist/memory/entry.js +28 -0
- package/dist/memory/entry.js.map +1 -0
- package/dist/memory/frontmatter-edit.d.ts +68 -0
- package/dist/memory/frontmatter-edit.d.ts.map +1 -0
- package/dist/memory/frontmatter-edit.js +333 -0
- package/dist/memory/frontmatter-edit.js.map +1 -0
- package/dist/memory/git-log.d.ts +32 -0
- package/dist/memory/git-log.d.ts.map +1 -0
- package/dist/memory/git-log.js +100 -0
- package/dist/memory/git-log.js.map +1 -0
- package/dist/memory/history.d.ts +142 -0
- package/dist/memory/history.d.ts.map +1 -0
- package/dist/memory/history.js +250 -0
- package/dist/memory/history.js.map +1 -0
- package/dist/memory/index.d.ts +58 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +107 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/query.d.ts +150 -0
- package/dist/memory/query.d.ts.map +1 -0
- package/dist/memory/query.js +307 -0
- package/dist/memory/query.js.map +1 -0
- package/dist/memory/reject.d.ts +11 -0
- package/dist/memory/reject.d.ts.map +1 -0
- package/dist/memory/reject.js +32 -0
- package/dist/memory/reject.js.map +1 -0
- package/dist/memory/schema.d.ts +104 -0
- package/dist/memory/schema.d.ts.map +1 -0
- package/dist/memory/schema.js +161 -0
- package/dist/memory/schema.js.map +1 -0
- package/dist/memory/state-machine.d.ts +166 -0
- package/dist/memory/state-machine.d.ts.map +1 -0
- package/dist/memory/state-machine.js +431 -0
- package/dist/memory/state-machine.js.map +1 -0
- package/dist/memory/submit.d.ts +11 -0
- package/dist/memory/submit.d.ts.map +1 -0
- package/dist/memory/submit.js +44 -0
- package/dist/memory/submit.js.map +1 -0
- package/dist/storage/builtin-directives.d.ts +54 -0
- package/dist/storage/builtin-directives.d.ts.map +1 -0
- package/dist/storage/builtin-directives.js +152 -0
- package/dist/storage/builtin-directives.js.map +1 -0
- package/dist/storage/commit.d.ts +92 -0
- package/dist/storage/commit.d.ts.map +1 -0
- package/dist/storage/commit.js +201 -0
- package/dist/storage/commit.js.map +1 -0
- package/dist/storage/confinement.d.ts +93 -0
- package/dist/storage/confinement.d.ts.map +1 -0
- package/dist/storage/confinement.js +164 -0
- package/dist/storage/confinement.js.map +1 -0
- package/dist/storage/document.d.ts +27 -0
- package/dist/storage/document.d.ts.map +1 -0
- package/dist/storage/document.js +52 -0
- package/dist/storage/document.js.map +1 -0
- package/dist/storage/errors.d.ts +36 -0
- package/dist/storage/errors.d.ts.map +1 -0
- package/dist/storage/errors.js +46 -0
- package/dist/storage/errors.js.map +1 -0
- package/dist/storage/frontmatter.d.ts +27 -0
- package/dist/storage/frontmatter.d.ts.map +1 -0
- package/dist/storage/frontmatter.js +37 -0
- package/dist/storage/frontmatter.js.map +1 -0
- package/dist/storage/git-root.d.ts +17 -0
- package/dist/storage/git-root.d.ts.map +1 -0
- package/dist/storage/git-root.js +49 -0
- package/dist/storage/git-root.js.map +1 -0
- package/dist/storage/index.d.ts +29 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +66 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/init-state.d.ts +9 -0
- package/dist/storage/init-state.d.ts.map +1 -0
- package/dist/storage/init-state.js +24 -0
- package/dist/storage/init-state.js.map +1 -0
- package/dist/storage/layout.d.ts +51 -0
- package/dist/storage/layout.d.ts.map +1 -0
- package/dist/storage/layout.js +88 -0
- package/dist/storage/layout.js.map +1 -0
- package/dist/storage/memory-path.d.ts +72 -0
- package/dist/storage/memory-path.d.ts.map +1 -0
- package/dist/storage/memory-path.js +127 -0
- package/dist/storage/memory-path.js.map +1 -0
- package/dist/storage/snapshot.d.ts +16 -0
- package/dist/storage/snapshot.d.ts.map +1 -0
- package/dist/storage/snapshot.js +72 -0
- package/dist/storage/snapshot.js.map +1 -0
- package/dist/storage/templates.d.ts +88 -0
- package/dist/storage/templates.d.ts.map +1 -0
- package/dist/storage/templates.js +422 -0
- package/dist/storage/templates.js.map +1 -0
- package/dist/validation/error-mapper.d.ts +16 -0
- package/dist/validation/error-mapper.d.ts.map +1 -0
- package/dist/validation/error-mapper.js +18 -0
- package/dist/validation/error-mapper.js.map +1 -0
- package/dist/validation/errors.d.ts +69 -0
- package/dist/validation/errors.d.ts.map +1 -0
- package/dist/validation/errors.js +69 -0
- package/dist/validation/errors.js.map +1 -0
- package/dist/validation/id.d.ts +16 -0
- package/dist/validation/id.d.ts.map +1 -0
- package/dist/validation/id.js +177 -0
- package/dist/validation/id.js.map +1 -0
- package/dist/validation/index.d.ts +18 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +37 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/secret-scan.d.ts +129 -0
- package/dist/validation/secret-scan.d.ts.map +1 -0
- package/dist/validation/secret-scan.js +367 -0
- package/dist/validation/secret-scan.js.map +1 -0
- package/dist/validation/two-pass.d.ts +24 -0
- package/dist/validation/two-pass.d.ts.map +1 -0
- package/dist/validation/two-pass.js +24 -0
- package/dist/validation/two-pass.js.map +1 -0
- package/dist/validation/warning.d.ts +31 -0
- package/dist/validation/warning.d.ts.map +1 -0
- package/dist/validation/warning.js +81 -0
- package/dist/validation/warning.js.map +1 -0
- package/dist/validation/yaml.d.ts +9 -0
- package/dist/validation/yaml.d.ts.map +1 -0
- package/dist/validation/yaml.js +30 -0
- package/dist/validation/yaml.js.map +1 -0
- package/dist/workflow/index.d.ts +10 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +16 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/schema.d.ts +89 -0
- package/dist/workflow/schema.d.ts.map +1 -0
- package/dist/workflow/schema.js +73 -0
- package/dist/workflow/schema.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ROLES_YAML_PATH = exports.DIRECTIVES_DIR_PATH = exports.DNA_YAML_PATH = exports.MEMORY_YAML_PATH = void 0;
|
|
4
|
+
exports.loadMemoryYaml = loadMemoryYaml;
|
|
5
|
+
exports.loadMemoryYamlAtHead = loadMemoryYamlAtHead;
|
|
6
|
+
exports.loadDnaYaml = loadDnaYaml;
|
|
7
|
+
exports.loadDnaYamlAtHead = loadDnaYamlAtHead;
|
|
8
|
+
exports.loadWorkflowsYaml = loadWorkflowsYaml;
|
|
9
|
+
exports.loadDirectives = loadDirectives;
|
|
10
|
+
exports.loadDirectivesAtHead = loadDirectivesAtHead;
|
|
11
|
+
exports.loadRolesYaml = loadRolesYaml;
|
|
12
|
+
exports.loadRolesYamlAtHead = loadRolesYamlAtHead;
|
|
13
|
+
/**
|
|
14
|
+
* Per-pillar loaders (task-004-decoupled-pillars, REQ-SYS-02). `core` exposes exactly one loader
|
|
15
|
+
* per pillar — `loadMemoryYaml`, `loadDnaYaml`, `loadWorkflowsYaml`, `loadDirectives` — each reading
|
|
16
|
+
* only its own artifact(s) under `.wingfoil/` (spec-011-storage-layout) through the shared two-pass
|
|
17
|
+
* validation pipeline (spec-009-validation-strategy): `storage.readDocument` for bytes,
|
|
18
|
+
* `validation.parseYaml` for the pre-Zod YAML parse, `validation.runValidation` for the Zod
|
|
19
|
+
* structural pass. No loader imports another pillar's schema module, and no loader reads another
|
|
20
|
+
* pillar's file(s) — that is what keeps adding a new Memory `type` (say) from ever requiring a
|
|
21
|
+
* change to `dna.yaml` or `workflows.yaml`, and is the structural guarantee the cross-pillar load
|
|
22
|
+
* test in `test/core/pillar-isolation.test.ts` exercises.
|
|
23
|
+
*/
|
|
24
|
+
const fs_1 = require("fs");
|
|
25
|
+
const path_1 = require("path");
|
|
26
|
+
const schema_1 = require("../directives/schema");
|
|
27
|
+
const schema_2 = require("../dna/schema");
|
|
28
|
+
const schema_3 = require("../memory/schema");
|
|
29
|
+
const storage_1 = require("../storage");
|
|
30
|
+
const validation_1 = require("../validation");
|
|
31
|
+
const schema_4 = require("../workflow/schema");
|
|
32
|
+
/**
|
|
33
|
+
* Recursively list every `.md` file under `dir`, as paths relative to `dir`, sorted
|
|
34
|
+
* lexicographically (REQ-SYS-07: no unordered iteration in a context-building path — directory-entry
|
|
35
|
+
* order from `readdirSync` is not guaranteed stable, so traversal always sorts explicitly, mirroring
|
|
36
|
+
* `src/storage/snapshot.ts`'s `listFilesSorted`). Returns `[]` if `dir` doesn't exist.
|
|
37
|
+
*/
|
|
38
|
+
function listMarkdownFilesSorted(dir) {
|
|
39
|
+
if (!(0, fs_1.existsSync)(dir) || !(0, fs_1.statSync)(dir).isDirectory())
|
|
40
|
+
return [];
|
|
41
|
+
const out = [];
|
|
42
|
+
const walk = (current, prefix) => {
|
|
43
|
+
for (const entry of (0, fs_1.readdirSync)(current).sort()) {
|
|
44
|
+
const full = (0, path_1.join)(current, entry);
|
|
45
|
+
const relative = prefix ? `${prefix}/${entry}` : entry;
|
|
46
|
+
if ((0, fs_1.statSync)(full).isDirectory()) {
|
|
47
|
+
walk(full, relative);
|
|
48
|
+
}
|
|
49
|
+
else if (entry.endsWith('.md')) {
|
|
50
|
+
out.push(relative);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
walk(dir, '');
|
|
55
|
+
return out.sort();
|
|
56
|
+
}
|
|
57
|
+
/** Load and validate `.wingfoil/memory.yaml` in isolation (spec-001-memory-yaml-schema). */
|
|
58
|
+
function loadMemoryYaml(root) {
|
|
59
|
+
const filePath = (0, path_1.join)(root, '.wingfoil', 'memory.yaml');
|
|
60
|
+
return parseMemoryYaml((0, storage_1.readDocument)(filePath), filePath);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Root-relative POSIX path of `memory.yaml` — the form git wants for a revision read
|
|
64
|
+
* (`<rev>:<path>`), as opposed to the platform `join` every on-disk read uses. Counterpart of
|
|
65
|
+
* {@link DNA_YAML_PATH} (task-091).
|
|
66
|
+
*/
|
|
67
|
+
exports.MEMORY_YAML_PATH = '.wingfoil/memory.yaml';
|
|
68
|
+
/**
|
|
69
|
+
* The Memory pillar's two-pass parse, over bytes that may come from anywhere — the working-tree file
|
|
70
|
+
* ({@link loadMemoryYaml}) or a git revision ({@link loadMemoryYamlAtHead}). `filePath` is a label
|
|
71
|
+
* only: it rides every issue this raises, so an error names the baseline it came from
|
|
72
|
+
* (`HEAD:.wingfoil/memory.yaml`, not just a path on disk).
|
|
73
|
+
*/
|
|
74
|
+
function parseMemoryYaml(raw, filePath) {
|
|
75
|
+
return (0, validation_1.runValidation)(schema_3.MemoryYaml, (0, validation_1.parseYaml)(raw, filePath), filePath);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Load and validate `.wingfoil/memory.yaml` **as the repository has committed it** — the version at
|
|
79
|
+
* `HEAD` — returning `null` when no commit of the repository contains that path (an untracked
|
|
80
|
+
* `memory.yaml`, or a repository with no commits at all). Same schema and same error shapes as
|
|
81
|
+
* {@link loadMemoryYaml}; only the source of the bytes differs.
|
|
82
|
+
*
|
|
83
|
+
* This is the baseline every Memory **state transition** resolves against
|
|
84
|
+
* (`prepareMemoryTransition`, `./memory-transition.ts`), per
|
|
85
|
+
* `dl-080-which-baseline-each-command-reads` option (B) — *a read that gates an operation resolves
|
|
86
|
+
* against the repository as committed at `HEAD`* — closing
|
|
87
|
+
* `bug-081-memory-yaml-read-from-worktree-fabricates-states`: an uncommitted edit to a type's
|
|
88
|
+
* `sequence` used to decide what transition a verb performed and what `status` it committed, through
|
|
89
|
+
* `memory submit`, which needs no authority at all, and left the element in a status the committed
|
|
90
|
+
* machine rejects, movable by no verb at all.
|
|
91
|
+
*
|
|
92
|
+
* `HEAD` rather than the commit being produced: a transition commit changes only the element path
|
|
93
|
+
* (`verifyCommittedScope`, task-088), so `memory.yaml` at `HEAD` and at the new commit are
|
|
94
|
+
* byte-identical, and `HEAD` is the one available before that commit exists.
|
|
95
|
+
*/
|
|
96
|
+
function loadMemoryYamlAtHead(root) {
|
|
97
|
+
const raw = (0, storage_1.readPathAtRev)(root, 'HEAD', exports.MEMORY_YAML_PATH);
|
|
98
|
+
if (raw === null)
|
|
99
|
+
return null;
|
|
100
|
+
return parseMemoryYaml(raw, `HEAD:${exports.MEMORY_YAML_PATH}`);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* `js-yaml`'s `YAMLException#message` always embeds the failure position as `(<line>:<column>)`
|
|
104
|
+
* (1-indexed) right after the reason text, ahead of the multi-line context snippet — verified across
|
|
105
|
+
* the common `load()` failure shapes (bad indentation, unclosed flow collection, block-mapping/key
|
|
106
|
+
* errors, tab-indentation), with a defensive `null` fallback for any that omit it.
|
|
107
|
+
* `parseYaml` (spec-009-validation-strategy §1) preserves this
|
|
108
|
+
* raw message verbatim in the single issue of the `E_YAML_PARSE_ERROR` `ValidationError` it throws.
|
|
109
|
+
* Returns `null` if the position marker isn't found (defensive — no known js-yaml failure omits it).
|
|
110
|
+
*/
|
|
111
|
+
function extractYamlErrorLine(message) {
|
|
112
|
+
const match = /\((\d+):\d+\)/.exec(message);
|
|
113
|
+
return match ? Number(match[1]) : null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Load and validate `.wingfoil/dna.yaml` in isolation (spec-002-dna-yaml-schema). On top of the
|
|
117
|
+
* shared two-pass pipeline every pillar loader uses, this re-wraps a YAML-syntax failure into P2.4's
|
|
118
|
+
* own fit criterion (BDD `P2.4-project-dna-config.feature` "Error - malformed YAML in the DNA file"):
|
|
119
|
+
* `invalid DNA: YAML parse error at line <n>`, rather than surfacing the generic `E_YAML_PARSE_ERROR`
|
|
120
|
+
* message every other pillar loader still uses as-is. DNA-scoped only — this does not change
|
|
121
|
+
* `parseYaml`/`ValidationError`'s shared behavior for `memory.yaml`/`workflows.yaml`/directives.
|
|
122
|
+
*/
|
|
123
|
+
function loadDnaYaml(root) {
|
|
124
|
+
return parseDnaYaml((0, storage_1.readDocument)((0, path_1.join)(root, '.wingfoil', 'dna.yaml')), (0, path_1.join)(root, '.wingfoil', 'dna.yaml'));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Root-relative POSIX path of `dna.yaml` — the form git wants for a revision read
|
|
128
|
+
* (`<rev>:<path>`), as opposed to the platform `join` every on-disk read uses (task-090).
|
|
129
|
+
*/
|
|
130
|
+
exports.DNA_YAML_PATH = '.wingfoil/dna.yaml';
|
|
131
|
+
/**
|
|
132
|
+
* The DNA pillar's two-pass parse, over bytes that may come from anywhere — the working-tree file
|
|
133
|
+
* ({@link loadDnaYaml}) or a git revision ({@link loadDnaYamlAtHead}). `filePath` is a label only: it
|
|
134
|
+
* rides every issue this raises, so an error names the baseline it came from
|
|
135
|
+
* (`HEAD:.wingfoil/dna.yaml`, not just a path on disk).
|
|
136
|
+
*/
|
|
137
|
+
function parseDnaYaml(raw, filePath) {
|
|
138
|
+
let data;
|
|
139
|
+
try {
|
|
140
|
+
data = (0, validation_1.parseYaml)(raw, filePath);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
if (err instanceof validation_1.ValidationError && err.issues[0]?.code === validation_1.E_YAML_PARSE_ERROR) {
|
|
144
|
+
const line = extractYamlErrorLine(err.issues[0].message);
|
|
145
|
+
const message = line !== null ? `invalid DNA: YAML parse error at line ${line}` : 'invalid DNA: YAML parse error';
|
|
146
|
+
throw new validation_1.ValidationError([{ ...err.issues[0], message }], err.exitCode);
|
|
147
|
+
}
|
|
148
|
+
throw err;
|
|
149
|
+
}
|
|
150
|
+
return (0, validation_1.runValidation)(schema_2.DnaYaml, data, filePath);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Load and validate `.wingfoil/dna.yaml` **as the repository has committed it** — the version at
|
|
154
|
+
* `HEAD` — returning `null` when no commit of the repository contains that path (an untracked
|
|
155
|
+
* `dna.yaml`, or a repository with no commits at all). Same schema and same error shapes as
|
|
156
|
+
* {@link loadDnaYaml}; only the source of the bytes differs.
|
|
157
|
+
*
|
|
158
|
+
* Its caller is `requireApprovalAuthority` (`./approval-authority.ts`, task-090 / `bug-079`) —
|
|
159
|
+
* joined by `checkAssignable` (`./directive-assign.ts`, task-091 / `bug-082`), which validates
|
|
160
|
+
* `directive assign`'s `--role` against the same committed catalogue: approval authority is a property of the
|
|
161
|
+
* repository, not of a working tree, so the roles it reads must be roles someone committed.
|
|
162
|
+
* `adr-006-git-identity-role-based-authz`'s own Positive consequence — a fresh clone "reproduces the
|
|
163
|
+
* full audit trail with zero extra infrastructure" — is what fixes the baseline: a clone carries
|
|
164
|
+
* committed state and nothing else, so an `Approver:` line resting on an uncommitted grant is
|
|
165
|
+
* evidence no clone can re-derive.
|
|
166
|
+
*
|
|
167
|
+
* `HEAD` rather than the produced commit: an approval commit changes only the element path
|
|
168
|
+
* (`verifyCommittedScope`, task-088), so `dna.yaml` at `HEAD` and at the commit being produced are
|
|
169
|
+
* byte-identical — the two shapes `bug-079`'s Expected Behavior offers cannot diverge, and `HEAD` is
|
|
170
|
+
* the one available before the commit exists.
|
|
171
|
+
*
|
|
172
|
+
* Deliberately NOT how the working-tree loaders behave — but no longer an exception argued for one
|
|
173
|
+
* read: `dl-080-which-baseline-each-command-reads` is `ready`, ratified as option (B), and **a read
|
|
174
|
+
* that gates an operation resolves at `HEAD`** is now the rule this and {@link loadMemoryYamlAtHead}
|
|
175
|
+
* implement. A read that gates nothing — `dna show`, `paths`, `directives list`, the MCP Resources —
|
|
176
|
+
* still reports the working tree, which is what those exist to do. (`bug-078` is (B)'s write half:
|
|
177
|
+
* a write refuses while its target carries modifications it does not own.)
|
|
178
|
+
*/
|
|
179
|
+
function loadDnaYamlAtHead(root) {
|
|
180
|
+
const raw = (0, storage_1.readPathAtRev)(root, 'HEAD', exports.DNA_YAML_PATH);
|
|
181
|
+
if (raw === null)
|
|
182
|
+
return null;
|
|
183
|
+
return parseDnaYaml(raw, `HEAD:${exports.DNA_YAML_PATH}`);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Load and validate the Workflow pillar in isolation (spec-003-workflows-yaml-schema): Layer 1
|
|
187
|
+
* (`.wingfoil/workflows.yaml`), then every file its `include` list names (Layer 2), resolved
|
|
188
|
+
* relative to `.wingfoil/` per spec-003. Two cross-file Pass-2 checks that need the loaded files
|
|
189
|
+
* themselves (spec-009 §1 "Cross-file" category) run here, not in the schema module:
|
|
190
|
+
*
|
|
191
|
+
* - every `include` path must resolve to a file that actually exists
|
|
192
|
+
* (`E_WORKFLOW_FILE_NOT_FOUND`, spec-003);
|
|
193
|
+
* - at least one loaded workflow must be `kind: main` (REQ-STATE-03 / spec-003 Layer 1 step 3).
|
|
194
|
+
*/
|
|
195
|
+
function loadWorkflowsYaml(root) {
|
|
196
|
+
const configDir = (0, path_1.join)(root, '.wingfoil');
|
|
197
|
+
const manifestPath = (0, path_1.join)(configDir, 'workflows.yaml');
|
|
198
|
+
const manifestRaw = (0, storage_1.readDocument)(manifestPath);
|
|
199
|
+
const manifestData = (0, validation_1.parseYaml)(manifestRaw, manifestPath);
|
|
200
|
+
const manifest = (0, validation_1.runValidation)(schema_4.WorkflowsYaml, manifestData, manifestPath);
|
|
201
|
+
const workflows = [];
|
|
202
|
+
for (const includePath of manifest.include) {
|
|
203
|
+
const workflowPath = (0, path_1.join)(configDir, includePath);
|
|
204
|
+
if (!(0, storage_1.documentExists)(workflowPath)) {
|
|
205
|
+
throw validation_1.ValidationError.semantic([
|
|
206
|
+
{
|
|
207
|
+
code: 'E_WORKFLOW_FILE_NOT_FOUND',
|
|
208
|
+
path: 'include',
|
|
209
|
+
file: manifestPath,
|
|
210
|
+
message: `included workflow file not found: ${includePath}`,
|
|
211
|
+
},
|
|
212
|
+
]);
|
|
213
|
+
}
|
|
214
|
+
const raw = (0, storage_1.readDocument)(workflowPath);
|
|
215
|
+
const data = (0, validation_1.parseYaml)(raw, workflowPath);
|
|
216
|
+
workflows.push((0, validation_1.runValidation)(schema_4.Workflow, data, workflowPath));
|
|
217
|
+
}
|
|
218
|
+
if (!workflows.some((workflow) => workflow.kind === 'main')) {
|
|
219
|
+
throw validation_1.ValidationError.semantic([
|
|
220
|
+
{
|
|
221
|
+
code: 'E_NO_MAIN_WORKFLOW',
|
|
222
|
+
path: 'include',
|
|
223
|
+
file: manifestPath,
|
|
224
|
+
message: 'at least one included workflow must be `kind: main` (REQ-STATE-03)',
|
|
225
|
+
},
|
|
226
|
+
]);
|
|
227
|
+
}
|
|
228
|
+
return { manifest, workflows };
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Root-relative POSIX path of the Directives tree — the form git wants for a revision listing, as
|
|
232
|
+
* opposed to the platform `join` every on-disk read uses. Counterpart of {@link DNA_YAML_PATH} /
|
|
233
|
+
* {@link MEMORY_YAML_PATH} for the one pillar whose baseline is a **directory** (task-096).
|
|
234
|
+
*/
|
|
235
|
+
exports.DIRECTIVES_DIR_PATH = '.wingfoil/directives';
|
|
236
|
+
/**
|
|
237
|
+
* The Directives pillar's per-file parse, over bytes that may come from anywhere — the working-tree
|
|
238
|
+
* file ({@link loadDirectives}) or a git revision ({@link loadDirectivesAtHead}). `filePath` is a
|
|
239
|
+
* label only: it rides every issue this raises, so an error names the baseline it came from
|
|
240
|
+
* (`HEAD:.wingfoil/directives/custom/x.md`, not just a path on disk). Lifted out so the two loaders
|
|
241
|
+
* cannot drift on what a directive file *is*.
|
|
242
|
+
*
|
|
243
|
+
* @param relativePath - The file's path relative to `.wingfoil/directives/`, POSIX-spelled.
|
|
244
|
+
*/
|
|
245
|
+
function parseDirectiveFile(raw, filePath, relativePath) {
|
|
246
|
+
const frontmatterText = (0, storage_1.extractFrontmatter)(raw);
|
|
247
|
+
if (frontmatterText === null) {
|
|
248
|
+
throw validation_1.ValidationError.semantic([
|
|
249
|
+
{
|
|
250
|
+
code: 'E_MISSING_FRONTMATTER',
|
|
251
|
+
path: '',
|
|
252
|
+
file: filePath,
|
|
253
|
+
message: 'directive file has no frontmatter block',
|
|
254
|
+
},
|
|
255
|
+
]);
|
|
256
|
+
}
|
|
257
|
+
const data = (0, validation_1.parseYaml)(frontmatterText, filePath);
|
|
258
|
+
const frontmatter = (0, validation_1.runValidation)(schema_1.DirectiveFrontmatter, data, filePath);
|
|
259
|
+
// `join`, so `DirectiveFile.path` carries the platform separator on both loaders — `requireCustomAsset`
|
|
260
|
+
// and `selectDirectivesById` see one spelling whichever baseline produced the file.
|
|
261
|
+
return { path: (0, path_1.join)('directives', ...relativePath.split('/')), frontmatter };
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Load and validate every Directives file in isolation (task-004-decoupled-pillars — see
|
|
265
|
+
* `src/directives/schema.ts` for why this pillar has no dedicated approved tech-spec yet). Reads
|
|
266
|
+
* every `.md` file under `.wingfoil/directives/**` (built-in + custom) **in the working tree**,
|
|
267
|
+
* sorted deterministically (REQ-SYS-07: no unordered iteration in a context-building path), extracts
|
|
268
|
+
* its frontmatter (`storage.extractFrontmatter`), and validates it against `DirectiveFrontmatter`.
|
|
269
|
+
*
|
|
270
|
+
* This is the *report* baseline — what the user has now — and it is what `directives list`, context
|
|
271
|
+
* assembly and the MCP Resources read. A read that **gates** a mutation reads
|
|
272
|
+
* {@link loadDirectivesAtHead} instead (`dl-080` (B)).
|
|
273
|
+
*/
|
|
274
|
+
function loadDirectives(root) {
|
|
275
|
+
const directivesDir = (0, path_1.join)(root, '.wingfoil', 'directives');
|
|
276
|
+
return listMarkdownFilesSorted(directivesDir).map((relativePath) => parseDirectiveFile((0, storage_1.readDocument)((0, path_1.join)(directivesDir, relativePath)), (0, path_1.join)(directivesDir, relativePath), relativePath));
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Load and validate every Directives file **as the repository has committed it** — the tree at
|
|
280
|
+
* `HEAD`.
|
|
281
|
+
*
|
|
282
|
+
* This is the inventory a read that gates a mutation resolves against
|
|
283
|
+
* (`checkAssignable`, `./directive-assign.ts`), per `dl-080-which-baseline-each-command-reads` option
|
|
284
|
+
* (B), closing the `assign` half of `bug-086-directive-inventory-read-from-the-worktree`: an
|
|
285
|
+
* untracked directive file used to be bindable, and the committed `roles.yaml` then named a directive
|
|
286
|
+
* present in no commit — a dangling reference by construction, since every other clone gets the
|
|
287
|
+
* binding without the file (REQ-SYS-08's referential integrity, the same way `bug-082` broke it for
|
|
288
|
+
* `--role`).
|
|
289
|
+
*
|
|
290
|
+
* Unlike every other committed-baseline loader, this one needs a **directory listing at a revision**
|
|
291
|
+
* (`storage.listPathsAtRev`, task-096) rather than one `readPathAtRev`: the pillar's members are
|
|
292
|
+
* discovered, not named in advance. That missing primitive is why `task-091` deferred this half.
|
|
293
|
+
*
|
|
294
|
+
* Same schema and same error shapes as {@link loadDirectives}; only the source of the bytes differs.
|
|
295
|
+
*
|
|
296
|
+
* Returns an **array, never `null`**, unlike its three sibling committed-baseline loaders. They read
|
|
297
|
+
* one named file, where "not committed" and "committed but empty" are different facts a caller may
|
|
298
|
+
* need to tell apart; here the two collapse — a `HEAD` that does not resolve (no commits at all) and
|
|
299
|
+
* a `HEAD` that commits no directive file both mean *the repository records no directive*, and both
|
|
300
|
+
* produce the same refusal from the only gate that consults this (`checkAssignable`: every id is
|
|
301
|
+
* unknown). `listPathsAtRev` keeps the distinction for callers that do need it.
|
|
302
|
+
*/
|
|
303
|
+
function loadDirectivesAtHead(root) {
|
|
304
|
+
const paths = (0, storage_1.listPathsAtRev)(root, 'HEAD', exports.DIRECTIVES_DIR_PATH) ?? [];
|
|
305
|
+
const files = [];
|
|
306
|
+
for (const path of paths) {
|
|
307
|
+
if (!path.endsWith('.md'))
|
|
308
|
+
continue;
|
|
309
|
+
const raw = (0, storage_1.readPathAtRev)(root, 'HEAD', path);
|
|
310
|
+
// Unreachable by construction — git has just listed this blob. Reachable only if the ref moved
|
|
311
|
+
// between the two calls, and skipping is the fail-closed answer there: a directive nobody can read
|
|
312
|
+
// is a directive that does not exist, so a binding to it is refused rather than committed.
|
|
313
|
+
if (raw === null)
|
|
314
|
+
continue;
|
|
315
|
+
files.push(parseDirectiveFile(raw, `HEAD:${path}`, path.slice(exports.DIRECTIVES_DIR_PATH.length + 1)));
|
|
316
|
+
}
|
|
317
|
+
return files;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Root-relative POSIX path of `roles.yaml` — the form git wants for a revision read (`<rev>:<path>`),
|
|
321
|
+
* as opposed to the platform `join` every on-disk read uses. It lived in `./directive-assign.ts` until
|
|
322
|
+
* task-096 moved it here, beside {@link DNA_YAML_PATH} / {@link MEMORY_YAML_PATH} and beside the
|
|
323
|
+
* committed-baseline reader that uses it; `./directive-assign.ts` now **imports** it like any other
|
|
324
|
+
* caller, and `src/core`'s barrel exports it from here.
|
|
325
|
+
*/
|
|
326
|
+
exports.ROLES_YAML_PATH = '.wingfoil/roles.yaml';
|
|
327
|
+
/**
|
|
328
|
+
* Load and validate `.wingfoil/roles.yaml` in isolation (task-037-role-task-scoped-context,
|
|
329
|
+
* REQ-STATE-05's `directive-loader`, P3.2/P3.7 role → directive bindings) — the same shared two-pass
|
|
330
|
+
* pipeline (`readDocument` + `parseYaml` + `runValidation`) every other pillar loader uses, so this
|
|
331
|
+
* pillar's own validation never depends on another pillar's schema (REQ-SYS-02). Consumed by
|
|
332
|
+
* `resolveRoleDirectives`/`assembleExecutionContext` (`./context.ts`) to resolve a role's assigned
|
|
333
|
+
* directives.
|
|
334
|
+
*/
|
|
335
|
+
function loadRolesYaml(root) {
|
|
336
|
+
const filePath = (0, path_1.join)(root, '.wingfoil', 'roles.yaml');
|
|
337
|
+
const raw = (0, storage_1.readDocument)(filePath);
|
|
338
|
+
const data = (0, validation_1.parseYaml)(raw, filePath);
|
|
339
|
+
return (0, validation_1.runValidation)(schema_1.RolesYaml, data, filePath);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Load and validate `.wingfoil/roles.yaml` **as the repository has committed it** — the version at
|
|
343
|
+
* `HEAD` — returning `null` when no commit contains that path (an untracked `roles.yaml`, a committed
|
|
344
|
+
* deletion of it, or a repository with no commits).
|
|
345
|
+
*
|
|
346
|
+
* This is the baseline REQ-SEC-07 clause (b) is answered from (`checkUnreferenced`,
|
|
347
|
+
* `./directive-assign.ts`), per `dl-080-which-baseline-each-command-reads` option (B), closing the
|
|
348
|
+
* `remove` half of `bug-086-directive-inventory-read-from-the-worktree`: an **uncommitted** deletion
|
|
349
|
+
* of the two `- <id>` lines was enough to delete a directive file the committed `roles.yaml` still
|
|
350
|
+
* bound — on the only verb in the system that destroys an artefact.
|
|
351
|
+
*
|
|
352
|
+
* `null` is not an error and does not fail closed there, unlike `loadDnaYamlAtHead`'s: "is anything
|
|
353
|
+
* still referencing this asset" is a question a missing record *answers*, with "nothing" (which is
|
|
354
|
+
* also how an absent `roles.yaml` has always been read — "no bindings yet", task-051/task-053). A
|
|
355
|
+
* committed `roles.yaml` that does not **validate** is the different case, and that one does refuse.
|
|
356
|
+
*/
|
|
357
|
+
function loadRolesYamlAtHead(root) {
|
|
358
|
+
const raw = (0, storage_1.readPathAtRev)(root, 'HEAD', exports.ROLES_YAML_PATH);
|
|
359
|
+
if (raw === null)
|
|
360
|
+
return null;
|
|
361
|
+
const label = `HEAD:${exports.ROLES_YAML_PATH}`;
|
|
362
|
+
return (0, validation_1.runValidation)(schema_1.RolesYaml, (0, validation_1.parseYaml)(raw, label), label);
|
|
363
|
+
}
|
|
364
|
+
//# sourceMappingURL=loaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loaders.js","sourceRoot":"","sources":["../../src/core/loaders.ts"],"names":[],"mappings":";;;AA8CA,wCAGC;AAsCD,oDAIC;AAwBD,kCAEC;AAwDD,8CAIC;AAkBD,8CAqCC;AAsDD,wCAKC;AA2BD,oDAaC;AAmBD,sCAKC;AAkBD,kDAKC;AA1XD;;;;;;;;;;GAUG;AACH,2BAAuD;AACvD,+BAA4B;AAE5B,iDAAuE;AACvE,0CAAwC;AACxC,6CAA8C;AAC9C,wCAA6G;AAC7G,8CAA8F;AAC9F,+CAA6D;AAE7D;;;;;GAKG;AACH,SAAS,uBAAuB,CAAC,GAAW;IAC1C,IAAI,CAAC,IAAA,eAAU,EAAC,GAAG,CAAC,IAAI,CAAC,IAAA,aAAQ,EAAC,GAAG,CAAC,CAAC,WAAW,EAAE;QAAE,OAAO,EAAE,CAAC;IAChE,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,CAAC,OAAe,EAAE,MAAc,EAAQ,EAAE;QACrD,KAAK,MAAM,KAAK,IAAI,IAAA,gBAAW,EAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAClC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;YACvD,IAAI,IAAA,aAAQ,EAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;gBACjC,IAAI,CAA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QAAQ,GAAG,IAAA,WAAI,EAAC,IAAI,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,IAAA,sBAAY,EAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,IAAA,sBAAS,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACtC,OAAO,IAAA,0BAAa,EAAC,kBAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAC,IAAI,EAAE,MAAM,EAAE,uBAAe,CAAC,CAAC;IACzD,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM,KAAK,GAAG,QAAQ,uBAAe,EAAE,CAAC;IACxC,OAAO,IAAA,0BAAa,EAAC,kBAAS,EAAE,IAAA,sBAAS,EAAC,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TemplateConfig } from '../memory';
|
|
2
|
+
import { type CoreResult } from './types';
|
|
3
|
+
/** Everything `memory add` needs about a type, all of it resolved from the same committed baseline. */
|
|
4
|
+
export interface ResolvedAddType {
|
|
5
|
+
/** The requested type name, as registered in the committed `memory.yaml`. */
|
|
6
|
+
readonly type: string;
|
|
7
|
+
/** The type's `path` pattern (e.g. `docs/memory/adr/{id}.md`), from `HEAD`. */
|
|
8
|
+
readonly pathPattern: string;
|
|
9
|
+
/** The type's `id_pattern` (e.g. `adr-{n}-{slug}`), from `HEAD`. */
|
|
10
|
+
readonly idPattern: string;
|
|
11
|
+
/** The type's `template` block, from `HEAD` — its `frontmatter.required` included. */
|
|
12
|
+
readonly template: TemplateConfig;
|
|
13
|
+
/** Root-relative POSIX path of `template.file`, the form git wants for a revision read. */
|
|
14
|
+
readonly templatePath: string;
|
|
15
|
+
/** The scaffold's bytes **as committed at `HEAD`**, the text `renderAddDocument` fills in. */
|
|
16
|
+
readonly scaffold: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve `type` against the `memory.yaml` **committed at `HEAD`** and return its `path`,
|
|
20
|
+
* `id_pattern`, `template` and the scaffold's committed bytes.
|
|
21
|
+
*
|
|
22
|
+
* Refusals, all returned (never thrown) and all exit `1` (`spec-005-cli-command-contract` § 1, as
|
|
23
|
+
* ruled on `bug-076`: a well-formed invocation failing a repository-state precondition is `1`, never
|
|
24
|
+
* `2`). Every one of them happens **before** anything is written, so "no file is created"
|
|
25
|
+
* (P1.3 sc.2) holds by construction:
|
|
26
|
+
*
|
|
27
|
+
* - `HEAD` holds no `memory.yaml` → `VALIDATION`, **fail-closed**. With no committed registry there
|
|
28
|
+
* is no `path` and no scaffold to create against, and the only fail-open available is the working
|
|
29
|
+
* tree, which is the defect. `wingfoil init` commits the registry *and* every scaffold it names in
|
|
30
|
+
* the scaffold commit, so no legitimate flow reaches this;
|
|
31
|
+
* - the committed `memory.yaml` does not parse or validate → `VALIDATION`, same reasoning;
|
|
32
|
+
* - the type is not registered → `NOT_FOUND` with P1.3 sc.2's pinned sentence
|
|
33
|
+
* `unknown memory type '<t>' (not defined in memory.yaml)`, verbatim and first;
|
|
34
|
+
* - the registered type declares no `id_pattern`/`template` → `VALIDATION`, unchanged wording;
|
|
35
|
+
* - `template.file` is not committed at `HEAD` → `VALIDATION`. An element copies a scaffold; copying
|
|
36
|
+
* one that exists in no commit is how `bug-085` put bytes from an untracked file into a permanent
|
|
37
|
+
* commit.
|
|
38
|
+
*
|
|
39
|
+
* The last three may carry a second sentence, appended only when the working tree and `HEAD` actually
|
|
40
|
+
* disagree about *this type* ({@link workingTreeEntry}).
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveAddType(root: string, type: string): CoreResult<ResolvedAddType>;
|
|
43
|
+
//# sourceMappingURL=memory-add-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-add-type.d.ts","sourceRoot":"","sources":["../../src/core/memory-add-type.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,WAAW,CAAC;AAK5D,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3D,uGAAuG;AACvG,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sFAAsF;IACtF,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,2FAA2F;IAC3F,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,8FAA8F;IAC9F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAmCD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,eAAe,CAAC,CAmEtF"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAddType = resolveAddType;
|
|
4
|
+
/**
|
|
5
|
+
* `memory add`'s type resolution, against the repository **as committed at `HEAD`**
|
|
6
|
+
* (task-095-memory-add-resolves-its-type-at-head, `bug-085`,
|
|
7
|
+
* `dl-080-which-baseline-each-command-reads` option (B): *a read that gates an operation resolves
|
|
8
|
+
* against the repository as committed at `HEAD`*).
|
|
9
|
+
*
|
|
10
|
+
* `memory add` asks three questions of its configuration before it writes anything — does this type
|
|
11
|
+
* exist, where do its files land, and which scaffold does it copy — and every one of them used to be
|
|
12
|
+
* answered from the working tree. An uncommitted `types:` entry was therefore enough to produce a
|
|
13
|
+
* *committed* element of a type no commit defines, and that element is **unreachable** afterwards:
|
|
14
|
+
* `memory submit` and `memory deprecate` both answer `document not found` and `memory search --type`
|
|
15
|
+
* finds nothing, which is indistinguishable from the element never having been created while the
|
|
16
|
+
* commit sits in the history.
|
|
17
|
+
*
|
|
18
|
+
* The shape follows `task-091`'s, by the one move this call site allows. That task removed the
|
|
19
|
+
* `MemoryYaml` **parameter** from `prepareMemoryTransition` and `checkAssignable`, so no caller could
|
|
20
|
+
* hand either a working-tree document even by accident. `memoryAddFn` had no such parameter to
|
|
21
|
+
* remove — the working-tree copy arrived through a `loadMemoryYaml(root)` call the verb made itself
|
|
22
|
+
* — so the equivalent is to move the whole decision **behind** {@link resolveAddType}, which takes a
|
|
23
|
+
* root and a type name and nothing else. The verb now holds no `MemoryYaml` at all, and there is no
|
|
24
|
+
* argument through which a working-tree registry could reach the decision. That property is enforced
|
|
25
|
+
* by the type checker rather than by a precondition someone must remember to run.
|
|
26
|
+
*
|
|
27
|
+
* @see `src/core/memory-transition.ts` for the same rule on the four state-transition verbs.
|
|
28
|
+
*/
|
|
29
|
+
const path_1 = require("path");
|
|
30
|
+
const storage_1 = require("../storage");
|
|
31
|
+
const validation_1 = require("../validation");
|
|
32
|
+
const loaders_1 = require("./loaders");
|
|
33
|
+
const types_1 = require("./types");
|
|
34
|
+
/** The directory every `template.file` path is relative to, matching `MEMORY_YAML_PATH`'s prefix. */
|
|
35
|
+
const WINGFOIL_DIR = '.wingfoil';
|
|
36
|
+
/**
|
|
37
|
+
* The working tree's entry for `type`, or `undefined` — the **diagnostic** half of this module, never
|
|
38
|
+
* the deciding half.
|
|
39
|
+
*
|
|
40
|
+
* Under a committed baseline a refusal can contradict the file open in the author's editor, and
|
|
41
|
+
* `memory.yaml` is precisely the file one edits while designing a new type. So when the two copies
|
|
42
|
+
* genuinely disagree *about this type*, say which one decided (`task-091`'s D5, `task-090`'s
|
|
43
|
+
* `workingTreeWouldGrant`). Any failure to read or parse the working-tree file is simply "no
|
|
44
|
+
* disagreement", so this can never change an outcome owned by `HEAD`.
|
|
45
|
+
*
|
|
46
|
+
* Note it is keyed on the type, not on the file being dirty: `memory.yaml` carrying an unrelated
|
|
47
|
+
* uncommitted edit adds nothing to the message.
|
|
48
|
+
*/
|
|
49
|
+
function workingTreeEntry(root, type) {
|
|
50
|
+
try {
|
|
51
|
+
return (0, loaders_1.loadMemoryYaml)(root).types[type];
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Whether the scaffold `template.file` names is present on disk — the same disagreement test. */
|
|
58
|
+
function workingTreeHasScaffold(root, templatePath) {
|
|
59
|
+
try {
|
|
60
|
+
return (0, storage_1.documentExists)((0, path_1.join)(root, templatePath));
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolve `type` against the `memory.yaml` **committed at `HEAD`** and return its `path`,
|
|
68
|
+
* `id_pattern`, `template` and the scaffold's committed bytes.
|
|
69
|
+
*
|
|
70
|
+
* Refusals, all returned (never thrown) and all exit `1` (`spec-005-cli-command-contract` § 1, as
|
|
71
|
+
* ruled on `bug-076`: a well-formed invocation failing a repository-state precondition is `1`, never
|
|
72
|
+
* `2`). Every one of them happens **before** anything is written, so "no file is created"
|
|
73
|
+
* (P1.3 sc.2) holds by construction:
|
|
74
|
+
*
|
|
75
|
+
* - `HEAD` holds no `memory.yaml` → `VALIDATION`, **fail-closed**. With no committed registry there
|
|
76
|
+
* is no `path` and no scaffold to create against, and the only fail-open available is the working
|
|
77
|
+
* tree, which is the defect. `wingfoil init` commits the registry *and* every scaffold it names in
|
|
78
|
+
* the scaffold commit, so no legitimate flow reaches this;
|
|
79
|
+
* - the committed `memory.yaml` does not parse or validate → `VALIDATION`, same reasoning;
|
|
80
|
+
* - the type is not registered → `NOT_FOUND` with P1.3 sc.2's pinned sentence
|
|
81
|
+
* `unknown memory type '<t>' (not defined in memory.yaml)`, verbatim and first;
|
|
82
|
+
* - the registered type declares no `id_pattern`/`template` → `VALIDATION`, unchanged wording;
|
|
83
|
+
* - `template.file` is not committed at `HEAD` → `VALIDATION`. An element copies a scaffold; copying
|
|
84
|
+
* one that exists in no commit is how `bug-085` put bytes from an untracked file into a permanent
|
|
85
|
+
* commit.
|
|
86
|
+
*
|
|
87
|
+
* The last three may carry a second sentence, appended only when the working tree and `HEAD` actually
|
|
88
|
+
* disagree about *this type* ({@link workingTreeEntry}).
|
|
89
|
+
*/
|
|
90
|
+
function resolveAddType(root, type) {
|
|
91
|
+
let committed;
|
|
92
|
+
try {
|
|
93
|
+
committed = (0, loaders_1.loadMemoryYamlAtHead)(root);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (!(error instanceof validation_1.ValidationError))
|
|
97
|
+
throw error;
|
|
98
|
+
return (0, types_1.coreErr)({
|
|
99
|
+
code: 'VALIDATION',
|
|
100
|
+
message: `cannot resolve the memory type registry: the committed '${loaders_1.MEMORY_YAML_PATH}' (at HEAD) is not readable as a ` +
|
|
101
|
+
`Memory configuration: ${error.message}. An element is created against the types the repository records ` +
|
|
102
|
+
'(dl-080), so the committed file must be valid; fix it and commit the fix, then retry.',
|
|
103
|
+
details: { issues: error.issues },
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (committed === null) {
|
|
107
|
+
return (0, types_1.coreErr)({
|
|
108
|
+
code: 'VALIDATION',
|
|
109
|
+
message: `cannot resolve the memory type registry: '${loaders_1.MEMORY_YAML_PATH}' is not committed at HEAD. An element is ` +
|
|
110
|
+
'created against a type the repository records, not one a working tree holds (dl-080); commit ' +
|
|
111
|
+
`'${loaders_1.MEMORY_YAML_PATH}' first, then retry.`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const entry = committed.types[type];
|
|
115
|
+
if (!entry) {
|
|
116
|
+
const uncommittedType = workingTreeEntry(root, type) !== undefined
|
|
117
|
+
? ` — the working tree's '${loaders_1.MEMORY_YAML_PATH}' defines it, but that change is not committed, and an element ` +
|
|
118
|
+
`is created against the committed registry (dl-080); commit '${loaders_1.MEMORY_YAML_PATH}' first, then retry`
|
|
119
|
+
: '';
|
|
120
|
+
return (0, types_1.coreErr)({
|
|
121
|
+
code: 'NOT_FOUND',
|
|
122
|
+
message: `unknown memory type '${type}' (not defined in memory.yaml)${uncommittedType}`,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const { path: pathPattern, id_pattern: idPattern, template } = entry;
|
|
126
|
+
if (idPattern === undefined || template === undefined) {
|
|
127
|
+
const live = workingTreeEntry(root, type);
|
|
128
|
+
const uncommittedShape = live !== undefined && live.id_pattern !== undefined && live.template !== undefined
|
|
129
|
+
? ` — the working tree's '${loaders_1.MEMORY_YAML_PATH}' gives it both, but that change is not committed; commit ` +
|
|
130
|
+
`'${loaders_1.MEMORY_YAML_PATH}' first, then retry`
|
|
131
|
+
: '';
|
|
132
|
+
return (0, types_1.coreErr)({
|
|
133
|
+
code: 'VALIDATION',
|
|
134
|
+
message: `memory type '${type}' has no id_pattern/template in memory.yaml${uncommittedShape}`,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
const templatePath = `${WINGFOIL_DIR}/${template.file}`;
|
|
138
|
+
const scaffold = (0, storage_1.readPathAtRev)(root, 'HEAD', templatePath);
|
|
139
|
+
if (scaffold === null) {
|
|
140
|
+
const tail = workingTreeHasScaffold(root, templatePath)
|
|
141
|
+
? `; the working tree holds it, but that file is in no commit — commit '${templatePath}' first, then retry`
|
|
142
|
+
: `; add '${templatePath}' and commit it, then retry`;
|
|
143
|
+
return (0, types_1.coreErr)({
|
|
144
|
+
code: 'VALIDATION',
|
|
145
|
+
message: `cannot read the scaffold for memory type '${type}': '${templatePath}' is not committed at HEAD. An element ` +
|
|
146
|
+
`copies the scaffold the repository records, not one a working tree holds (dl-080)${tail}.`,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return (0, types_1.coreOk)({ type, pathPattern, idPattern, template, templatePath, scaffold });
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=memory-add-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-add-type.js","sourceRoot":"","sources":["../../src/core/memory-add-type.ts"],"names":[],"mappings":";;AA2GA,wCAmEC;AA9KD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,+BAA4B;AAG5B,wCAA2D;AAC3D,8CAAgD;AAEhD,uCAAmF;AACnF,mCAA2D;AAkB3D,qGAAqG;AACrG,MAAM,YAAY,GAAG,WAAoB,CAAC;AAE1C;;;;;;;;;;;;GAYG;AACH,SAAS,gBAAgB,CAAC,IAAY,EAAE,IAAY;IAClD,IAAI,CAAC;QACH,OAAO,IAAA,wBAAc,EAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,kGAAkG;AAClG,SAAS,sBAAsB,CAAC,IAAY,EAAE,YAAoB;IAChE,IAAI,CAAC;QACH,OAAO,IAAA,wBAAc,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,IAAY;IACvD,IAAI,SAA4B,CAAC;IACjC,IAAI,CAAC;QACH,SAAS,GAAG,IAAA,8BAAoB,EAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,4BAAe,CAAC;YAAE,MAAM,KAAK,CAAC;QAC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