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
package/dist/dna/edit.js
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyDnaEditInText = applyDnaEditInText;
|
|
4
|
+
/**
|
|
5
|
+
* The comment-preserving **structural** edit behind `dna add | remove | update` (task-093) — the
|
|
6
|
+
* sequence-aware sibling of `setDnaValueInText` (`task-063`, `bug-004-dna-set-strips-yaml-comments`).
|
|
7
|
+
*
|
|
8
|
+
* `setDnaValueInText` rewrites or inserts exactly one **mapping** line and skips every sequence branch
|
|
9
|
+
* by design, so it can express none of the four shapes `dl-081-dna-mutation-surface-shape`'s verbs
|
|
10
|
+
* write: a list of strings, an entry of a collection, a field inside an entry, or a list of strings
|
|
11
|
+
* inside an entry. Its fallback for a shape it cannot edit is a whole-file `js-yaml` `dump()` — correct,
|
|
12
|
+
* but it discards every comment token, including the inline `[SPEC]`/`[AUTHORING]` field-provenance
|
|
13
|
+
* annotations whose loss is exactly what `bug-004` filed. That fallback is rare for `dna set`; without
|
|
14
|
+
* this module it would be the **norm** for `dna add`, and the first structured write on a freshly
|
|
15
|
+
* `wingfoil init`-ed project would delete the scaffold's own guidance comments.
|
|
16
|
+
*
|
|
17
|
+
* The safety contract is `setDnaValueInText`'s, unchanged and strengthened: every candidate edit is
|
|
18
|
+
* verified by re-parsing it and comparing the **whole document** against the intended object before it
|
|
19
|
+
* is returned, and anything that cannot be done provably-minimally returns `undefined` so the caller
|
|
20
|
+
* falls back to `dump()` rather than writing something subtly wrong. A mis-located edit therefore
|
|
21
|
+
* cannot corrupt a file; at worst it costs the comments.
|
|
22
|
+
*
|
|
23
|
+
* Pure and deterministic (REQ-SYS-07): a function of `(text, edit, intended)` alone — no wall-clock, no
|
|
24
|
+
* randomness, no filesystem, and the input text is never mutated.
|
|
25
|
+
*/
|
|
26
|
+
const js_yaml_1 = require("js-yaml");
|
|
27
|
+
const set_1 = require("./set");
|
|
28
|
+
/** A block-mapping key line: optional `- `, a plain scalar key, `:`, then end-of-line or a space. */
|
|
29
|
+
const KEY_LINE = /^( *)(- )?([A-Za-z0-9_][A-Za-z0-9_.+-]*):(?=$| )(.*)$/;
|
|
30
|
+
/** Literal leading-space count. */
|
|
31
|
+
function indentOf(line) {
|
|
32
|
+
return line.length - line.trimStart().length;
|
|
33
|
+
}
|
|
34
|
+
/** Whether a line carries no content of its own (blank, or a whole-line comment). */
|
|
35
|
+
function isFiller(line) {
|
|
36
|
+
const trimmed = line.trim();
|
|
37
|
+
return trimmed === '' || trimmed.startsWith('#');
|
|
38
|
+
}
|
|
39
|
+
/** Parse a line as a block-mapping key, or `undefined` when it is not one. */
|
|
40
|
+
function keyLineAt(lines, index) {
|
|
41
|
+
const line = lines[index];
|
|
42
|
+
const match = KEY_LINE.exec(line);
|
|
43
|
+
if (match === null)
|
|
44
|
+
return undefined;
|
|
45
|
+
const lead = match[1].length;
|
|
46
|
+
const dash = match[2] !== undefined;
|
|
47
|
+
return { line: index, indent: lead + (dash ? 2 : 0), key: match[3], rest: match[4], dash, lead };
|
|
48
|
+
}
|
|
49
|
+
/** Whether a line opens a sequence item (`- …`) at exactly `indent`. */
|
|
50
|
+
function isItemLine(line, indent) {
|
|
51
|
+
return indentOf(line) === indent && line.trimStart().startsWith('-');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The lines belonging to the block under the key on `keyLine` — everything indented deeper, plus a
|
|
55
|
+
* sequence written at the key's own indentation (`key:` then `- item` in the same column, which YAML
|
|
56
|
+
* permits and some hand-written files use).
|
|
57
|
+
*/
|
|
58
|
+
function blockRegion(lines, key) {
|
|
59
|
+
let end = key.line + 1;
|
|
60
|
+
for (let i = key.line + 1; i < lines.length; i += 1) {
|
|
61
|
+
const line = lines[i];
|
|
62
|
+
if (line.trim() === '')
|
|
63
|
+
continue;
|
|
64
|
+
const indent = indentOf(line);
|
|
65
|
+
if (indent > key.indent || (indent === key.indent && line.trimStart().startsWith('-') && !key.dash)) {
|
|
66
|
+
end = i + 1;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
return { start: key.line + 1, end };
|
|
72
|
+
}
|
|
73
|
+
/** The column this block's own content starts at (its children's indentation). */
|
|
74
|
+
function childIndentOf(lines, region) {
|
|
75
|
+
for (let i = region.start; i < region.end; i += 1) {
|
|
76
|
+
const line = lines[i];
|
|
77
|
+
if (isFiller(line))
|
|
78
|
+
continue;
|
|
79
|
+
const indent = indentOf(line);
|
|
80
|
+
return line.trimStart().startsWith('- ') || line.trim() === '-' ? indent + 2 : indent;
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
/** Find `key` among the mapping keys directly inside `region` at `indent`. */
|
|
85
|
+
function findKey(lines, region, indent, key) {
|
|
86
|
+
for (let i = region.start; i < region.end; i += 1) {
|
|
87
|
+
if (isFiller(lines[i]))
|
|
88
|
+
continue;
|
|
89
|
+
const candidate = keyLineAt(lines, i);
|
|
90
|
+
if (candidate === undefined || candidate.indent !== indent || candidate.key !== key)
|
|
91
|
+
continue;
|
|
92
|
+
return candidate;
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
/** The line spans of the sequence items directly inside `region`, in order. */
|
|
97
|
+
function itemSpans(lines, region) {
|
|
98
|
+
let itemIndent;
|
|
99
|
+
const starts = [];
|
|
100
|
+
for (let i = region.start; i < region.end; i += 1) {
|
|
101
|
+
const line = lines[i];
|
|
102
|
+
if (isFiller(line))
|
|
103
|
+
continue;
|
|
104
|
+
const indent = indentOf(line);
|
|
105
|
+
if (itemIndent === undefined) {
|
|
106
|
+
if (!line.trimStart().startsWith('-'))
|
|
107
|
+
return [];
|
|
108
|
+
itemIndent = indent;
|
|
109
|
+
}
|
|
110
|
+
if (isItemLine(line, itemIndent))
|
|
111
|
+
starts.push(i);
|
|
112
|
+
}
|
|
113
|
+
return starts.map((start, position) => ({ start, end: starts[position + 1] ?? region.end }));
|
|
114
|
+
}
|
|
115
|
+
/** Follow `path` through the text, returning where its last step lands — or `undefined` if it is absent. */
|
|
116
|
+
function locate(lines, path) {
|
|
117
|
+
let cursor = { region: { start: 0, end: lines.length }, indent: 0 };
|
|
118
|
+
for (const step of path) {
|
|
119
|
+
if ('key' in step) {
|
|
120
|
+
const key = findKey(lines, cursor.region, cursor.indent, step.key);
|
|
121
|
+
if (key === undefined)
|
|
122
|
+
return undefined;
|
|
123
|
+
const region = blockRegion(lines, key);
|
|
124
|
+
cursor = { region, indent: childIndentOf(lines, region) ?? key.indent + 2, key };
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const spans = itemSpans(lines, cursor.region);
|
|
128
|
+
const span = spans[step.index];
|
|
129
|
+
if (span === undefined)
|
|
130
|
+
return undefined;
|
|
131
|
+
cursor = { region: span, indent: childIndentOf(lines, span) ?? cursor.indent + 2 };
|
|
132
|
+
}
|
|
133
|
+
return cursor;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Render a value as the single-line YAML token `js-yaml` itself would emit — which is what keeps this
|
|
137
|
+
* editor's bytes identical to the whole-file `dump()` fallback's at the same position, including
|
|
138
|
+
* defensive quoting (`'2'` stays a string, `'y'` is quoted because YAML 1.1 reads a bare `y` as a
|
|
139
|
+
* boolean).
|
|
140
|
+
*
|
|
141
|
+
* `flowLevel: 0` is what makes the result always a single line: every container is emitted in flow
|
|
142
|
+
* style and every scalar escaped rather than folded, so a value carrying a newline comes back as
|
|
143
|
+
* `"a\nb"` rather than a block scalar. That is why this returns a `string` and not `string |
|
|
144
|
+
* undefined` — there is no value the callers can pass that has no single-line form.
|
|
145
|
+
*/
|
|
146
|
+
function renderInline(value) {
|
|
147
|
+
return (0, js_yaml_1.dump)(value, { lineWidth: -1, flowLevel: 0 }).replace(/\n$/, '');
|
|
148
|
+
}
|
|
149
|
+
/** Rebuild a key line with a new value, keeping its indentation, its `- ` prefix and its inline comment. */
|
|
150
|
+
function rewriteKeyLine(line, key, scalar) {
|
|
151
|
+
const head = `${' '.repeat(key.lead)}${key.dash ? '- ' : ''}${key.key}: ${scalar}`;
|
|
152
|
+
const commentIndex = (0, set_1.inlineCommentIndex)(key.rest);
|
|
153
|
+
if (commentIndex < 0)
|
|
154
|
+
return head;
|
|
155
|
+
const column = key.indent + key.key.length + 1 + commentIndex;
|
|
156
|
+
const gap = column > head.length ? ' '.repeat(column - head.length) : ' ';
|
|
157
|
+
return head + gap + key.rest.slice(commentIndex);
|
|
158
|
+
}
|
|
159
|
+
/** Render one sequence item as its own lines, at `indent`. */
|
|
160
|
+
function renderItem(item, indent) {
|
|
161
|
+
const pad = ' '.repeat(indent);
|
|
162
|
+
if (item === null || typeof item !== 'object' || Array.isArray(item)) {
|
|
163
|
+
return [`${pad}- ${renderInline(item)}`];
|
|
164
|
+
}
|
|
165
|
+
const entries = Object.entries(item);
|
|
166
|
+
if (entries.length === 0)
|
|
167
|
+
return undefined; // an empty mapping has no `- key: value` form
|
|
168
|
+
return entries.map(([key, value], index) => `${pad}${index === 0 ? '- ' : ' '}${key}: ${renderInline(value)}`);
|
|
169
|
+
}
|
|
170
|
+
/** Render a flow sequence, copying the bracket spacing of the line it replaces. */
|
|
171
|
+
function renderFlow(items, spaced) {
|
|
172
|
+
if (items.length === 0)
|
|
173
|
+
return '[]';
|
|
174
|
+
const body = items.map((item) => renderInline(item)).join(', ');
|
|
175
|
+
return spaced ? `[ ${body} ]` : `[${body}]`;
|
|
176
|
+
}
|
|
177
|
+
/** The last index in `region` that carries content, so an insert lands before a trailing comment block. */
|
|
178
|
+
function lastContentLine(lines, region) {
|
|
179
|
+
let last = region.start - 1;
|
|
180
|
+
for (let i = region.start; i < region.end; i += 1) {
|
|
181
|
+
if (!isFiller(lines[i]))
|
|
182
|
+
last = i;
|
|
183
|
+
}
|
|
184
|
+
return last;
|
|
185
|
+
}
|
|
186
|
+
/** The value `path` addresses inside an already-mutated document (used to re-render a flow sequence). */
|
|
187
|
+
function valueAtPath(document, path) {
|
|
188
|
+
let node = document;
|
|
189
|
+
for (const step of path) {
|
|
190
|
+
if ('key' in step) {
|
|
191
|
+
if (typeof node !== 'object' || node === null || Array.isArray(node))
|
|
192
|
+
return undefined;
|
|
193
|
+
node = node[step.key];
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
if (!Array.isArray(node))
|
|
197
|
+
return undefined;
|
|
198
|
+
node = node[step.index];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return node;
|
|
202
|
+
}
|
|
203
|
+
/** Order-insensitive structural equality — key ORDER is a rendering detail, key VALUES are the contract. */
|
|
204
|
+
function deepEqual(a, b) {
|
|
205
|
+
if (a === b)
|
|
206
|
+
return true;
|
|
207
|
+
if (a instanceof Date || b instanceof Date) {
|
|
208
|
+
return a instanceof Date && b instanceof Date && a.getTime() === b.getTime();
|
|
209
|
+
}
|
|
210
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
211
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)
|
|
212
|
+
return false;
|
|
213
|
+
return a.every((item, index) => deepEqual(item, b[index]));
|
|
214
|
+
}
|
|
215
|
+
if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null)
|
|
216
|
+
return false;
|
|
217
|
+
const left = a;
|
|
218
|
+
const right = b;
|
|
219
|
+
const leftKeys = Object.keys(left);
|
|
220
|
+
if (leftKeys.length !== Object.keys(right).length)
|
|
221
|
+
return false;
|
|
222
|
+
return leftKeys.every((key) => Object.prototype.hasOwnProperty.call(right, key) && deepEqual(left[key], right[key]));
|
|
223
|
+
}
|
|
224
|
+
/** Write a value at the mapping key the path ends on, inserting the key when the block does not carry it. */
|
|
225
|
+
function editSetScalar(lines, path, value) {
|
|
226
|
+
const scalar = renderInline(value);
|
|
227
|
+
const parentPath = path.slice(0, -1);
|
|
228
|
+
const last = path[path.length - 1];
|
|
229
|
+
if (last === undefined || !('key' in last))
|
|
230
|
+
return undefined;
|
|
231
|
+
const parent = locate(lines, parentPath);
|
|
232
|
+
if (parent === undefined)
|
|
233
|
+
return undefined;
|
|
234
|
+
const existing = findKey(lines, parent.region, parent.indent, last.key);
|
|
235
|
+
if (existing !== undefined) {
|
|
236
|
+
// A value that continues past its own line (a block scalar, a nested block) has no one-line edit.
|
|
237
|
+
const currentValue = (0, set_1.valueOf)(existing.rest);
|
|
238
|
+
if (currentValue.startsWith('|') || currentValue.startsWith('>'))
|
|
239
|
+
return undefined;
|
|
240
|
+
if (blockRegion(lines, existing).end > existing.line + 1)
|
|
241
|
+
return undefined;
|
|
242
|
+
lines[existing.line] = rewriteKeyLine(lines[existing.line], existing, scalar);
|
|
243
|
+
return lines;
|
|
244
|
+
}
|
|
245
|
+
// `lastContentLine` returns `region.start - 1` for an empty block, so the insert lands at its start.
|
|
246
|
+
lines.splice(lastContentLine(lines, parent.region) + 1, 0, `${' '.repeat(parent.indent)}${last.key}: ${scalar}`);
|
|
247
|
+
return lines;
|
|
248
|
+
}
|
|
249
|
+
/** Drop the mapping key the path ends on, together with the block hanging below it. */
|
|
250
|
+
function editDeleteKey(lines, path) {
|
|
251
|
+
const cursor = locate(lines, path);
|
|
252
|
+
if (cursor?.key === undefined)
|
|
253
|
+
return undefined;
|
|
254
|
+
const region = blockRegion(lines, cursor.key);
|
|
255
|
+
lines.splice(cursor.key.line, Math.max(region.end, cursor.key.line + 1) - cursor.key.line);
|
|
256
|
+
return lines;
|
|
257
|
+
}
|
|
258
|
+
/** Append items to the sequence the path ends on, in whichever form that sequence is written. */
|
|
259
|
+
function editAppendItems(lines, path, items, intended) {
|
|
260
|
+
const cursor = locate(lines, path);
|
|
261
|
+
if (cursor?.key === undefined)
|
|
262
|
+
return undefined;
|
|
263
|
+
const key = cursor.key;
|
|
264
|
+
const currentValue = (0, set_1.valueOf)(key.rest);
|
|
265
|
+
// An inline flow sequence (`roles: [ approver ]`) — or an empty one, which becomes a block below.
|
|
266
|
+
if (currentValue.startsWith('[')) {
|
|
267
|
+
if (currentValue !== '[]')
|
|
268
|
+
return rewriteFlow(lines, key, path, intended);
|
|
269
|
+
const rendered = renderItems(items, key.indent + 2);
|
|
270
|
+
if (rendered === undefined)
|
|
271
|
+
return undefined;
|
|
272
|
+
lines[key.line] = rewriteKeyLine(lines[key.line], key, '').replace(/: $/, ':');
|
|
273
|
+
lines.splice(key.line + 1, 0, ...rendered);
|
|
274
|
+
return lines;
|
|
275
|
+
}
|
|
276
|
+
if (currentValue !== '')
|
|
277
|
+
return undefined; // the key holds a plain scalar: not a sequence at all
|
|
278
|
+
const region = blockRegion(lines, key);
|
|
279
|
+
const spans = itemSpans(lines, region);
|
|
280
|
+
const itemIndent = spans.length > 0 ? indentOf(lines[spans[0].start]) : childIndentOf(lines, region) ?? key.indent + 2;
|
|
281
|
+
const rendered = renderItems(items, itemIndent);
|
|
282
|
+
if (rendered === undefined)
|
|
283
|
+
return undefined;
|
|
284
|
+
lines.splice(lastContentLine(lines, region) + 1, 0, ...rendered);
|
|
285
|
+
return lines;
|
|
286
|
+
}
|
|
287
|
+
/** Drop items from the sequence the path ends on. */
|
|
288
|
+
function editRemoveItems(lines, path, indexes, intended) {
|
|
289
|
+
const cursor = locate(lines, path);
|
|
290
|
+
if (cursor?.key === undefined)
|
|
291
|
+
return undefined;
|
|
292
|
+
const key = cursor.key;
|
|
293
|
+
if ((0, set_1.valueOf)(key.rest).startsWith('['))
|
|
294
|
+
return rewriteFlow(lines, key, path, intended);
|
|
295
|
+
const region = blockRegion(lines, key);
|
|
296
|
+
const spans = itemSpans(lines, region);
|
|
297
|
+
if (spans.length === 0)
|
|
298
|
+
return undefined;
|
|
299
|
+
for (const index of [...indexes].sort((a, b) => b - a)) {
|
|
300
|
+
const span = spans[index];
|
|
301
|
+
if (span === undefined)
|
|
302
|
+
return undefined;
|
|
303
|
+
// Trailing comment/blank lines introduce whatever comes NEXT, so they are not this item's to delete.
|
|
304
|
+
const end = lastContentLine(lines, span) + 1;
|
|
305
|
+
lines.splice(span.start, end - span.start);
|
|
306
|
+
}
|
|
307
|
+
const remaining = valueAtPath(intended, path);
|
|
308
|
+
if (Array.isArray(remaining) && remaining.length === 0) {
|
|
309
|
+
lines[key.line] = rewriteKeyLine(lines[key.line], key, '[]');
|
|
310
|
+
}
|
|
311
|
+
return lines;
|
|
312
|
+
}
|
|
313
|
+
/** Replace the whole sequence the path ends on. */
|
|
314
|
+
function editReplaceList(lines, path, items, intended) {
|
|
315
|
+
const cursor = locate(lines, path);
|
|
316
|
+
if (cursor?.key === undefined)
|
|
317
|
+
return undefined;
|
|
318
|
+
const key = cursor.key;
|
|
319
|
+
if ((0, set_1.valueOf)(key.rest).startsWith('['))
|
|
320
|
+
return rewriteFlow(lines, key, path, intended);
|
|
321
|
+
const region = blockRegion(lines, key);
|
|
322
|
+
const spans = itemSpans(lines, region);
|
|
323
|
+
if (spans.length === 0)
|
|
324
|
+
return undefined;
|
|
325
|
+
const itemIndent = indentOf(lines[spans[0].start]);
|
|
326
|
+
const rendered = renderItems(items, itemIndent);
|
|
327
|
+
if (rendered === undefined)
|
|
328
|
+
return undefined;
|
|
329
|
+
const from = spans[0].start;
|
|
330
|
+
const to = lastContentLine(lines, spans[spans.length - 1]) + 1;
|
|
331
|
+
lines.splice(from, to - from, ...rendered);
|
|
332
|
+
return lines;
|
|
333
|
+
}
|
|
334
|
+
/** Re-render an inline flow sequence from the intended document, keeping the line's bracket spacing. */
|
|
335
|
+
function rewriteFlow(lines, key, path, intended) {
|
|
336
|
+
const items = valueAtPath(intended, path);
|
|
337
|
+
if (!Array.isArray(items))
|
|
338
|
+
return undefined;
|
|
339
|
+
lines[key.line] = rewriteKeyLine(lines[key.line], key, renderFlow(items, /\[\s/.test((0, set_1.valueOf)(key.rest))));
|
|
340
|
+
return lines;
|
|
341
|
+
}
|
|
342
|
+
/** Render several sequence items at `indent`, or `undefined` when any of them needs more than one line. */
|
|
343
|
+
function renderItems(items, indent) {
|
|
344
|
+
const out = [];
|
|
345
|
+
for (const item of items) {
|
|
346
|
+
const rendered = renderItem(item, indent);
|
|
347
|
+
if (rendered === undefined)
|
|
348
|
+
return undefined;
|
|
349
|
+
out.push(...rendered);
|
|
350
|
+
}
|
|
351
|
+
return out;
|
|
352
|
+
}
|
|
353
|
+
/** Apply one edit to `lines` in place, returning `undefined` when it has no provably-minimal form. */
|
|
354
|
+
function applyOne(lines, edit, intended) {
|
|
355
|
+
switch (edit.kind) {
|
|
356
|
+
case 'set-scalar':
|
|
357
|
+
return editSetScalar(lines, edit.path, edit.value);
|
|
358
|
+
case 'delete-key':
|
|
359
|
+
return editDeleteKey(lines, edit.path);
|
|
360
|
+
case 'append-items':
|
|
361
|
+
return editAppendItems(lines, edit.path, edit.items, intended);
|
|
362
|
+
case 'remove-items':
|
|
363
|
+
return editRemoveItems(lines, edit.path, edit.indexes, intended);
|
|
364
|
+
case 'replace-list':
|
|
365
|
+
return editReplaceList(lines, edit.path, edit.items, intended);
|
|
366
|
+
case 'batch': {
|
|
367
|
+
let current = lines;
|
|
368
|
+
for (const inner of edit.edits) {
|
|
369
|
+
current = applyOne(current, inner, intended);
|
|
370
|
+
if (current === undefined)
|
|
371
|
+
return undefined;
|
|
372
|
+
}
|
|
373
|
+
return current;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* The one shape the walker above cannot reach: a scalar whose PARENT key is itself absent from the
|
|
379
|
+
* text, so there is no block to insert into (`project.name` in a file with no `project:` at all).
|
|
380
|
+
* `setDnaValueInText` (`task-063`) already solves exactly that — it inserts the missing tail of a
|
|
381
|
+
* mapping path, comments intact — so it is reused rather than re-implemented, for the mapping-only
|
|
382
|
+
* paths it understands. Anything else still falls through to the caller's `dump()`.
|
|
383
|
+
*/
|
|
384
|
+
function insertMissingScalarPath(text, edit) {
|
|
385
|
+
if (edit.kind !== 'set-scalar' || typeof edit.value !== 'string')
|
|
386
|
+
return undefined;
|
|
387
|
+
if (!edit.path.every((step) => 'key' in step))
|
|
388
|
+
return undefined;
|
|
389
|
+
const keyPath = edit.path.map((step) => step.key).join('.');
|
|
390
|
+
return (0, set_1.setDnaValueInText)(text, keyPath, edit.value);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Apply `edit` to the RAW TEXT of a `dna.yaml`, editing as few lines as possible, and return the new
|
|
394
|
+
* text — or `undefined`, deliberately and not as an error, when no provably-minimal edit exists, so the
|
|
395
|
+
* caller falls back to the whole-file `dump()`.
|
|
396
|
+
*
|
|
397
|
+
* `intended` is the document the mutation produced (`applyDnaMutation`'s `dna`). It serves twice: an
|
|
398
|
+
* inline flow sequence is re-rendered from it rather than patched token-by-token, and — the part that
|
|
399
|
+
* makes this safe — the edited text is re-parsed and compared against it in full before being returned.
|
|
400
|
+
* Structural equality is used rather than a byte comparison because key ORDER is a rendering detail
|
|
401
|
+
* while key values are the contract; a mis-located edit fails the comparison and costs the comments,
|
|
402
|
+
* never the content.
|
|
403
|
+
*
|
|
404
|
+
* Declines (returns `undefined`) when: the text is not one valid YAML document; a step of the path is
|
|
405
|
+
* absent from the text; the target or a value it must rewrite spans more than its own line (a block
|
|
406
|
+
* scalar, a nested block); a value has no single-line YAML form; or the result does not read back as
|
|
407
|
+
* `intended`.
|
|
408
|
+
*/
|
|
409
|
+
function applyDnaEditInText(text, edit, intended) {
|
|
410
|
+
try {
|
|
411
|
+
(0, js_yaml_1.load)(text); // never "repair" input the caller could not read in the first place
|
|
412
|
+
}
|
|
413
|
+
catch {
|
|
414
|
+
return undefined;
|
|
415
|
+
}
|
|
416
|
+
const edited = applyOne(text.split('\n'), edit, intended) ?? insertMissingScalarPath(text, edit);
|
|
417
|
+
if (edited === undefined)
|
|
418
|
+
return undefined;
|
|
419
|
+
const result = Array.isArray(edited) ? edited.join('\n') : edited;
|
|
420
|
+
let parsed;
|
|
421
|
+
try {
|
|
422
|
+
parsed = (0, js_yaml_1.load)(result);
|
|
423
|
+
}
|
|
424
|
+
catch {
|
|
425
|
+
return undefined;
|
|
426
|
+
}
|
|
427
|
+
return deepEqual(parsed, intended) ? result : undefined;
|
|
428
|
+
}
|
|
429
|
+
//# sourceMappingURL=edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../src/dna/edit.ts"],"names":[],"mappings":";;AAycA,gDAkBC;AA3dD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qCAAqC;AAErC,+BAAuE;AAwCvE,qGAAqG;AACrG,MAAM,QAAQ,GAAG,uDAAuD,CAAC;AAEzE,mCAAmC;AACnC,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;AAC/C,CAAC;AAED,qFAAqF;AACrF,SAAS,QAAQ,CAAC,IAAY;IAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,OAAO,OAAO,KAAK,EAAE,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACnD,CAAC;AAED,8EAA8E;AAC9E,SAAS,SAAS,CAAC,KAAwB,EAAE,KAAa;IACxD,MAAM,IAAI,GAAG,KAAK,CAAC,K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,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dna` module — Project DNA pillar; structured project map (P2.4). `dna.yaml`'s schema
|
|
3
|
+
* (spec-002-dna-yaml-schema) lives here — the pillar owns its own independent schema (REQ-SYS-02);
|
|
4
|
+
* `src/core`'s loader wires it through the shared validation pipeline. `./roles` adds the
|
|
5
|
+
* role-based binding resolver (REQ-SYS-08, task-034-role-based-binding): `team.roles` is the sole
|
|
6
|
+
* role catalogue, `resolveRoleHolders` reads `team.members`/`team.agents` alone to answer "who holds
|
|
7
|
+
* this role today" — the foundation the Directives pillar (P3) builds on. Approval routing is *not*
|
|
8
|
+
* here (`dl-033-canonical-role-resolver`, option b): "may this principal approve?" is answered by
|
|
9
|
+
* `src/core/approval-authority.ts`. Further DNA behavior (`wingfoil dna show/set`, `wingfoil paths`)
|
|
10
|
+
* lands in later tasks.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MODULE_NAME: "dna";
|
|
13
|
+
export { DnaYaml, Project, Module, TechEntry, MethodologyEntry, Stacks, TeamMember, AgentEntry, RoleEntry, Team, Paths, } from './schema';
|
|
14
|
+
export { isValidKeyPath, quoteDnaSegment, splitDnaPath, setDnaValueInText, DNA_KEY_ALIASES } from './set';
|
|
15
|
+
export type { DnaPathSplit } from './set';
|
|
16
|
+
export { resolveDnaPath, dnaCollectionPaths, dnaEntryOptionNames, DNA_ENTRY_OPTION_PREFIX, dnaEntryOptionName, dnaEntryFieldOfOption, } from './path';
|
|
17
|
+
export type { DnaEntryField, DnaFieldKind, DnaPathResolution, DnaPathTarget, DnaTargetKind } from './path';
|
|
18
|
+
export { applyDnaMutation } from './mutate';
|
|
19
|
+
export type { DnaMutationRequest, DnaMutationResult, DnaMutationVerb } from './mutate';
|
|
20
|
+
export { applyDnaEditInText } from './edit';
|
|
21
|
+
export type { DnaTextEdit, DnaTextStep } from './edit';
|
|
22
|
+
export { isRoleDefined, assertRoleDefined, resolveRoleHolders, UnknownRoleError, } from './roles';
|
|
23
|
+
export type { RoleHolders } from './roles';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dna/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,EAAG,KAAc,CAAC;AAE1C,OAAO,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,SAAS,EACT,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,UAAU,EACV,SAAS,EACT,IAAI,EACJ,KAAK,GACN,MAAM,UAAU,CAAC;AAMlB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAC1G,YAAY,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE3G,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEvD,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnknownRoleError = exports.resolveRoleHolders = exports.assertRoleDefined = exports.isRoleDefined = exports.applyDnaEditInText = exports.applyDnaMutation = exports.dnaEntryFieldOfOption = exports.dnaEntryOptionName = exports.DNA_ENTRY_OPTION_PREFIX = exports.dnaEntryOptionNames = exports.dnaCollectionPaths = exports.resolveDnaPath = exports.DNA_KEY_ALIASES = exports.setDnaValueInText = exports.splitDnaPath = exports.quoteDnaSegment = exports.isValidKeyPath = exports.Paths = exports.Team = exports.RoleEntry = exports.AgentEntry = exports.TeamMember = exports.Stacks = exports.MethodologyEntry = exports.TechEntry = exports.Module = exports.Project = exports.DnaYaml = exports.MODULE_NAME = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* `dna` module — Project DNA pillar; structured project map (P2.4). `dna.yaml`'s schema
|
|
6
|
+
* (spec-002-dna-yaml-schema) lives here — the pillar owns its own independent schema (REQ-SYS-02);
|
|
7
|
+
* `src/core`'s loader wires it through the shared validation pipeline. `./roles` adds the
|
|
8
|
+
* role-based binding resolver (REQ-SYS-08, task-034-role-based-binding): `team.roles` is the sole
|
|
9
|
+
* role catalogue, `resolveRoleHolders` reads `team.members`/`team.agents` alone to answer "who holds
|
|
10
|
+
* this role today" — the foundation the Directives pillar (P3) builds on. Approval routing is *not*
|
|
11
|
+
* here (`dl-033-canonical-role-resolver`, option b): "may this principal approve?" is answered by
|
|
12
|
+
* `src/core/approval-authority.ts`. Further DNA behavior (`wingfoil dna show/set`, `wingfoil paths`)
|
|
13
|
+
* lands in later tasks.
|
|
14
|
+
*/
|
|
15
|
+
exports.MODULE_NAME = 'dna';
|
|
16
|
+
var schema_1 = require("./schema");
|
|
17
|
+
Object.defineProperty(exports, "DnaYaml", { enumerable: true, get: function () { return schema_1.DnaYaml; } });
|
|
18
|
+
Object.defineProperty(exports, "Project", { enumerable: true, get: function () { return schema_1.Project; } });
|
|
19
|
+
Object.defineProperty(exports, "Module", { enumerable: true, get: function () { return schema_1.Module; } });
|
|
20
|
+
Object.defineProperty(exports, "TechEntry", { enumerable: true, get: function () { return schema_1.TechEntry; } });
|
|
21
|
+
Object.defineProperty(exports, "MethodologyEntry", { enumerable: true, get: function () { return schema_1.MethodologyEntry; } });
|
|
22
|
+
Object.defineProperty(exports, "Stacks", { enumerable: true, get: function () { return schema_1.Stacks; } });
|
|
23
|
+
Object.defineProperty(exports, "TeamMember", { enumerable: true, get: function () { return schema_1.TeamMember; } });
|
|
24
|
+
Object.defineProperty(exports, "AgentEntry", { enumerable: true, get: function () { return schema_1.AgentEntry; } });
|
|
25
|
+
Object.defineProperty(exports, "RoleEntry", { enumerable: true, get: function () { return schema_1.RoleEntry; } });
|
|
26
|
+
Object.defineProperty(exports, "Team", { enumerable: true, get: function () { return schema_1.Team; } });
|
|
27
|
+
Object.defineProperty(exports, "Paths", { enumerable: true, get: function () { return schema_1.Paths; } });
|
|
28
|
+
// `splitDnaPath` (task-099, `dl-083-dotted-entry-names-in-paths`) is the pillar's path parser: the one
|
|
29
|
+
// place a dotted path is split, and therefore the one definition of the quoted-segment rule that makes
|
|
30
|
+
// an entry named `Node.js` addressable. `isValidKeyPath` is that parser reduced to a boolean, and
|
|
31
|
+
// `quoteDnaSegment` is its inverse, used where a refusal echoes part of a path.
|
|
32
|
+
var set_1 = require("./set");
|
|
33
|
+
Object.defineProperty(exports, "isValidKeyPath", { enumerable: true, get: function () { return set_1.isValidKeyPath; } });
|
|
34
|
+
Object.defineProperty(exports, "quoteDnaSegment", { enumerable: true, get: function () { return set_1.quoteDnaSegment; } });
|
|
35
|
+
Object.defineProperty(exports, "splitDnaPath", { enumerable: true, get: function () { return set_1.splitDnaPath; } });
|
|
36
|
+
Object.defineProperty(exports, "setDnaValueInText", { enumerable: true, get: function () { return set_1.setDnaValueInText; } });
|
|
37
|
+
Object.defineProperty(exports, "DNA_KEY_ALIASES", { enumerable: true, get: function () { return set_1.DNA_KEY_ALIASES; } });
|
|
38
|
+
// task-093-dna-mutation-surface-add-remove-update — the mutation surface `dl-081-dna-mutation-surface-shape`
|
|
39
|
+
// ratified (option (E)): one schema-driven traversal (`./path`), the pure add|remove|update semantics
|
|
40
|
+
// over it (`./mutate`), and the comment-preserving structural edit that writes the result (`./edit`).
|
|
41
|
+
// `setDnaValue` is gone with them: it treated every path segment as an object key and created an object
|
|
42
|
+
// for any segment it could not descend into, which is the mechanism `bug-084` filed.
|
|
43
|
+
var path_1 = require("./path");
|
|
44
|
+
Object.defineProperty(exports, "resolveDnaPath", { enumerable: true, get: function () { return path_1.resolveDnaPath; } });
|
|
45
|
+
Object.defineProperty(exports, "dnaCollectionPaths", { enumerable: true, get: function () { return path_1.dnaCollectionPaths; } });
|
|
46
|
+
Object.defineProperty(exports, "dnaEntryOptionNames", { enumerable: true, get: function () { return path_1.dnaEntryOptionNames; } });
|
|
47
|
+
Object.defineProperty(exports, "DNA_ENTRY_OPTION_PREFIX", { enumerable: true, get: function () { return path_1.DNA_ENTRY_OPTION_PREFIX; } });
|
|
48
|
+
Object.defineProperty(exports, "dnaEntryOptionName", { enumerable: true, get: function () { return path_1.dnaEntryOptionName; } });
|
|
49
|
+
Object.defineProperty(exports, "dnaEntryFieldOfOption", { enumerable: true, get: function () { return path_1.dnaEntryFieldOfOption; } });
|
|
50
|
+
var mutate_1 = require("./mutate");
|
|
51
|
+
Object.defineProperty(exports, "applyDnaMutation", { enumerable: true, get: function () { return mutate_1.applyDnaMutation; } });
|
|
52
|
+
var edit_1 = require("./edit");
|
|
53
|
+
Object.defineProperty(exports, "applyDnaEditInText", { enumerable: true, get: function () { return edit_1.applyDnaEditInText; } });
|
|
54
|
+
var roles_1 = require("./roles");
|
|
55
|
+
Object.defineProperty(exports, "isRoleDefined", { enumerable: true, get: function () { return roles_1.isRoleDefined; } });
|
|
56
|
+
Object.defineProperty(exports, "assertRoleDefined", { enumerable: true, get: function () { return roles_1.assertRoleDefined; } });
|
|
57
|
+
Object.defineProperty(exports, "resolveRoleHolders", { enumerable: true, get: function () { return roles_1.resolveRoleHolders; } });
|
|
58
|
+
Object.defineProperty(exports, "UnknownRoleError", { enumerable: true, get: function () { return roles_1.UnknownRoleError; } });
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dna/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACU,QAAA,WAAW,GAAG,KAAc,CAAC;AAE1C,mCAYkB;AAXhB,iGAAA,OAAO,OAAA;AACP,iGAAA,OAAO,OAAA;AACP,gGAAA,MAAM,OAAA;AACN,mGAAA,SAAS,OAAA;AACT,0GAAA,gBAAgB,OAAA;AAChB,gGAAA,MAAM,OAAA;AACN,oGAAA,UAAU,OAAA;AACV,oGAAA,UAAU,OAAA;AACV,mGAAA,SAAS,OAAA;AACT,8FAAA,IAAI,OAAA;AACJ,+FAAA,KAAK,OAAA;AAGP,uGAAuG;AACvG,uGAAuG;AACvG,kGAAkG;AAClG,gFAAgF;AAChF,6BAA0G;AAAjG,qGAAA,cAAc,OAAA;AAAE,sGAAA,eAAe,OAAA;AAAE,mGAAA,YAAY,OAAA;AAAE,wGAAA,iBAAiB,OAAA;AAAE,sGAAA,eAAe,OAAA;AAG1F,6GAA6G;AAC7G,sGAAsG;AACtG,sGAAsG;AACtG,wGAAwG;AACxG,qFAAqF;AACrF,+BAOgB;AANd,sGAAA,cAAc,OAAA;AACd,0GAAA,kBAAkB,OAAA;AAClB,2GAAA,mBAAmB,OAAA;AACnB,+GAAA,uBAAuB,OAAA;AACvB,0GAAA,kBAAkB,OAAA;AAClB,6GAAA,qBAAqB,OAAA;AAIvB,mCAA4C;AAAnC,0GAAA,gBAAgB,OAAA;AAGzB,+BAA4C;AAAnC,0GAAA,kBAAkB,OAAA;AAG3B,iCAKiB;AAJf,sGAAA,aAAa,OAAA;AACb,0GAAA,iBAAiB,OAAA;AACjB,2GAAA,kBAAkB,OAAA;AAClB,yGAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pure `add | remove | update` semantics of the DNA mutation surface
|
|
3
|
+
* (`dl-081-dna-mutation-surface-shape`, ratified option **(E)**; task-093;
|
|
4
|
+
* closes `bug-083-dna-set-cannot-write-array-valued-fields`).
|
|
5
|
+
*
|
|
6
|
+
* Before this module, `dna set` reached 7 of roughly 38 schema fields — `version` and the six scalars
|
|
7
|
+
* under `project` — because its traversal treated every path segment as an object key. 11 fields are
|
|
8
|
+
* array-valued and 17 more live inside array entries, and none of them was reachable for create, update
|
|
9
|
+
* or delete: not a module's `path`, a technology's `version`, a member's `email`, nor the removal of any
|
|
10
|
+
* of them, nor the addition of a role or a member (`dl-081` E2/E3).
|
|
11
|
+
*
|
|
12
|
+
* The grammar the ratification chose, and which this module implements — with the path in the verb's
|
|
13
|
+
* **positional** (`dl-082-cli-parameter-shape`: a positional carries the identity of the target, an
|
|
14
|
+
* option a named attribute of the action) and every attribute in an option:
|
|
15
|
+
*
|
|
16
|
+
* ```
|
|
17
|
+
* dna add team.roles --value reviewer --entry-description "reviews changes"
|
|
18
|
+
* dna add team.members --value roberto --entry-email r@example.it --entry-roles approver
|
|
19
|
+
* dna add team.members.roberto.roles --value qa
|
|
20
|
+
* dna update team.members --value roberto --entry-email new@example.it
|
|
21
|
+
* dna update modules.core.path --value src/core
|
|
22
|
+
* dna remove modules --value core
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* `--value` carries **two** things by position — the new entry's identity when the path ends at a
|
|
26
|
+
* collection, the new value when it ends at a leaf. That is a convention rather than something the
|
|
27
|
+
* grammar states, so it is stated: here, in `--help` (`src/core/index.ts`'s option descriptions) and in
|
|
28
|
+
* `spec-008-cli-grammar`.
|
|
29
|
+
*
|
|
30
|
+
* This module is pure (REQ-SYS-07): no git, no filesystem, no clock, and the document it is handed is
|
|
31
|
+
* never mutated — every mutation is applied to a deep clone, so a refusal leaves the caller's object
|
|
32
|
+
* untouched and `src/core` re-validates and commits only what comes back. It sits under `src/core`
|
|
33
|
+
* (`spec-006-core-domain-api` §1: the pillar is a leaf, and imports nothing from `core`).
|
|
34
|
+
*/
|
|
35
|
+
import type { z } from 'zod';
|
|
36
|
+
import type { DnaTextEdit } from './edit';
|
|
37
|
+
/** The three verbs `dl-081` ratified. `dna set` is `update` restricted to a scalar. */
|
|
38
|
+
export type DnaMutationVerb = 'add' | 'remove' | 'update';
|
|
39
|
+
/** One mutation request: the full `<path>`, the `--value` payload, and the per-entry `--entry-<field>` options. */
|
|
40
|
+
export interface DnaMutationRequest {
|
|
41
|
+
readonly verb: DnaMutationVerb;
|
|
42
|
+
/** The FULL dotted path (`dl-081`: never a bare field name — `team.roles` and `team.members.roles` differ). */
|
|
43
|
+
readonly field: string;
|
|
44
|
+
/** The entry's identity at a collection; the new value at a leaf. Optional only where the path says everything. */
|
|
45
|
+
readonly value?: string;
|
|
46
|
+
/** `--entry-<field>` options, keyed by the schema's own field name and still raw strings; coerced against the entry schema (`{ email: 'r@x.y' }`). */
|
|
47
|
+
readonly fields?: Readonly<Record<string, string>>;
|
|
48
|
+
}
|
|
49
|
+
/** The mutated document plus the minimal text edit that expresses it, or the refusal to report at exit `1`. */
|
|
50
|
+
export type DnaMutationResult = {
|
|
51
|
+
readonly ok: true;
|
|
52
|
+
readonly dna: Record<string, unknown>;
|
|
53
|
+
readonly edit: DnaTextEdit;
|
|
54
|
+
} | {
|
|
55
|
+
readonly ok: false;
|
|
56
|
+
readonly message: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Apply one `add`/`remove`/`update` to `dna`, returning the new document and the minimal text edit that
|
|
60
|
+
* expresses it — or a refusal message the caller reports at exit `1` (`spec-005` §1, as ruled on
|
|
61
|
+
* `bug-076`: a well-formed invocation that fails on the content is a logic error, not a usage error).
|
|
62
|
+
*
|
|
63
|
+
* Every refusal names what failed and, where there is one, the verb that would have worked — the whole
|
|
64
|
+
* point of `bug-083`'s repair is that `dna set team.members '[…]'` used to fail with
|
|
65
|
+
* `expected array, received string` from a schema re-validation, which says nothing about how to reach
|
|
66
|
+
* the field.
|
|
67
|
+
*
|
|
68
|
+
* `schemaRoot` is passed straight to `resolveDnaPath` and defaults to `DnaYaml` there — the only schema
|
|
69
|
+
* any caller uses. It is a parameter for the same reason: the semantics below are a function of *a*
|
|
70
|
+
* schema (which field kinds exist, which are required), so they stay exercisable against shapes
|
|
71
|
+
* `spec-002` does not declare today rather than resting on an untested claim.
|
|
72
|
+
*/
|
|
73
|
+
export declare function applyDnaMutation(dna: Record<string, unknown>, request: DnaMutationRequest, schemaRoot?: z.ZodType): DnaMutationResult;
|
|
74
|
+
//# sourceMappingURL=mutate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutate.d.ts","sourceRoot":"","sources":["../../src/dna/mutate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,QAAQ,CAAC;AAGvD,uFAAuF;AACvF,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE1D,mHAAmH;AACnH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,+GAA+G;IAC/G,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mHAAmH;IACnH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,sJAAsJ;IACtJ,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM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