ddduck 0.1.0 → 0.2.0

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.
Files changed (41) hide show
  1. package/README.md +11 -6
  2. package/docs/architecture.md +5 -2
  3. package/docs/cli.md +135 -53
  4. package/docs/definition-workflow.md +130 -0
  5. package/docs/getting-started.md +21 -48
  6. package/docs/model-reference.md +4 -0
  7. package/docs/model.md +1 -0
  8. package/docs/templates/change-brief.md +48 -0
  9. package/package.json +8 -5
  10. package/schemas/model-diff.schema.json +107 -0
  11. package/scripts/audit-fr-to-code.mjs +25 -0
  12. package/scripts/check-generated-docs.mjs +24 -5
  13. package/scripts/check-generated-graph-svg.mjs +26 -8
  14. package/scripts/check-generated-graph.mjs +25 -5
  15. package/scripts/check-model.mjs +95 -5
  16. package/scripts/ddduck.mjs +216 -22
  17. package/scripts/generate-agent-readiness-report.mjs +8 -0
  18. package/scripts/generate-docs.mjs +29 -3
  19. package/scripts/generate-graph-svg.mjs +53 -16
  20. package/scripts/generate-graph.mjs +26 -1
  21. package/scripts/lib/agent-readiness-evals.mjs +32 -0
  22. package/scripts/lib/agent-readiness-report.mjs +14 -0
  23. package/scripts/lib/cli-contract.mjs +65 -15
  24. package/scripts/lib/context-pack.mjs +49 -1
  25. package/scripts/lib/ddduck-config.mjs +31 -1
  26. package/scripts/lib/fr-to-code-audit.mjs +30 -0
  27. package/scripts/lib/product-authoring.mjs +52 -0
  28. package/scripts/lib/product-diff.mjs +155 -0
  29. package/scripts/lib/product-layout.mjs +42 -1
  30. package/scripts/lib/product-operation.mjs +140 -22
  31. package/scripts/lib/product-paths.mjs +16 -0
  32. package/scripts/lib/product-query.mjs +102 -20
  33. package/scripts/lib/product-root-resolver.mjs +40 -0
  34. package/scripts/lib/scan-ignore.mjs +14 -3
  35. package/scripts/lib/skill-installer.mjs +227 -39
  36. package/scripts/query-model.mjs +18 -7
  37. package/scripts/run-agent-readiness-evals.mjs +18 -2
  38. package/skills/update-ddduck-specs/SKILL.md +25 -83
  39. package/skills/update-ddduck-specs/references/authoring-and-verification.md +60 -0
  40. package/skills/update-ddduck-specs/references/modeling-and-evidence.md +56 -0
  41. package/skills/update-ddduck-specs/references/reviewing-changes.md +45 -0
@@ -0,0 +1,60 @@
1
+ # Authoring and verification
2
+
3
+ Read this reference before proposing or applying canonical ddduck changes.
4
+
5
+ ## Resolve and classify once
6
+
7
+ Use an explicitly requested root. Otherwise let ddduck resolve the enclosing product root, then `.ddduck/config.json`, then the unique repository candidate. `ddduck query spec --root <root> --json` reports the resolved root. Ambiguity is a stop condition: report candidates and ask rather than initializing a second model.
8
+
9
+ Classify the selected path:
10
+
11
+ - `existing`: `product.yaml` exists. Run `query spec` and `check` independently. A failing model remains existing and invalid.
12
+ - `absent`: the root is missing or empty. Inspect the repository before proposing initialization.
13
+ - `path-collision`: the path is non-empty but is not a recognizable product. Report it and do not initialize over it.
14
+
15
+ Stop before mutation when the executable is missing or incompatible, the root is ambiguous, the path collides, bootstrap identity or seams are ungrounded, evidence conflicts change the proposal materially, target files overlap inseparable user work, or the analyzed working tree changed.
16
+
17
+ ## Plan-only report
18
+
19
+ Before any write, report in this order:
20
+
21
+ 1. Mode, resolved root, and model state.
22
+ 2. Independent query and validation outcomes.
23
+ 3. Inspected coverage, exclusions, and gaps.
24
+ 4. Proposed changes with classification, evidence, affected IDs, and exact files.
25
+ 5. Contradictions, uncertainties, and required decisions.
26
+ 6. Exact authoring, generation, and verification commands.
27
+
28
+ Without explicit application authorization, stop here. Plan-only performs no initialization or generation.
29
+
30
+ ## Apply canonical changes
31
+
32
+ Recheck Git status, intended files, and decisive evidence immediately before writing.
33
+
34
+ Use the supported operation instead of coordinating parent collections by hand:
35
+
36
+ ```bash
37
+ ddduck create domain --id domain:<slug> --name <text> --purpose <text> --root <root>
38
+ ddduck create concept --id concept:<slug> --owner domain:<slug> --name <text> --purpose <text> --root <root>
39
+ ddduck create use-case --file <yaml-file> --root <root>
40
+ ```
41
+
42
+ Use ddduck lifecycle commands for Guarantee creation, movement, splitting, and retirement. Author canonical YAML directly only for kinds or field changes without a supported mutation command, following installed schemas and existing conventions. Never edit generated views.
43
+
44
+ Apply only approved, unambiguous changes. Leave unresolved findings unchanged. A helper coordinates structure and publication; it does not supply product meaning.
45
+
46
+ ## Verify and read back
47
+
48
+ For hand-authored canonical edits, run the source-only check before generation. Mutation commands already stage validation and generation, but still perform the common final readback:
49
+
50
+ ```bash
51
+ ddduck check --root <root> --source-only
52
+ ddduck generate --root <root>
53
+ ddduck check --root <root>
54
+ ddduck query spec --root <root> --json
55
+ git diff -- <root>/product.yaml <root>/model <root>/decisions <root>/generated
56
+ ```
57
+
58
+ When only mutation commands were used, the first two commands may be redundant; run them when hand edits occurred or when generated freshness is uncertain. Always require the final `check`, fresh generated views in `query spec`, and a scoped diff.
59
+
60
+ Any failure makes the result `incomplete`. Inspect the resulting tree without destructive rollback. Report changed canonical, decision, and generated files; evidence for every material change; skipped and unresolved findings; exact diagnostics; freshness; and remaining coverage gaps.
@@ -0,0 +1,56 @@
1
+ # Modeling and evidence
2
+
3
+ Read this reference for every ddduck bootstrap, audit, or reconciliation.
4
+
5
+ ## Evidence ledger
6
+
7
+ For every candidate model fact, record:
8
+
9
+ - the proposed assertion;
10
+ - repository-relative path plus line, symbol, heading, or test name;
11
+ - role: implementation, verification, documentation, decision, or configuration;
12
+ - contradictory evidence;
13
+ - inspected scope and remaining unknowns.
14
+
15
+ Executable behavior and passing tests establish observed behavior. Accepted requirements and decisions establish intended behavior. A conflict between them is an inconsistency requiring a decision; neither side silently becomes product truth.
16
+
17
+ Repository-wide evidence belongs in the plan and final report. Persist only evidence fields supported by the installed schema. Interface anchors must remain inside the product root. Do not copy source into the model, invent metadata, or create bridge documents merely to manufacture provenance.
18
+
19
+ Valid anchors prove that declared text exists. Declared audit verdicts remain assessments. Readiness records and valid links do not execute tests or prove runtime behavior.
20
+
21
+ ## Define before asserting
22
+
23
+ Reuse an existing proposal or brief. Capture the actor and problem, success and refusal examples, evidence provenance, accepted constraints, alternatives, open conflicts, affected IDs, decision and rationale, and receiving plan. Omit sections that add no decision value.
24
+
25
+ - `Observed`: inspected behavior, not endorsement.
26
+ - `Accepted`: intended behavior with identified authority; it may be unimplemented.
27
+ - `Open`: unresolved meaning that stays out of canonical YAML.
28
+ - `Rejected`: considered alternative retained with its rationale.
29
+
30
+ These labels are prose, not schema fields or Guarantee lifecycle states. Independent accepted obligations may be modeled while another question remains open. Zero canonical change is correct when existing obligations suffice, the proposal remains unresolved, or the change is implementation-only. Create an ADR only for a durable consequential decision worth maintaining.
31
+
32
+ ## Model by meaning
33
+
34
+ - Domain: a distinct product responsibility, not a package or screen.
35
+ - Concept: vocabulary needed to reason about a decision, not every noun or class.
36
+ - Guarantee: an observable obligation or invariant, not an aspiration.
37
+ - UseCase: an actor goal and the obligations it requires, preserves, or establishes, not an implementation task list.
38
+ - Relationship: an explicit connection worth reviewing, not proof of causation.
39
+ - Interface: optional; add one only when an external behavioral boundary matters.
40
+
41
+ Prefer the smallest coherent model change. Preserve identity and history. Never silently delete or reuse a Guarantee ID.
42
+
43
+ Classify every material difference as exactly one of:
44
+
45
+ - verified omission;
46
+ - stale modeled fact;
47
+ - structural inconsistency with an unambiguous repair;
48
+ - contradiction or uncertainty requiring a human decision;
49
+ - irrelevant implementation detail;
50
+ - insufficiently covered.
51
+
52
+ ## Greenfield coverage
53
+
54
+ Initialize only when identity, purpose, and initial domain seams are explicit or unambiguously grounded.
55
+
56
+ Use runtime-supported subagents only when no model exists and the evidence corpus spans several substantial independent packages, applications, or domains that cannot fit reliably in the coordinating context. File count alone is insufficient. Give each subagent a non-overlapping read-only scope and require candidate facts with exact evidence locations, conflicts, unknowns, and coverage. The coordinator re-reads decisive evidence and is the sole model writer.
@@ -0,0 +1,45 @@
1
+ # Reviewing changes
2
+
3
+ Read this reference when two product roots or revisions must be compared, or when a move, removal, or affected-context review is requested.
4
+
5
+ ## Structural comparison
6
+
7
+ Keep both roots stable and run:
8
+
9
+ ```bash
10
+ ddduck diff --base <before-root> --root <after-root> --json
11
+ ```
12
+
13
+ The command validates both roots independently and compares canonical YAML records by stable ID. It reports additions, removals, field changes, and relocations. Object-key order, comments, and YAML formatting are not semantic record changes; array order is significant. Raw canonical bytes still contribute to each source digest.
14
+
15
+ Exit `0` means the comparison completed, including when differences exist. It is not approval. Exit `2` means a root is busy; other failures exit `1`. The report excludes decision content, evidence content, delivery artifacts, and runtime. Empty output does not prove semantic equivalence or freshness outside that scope.
16
+
17
+ Source reads are not an atomic snapshot. Keep both roots unchanged during review and repeat the comparison if either tree changes.
18
+
19
+ ## Inspect affected context
20
+
21
+ For each changed or removed ID, inspect both roots where the record exists:
22
+
23
+ ```bash
24
+ ddduck query node --id <id> --root <root> --json
25
+ ddduck query impact --id <id> --root <root> --json
26
+ ddduck query neighbors --id <id> --root <root> --json
27
+ ddduck query context --id <id> --root <root> --json
28
+ ```
29
+
30
+ `impact` follows reverse ownership and behavioral-reference edges. `neighbors` returns direct edges; relationships are review candidates, not causal proof. Filter incoming and outgoing edges with `edge.kind === "relationship"` and deduplicate by `edge.id`, because a self-relationship appears in both lists.
31
+
32
+ When the changed ID is a Relationship, query the relationship record and inspect its `from`, `to`, description, and constraints. `neighbors` matches endpoint IDs, not the Relationship record's own ID.
33
+
34
+ Inspect the before root for removed context; current-root queries cannot reconstruct deleted records. Use the consumer's own bridge for feature traces or delivery references outside the ddduck product root.
35
+
36
+ ## Review outcome
37
+
38
+ For every reported ID, state the structural difference, before/after ownership and paths, affected obligations and use cases, supporting evidence, contradictions, and one of the exact classifications from the modeling reference. Preserve a Guarantee ID across ownership moves. Treat deletion and recreation under another ID as an identity break, not a move.
39
+
40
+ Conclude separately:
41
+
42
+ - structural comparison completed or incomplete;
43
+ - semantic change acceptable, not acceptable, or decision required;
44
+ - historical retention check required or satisfied;
45
+ - runtime and external effects verified or unverified.