dna-sdk 0.1.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 (240) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -0
  3. package/dist/adapters/embedding/onnx.d.ts +32 -0
  4. package/dist/adapters/embedding/onnx.js +51 -0
  5. package/dist/adapters/filesystem/cache.d.ts +16 -0
  6. package/dist/adapters/filesystem/cache.js +113 -0
  7. package/dist/adapters/filesystem/index.d.ts +2 -0
  8. package/dist/adapters/filesystem/index.js +2 -0
  9. package/dist/adapters/filesystem/source.d.ts +82 -0
  10. package/dist/adapters/filesystem/source.js +357 -0
  11. package/dist/adapters/postgres/index.d.ts +2 -0
  12. package/dist/adapters/postgres/index.js +2 -0
  13. package/dist/adapters/postgres/migrations.d.ts +14 -0
  14. package/dist/adapters/postgres/migrations.js +88 -0
  15. package/dist/adapters/postgres/source.d.ts +172 -0
  16. package/dist/adapters/postgres/source.js +569 -0
  17. package/dist/adapters/resolvers/github.d.ts +12 -0
  18. package/dist/adapters/resolvers/github.js +47 -0
  19. package/dist/adapters/resolvers/http.d.ts +22 -0
  20. package/dist/adapters/resolvers/http.js +145 -0
  21. package/dist/adapters/resolvers/index.d.ts +3 -0
  22. package/dist/adapters/resolvers/index.js +3 -0
  23. package/dist/adapters/resolvers/local.d.ts +24 -0
  24. package/dist/adapters/resolvers/local.js +132 -0
  25. package/dist/adapters/search/driver.d.ts +45 -0
  26. package/dist/adapters/search/driver.js +138 -0
  27. package/dist/adapters/search/migrations.d.ts +26 -0
  28. package/dist/adapters/search/migrations.js +58 -0
  29. package/dist/adapters/search/rrf.d.ts +23 -0
  30. package/dist/adapters/search/rrf.js +42 -0
  31. package/dist/adapters/search/sqlite-vec.d.ts +66 -0
  32. package/dist/adapters/search/sqlite-vec.js +294 -0
  33. package/dist/bootstrap.d.ts +45 -0
  34. package/dist/bootstrap.js +134 -0
  35. package/dist/extensions/agentskills/DOCS.md +18 -0
  36. package/dist/extensions/agentskills.d.ts +28 -0
  37. package/dist/extensions/agentskills.js +252 -0
  38. package/dist/extensions/agentsmd/DOCS.md +18 -0
  39. package/dist/extensions/agentsmd.d.ts +22 -0
  40. package/dist/extensions/agentsmd.js +170 -0
  41. package/dist/extensions/audit/kinds/audit-log.kind.yaml +148 -0
  42. package/dist/extensions/audit.d.ts +25 -0
  43. package/dist/extensions/audit.js +62 -0
  44. package/dist/extensions/automation/kinds/automation.kind.yaml +296 -0
  45. package/dist/extensions/automation/query.d.ts +49 -0
  46. package/dist/extensions/automation/query.js +77 -0
  47. package/dist/extensions/automation/write-guards.d.ts +59 -0
  48. package/dist/extensions/automation/write-guards.js +153 -0
  49. package/dist/extensions/automation.d.ts +41 -0
  50. package/dist/extensions/automation.js +54 -0
  51. package/dist/extensions/collab.d.ts +16 -0
  52. package/dist/extensions/collab.js +79 -0
  53. package/dist/extensions/doc/kinds/doc.kind.yaml +118 -0
  54. package/dist/extensions/doc.d.ts +25 -0
  55. package/dist/extensions/doc.js +10 -0
  56. package/dist/extensions/eval/kinds/eval-baseline.kind.yaml +65 -0
  57. package/dist/extensions/eval/kinds/eval-case.kind.yaml +140 -0
  58. package/dist/extensions/eval/kinds/eval-run.kind.yaml +134 -0
  59. package/dist/extensions/eval/kinds/eval-suite.kind.yaml +87 -0
  60. package/dist/extensions/eval.d.ts +24 -0
  61. package/dist/extensions/eval.js +31 -0
  62. package/dist/extensions/evidence/kinds/evidence.kind.yaml +92 -0
  63. package/dist/extensions/evidence.d.ts +17 -0
  64. package/dist/extensions/evidence.js +94 -0
  65. package/dist/extensions/federation.d.ts +22 -0
  66. package/dist/extensions/federation.js +173 -0
  67. package/dist/extensions/guardrails/DOCS.md +20 -0
  68. package/dist/extensions/guardrails.d.ts +31 -0
  69. package/dist/extensions/guardrails.js +228 -0
  70. package/dist/extensions/helix/DOCS-Actor.md +20 -0
  71. package/dist/extensions/helix/DOCS-Agent.md +20 -0
  72. package/dist/extensions/helix/DOCS-UseCase.md +20 -0
  73. package/dist/extensions/helix/layers.d.ts +12 -0
  74. package/dist/extensions/helix/layers.js +18 -0
  75. package/dist/extensions/helix/write-guards.d.ts +70 -0
  76. package/dist/extensions/helix/write-guards.js +172 -0
  77. package/dist/extensions/helix.d.ts +29 -0
  78. package/dist/extensions/helix.js +963 -0
  79. package/dist/extensions/helix_extras.d.ts +124 -0
  80. package/dist/extensions/helix_extras.js +328 -0
  81. package/dist/extensions/hooks.d.ts +31 -0
  82. package/dist/extensions/hooks.js +247 -0
  83. package/dist/extensions/kinddef/DOCS.md +24 -0
  84. package/dist/extensions/kinddef.d.ts +40 -0
  85. package/dist/extensions/kinddef.js +171 -0
  86. package/dist/extensions/lesson.d.ts +6 -0
  87. package/dist/extensions/lesson.js +194 -0
  88. package/dist/extensions/modelreg/kinds/model-profile.kind.yaml +155 -0
  89. package/dist/extensions/modelreg.d.ts +30 -0
  90. package/dist/extensions/modelreg.js +38 -0
  91. package/dist/extensions/recognizer.d.ts +34 -0
  92. package/dist/extensions/recognizer.js +272 -0
  93. package/dist/extensions/research.d.ts +32 -0
  94. package/dist/extensions/research.js +292 -0
  95. package/dist/extensions/safety.d.ts +33 -0
  96. package/dist/extensions/safety.js +230 -0
  97. package/dist/extensions/sdlc/kinds/adr.kind.yaml +136 -0
  98. package/dist/extensions/sdlc/kinds/archive-proposal.kind.yaml +107 -0
  99. package/dist/extensions/sdlc/kinds/changelog.kind.yaml +108 -0
  100. package/dist/extensions/sdlc/kinds/cognitive-policy.kind.yaml +470 -0
  101. package/dist/extensions/sdlc/kinds/forecast.kind.yaml +125 -0
  102. package/dist/extensions/sdlc/kinds/insight.kind.yaml +87 -0
  103. package/dist/extensions/sdlc/kinds/kaizen.kind.yaml +106 -0
  104. package/dist/extensions/sdlc/kinds/lesson-learned.kind.yaml +270 -0
  105. package/dist/extensions/sdlc/kinds/narrative.kind.yaml +189 -0
  106. package/dist/extensions/sdlc/kinds/pattern-insight.kind.yaml +204 -0
  107. package/dist/extensions/sdlc/kinds/postmortem.kind.yaml +168 -0
  108. package/dist/extensions/sdlc/kinds/pre-mortem.kind.yaml +145 -0
  109. package/dist/extensions/sdlc/kinds/prompt-template.kind.yaml +109 -0
  110. package/dist/extensions/sdlc/kinds/retrospective.kind.yaml +186 -0
  111. package/dist/extensions/sdlc/kinds/risk-register.kind.yaml +178 -0
  112. package/dist/extensions/sdlc/kinds/saved-view.kind.yaml +127 -0
  113. package/dist/extensions/sdlc/kinds/status-report.kind.yaml +129 -0
  114. package/dist/extensions/sdlc/kinds/synthesis-run.kind.yaml +279 -0
  115. package/dist/extensions/sdlc/kinds/synthesizer-state.kind.yaml +196 -0
  116. package/dist/extensions/sdlc/kinds/workflow-event.kind.yaml +195 -0
  117. package/dist/extensions/sdlc.d.ts +32 -0
  118. package/dist/extensions/sdlc.js +1318 -0
  119. package/dist/extensions/soulspec/DOCS.md +19 -0
  120. package/dist/extensions/soulspec.d.ts +22 -0
  121. package/dist/extensions/soulspec.js +287 -0
  122. package/dist/extensions/tenant.d.ts +6 -0
  123. package/dist/extensions/tenant.js +291 -0
  124. package/dist/extensions/testkit.d.ts +24 -0
  125. package/dist/extensions/testkit.js +211 -0
  126. package/dist/index.d.ts +80 -0
  127. package/dist/index.js +102 -0
  128. package/dist/kernel/_text.d.ts +28 -0
  129. package/dist/kernel/_text.js +42 -0
  130. package/dist/kernel/bundle-handle.d.ts +83 -0
  131. package/dist/kernel/bundle-handle.js +184 -0
  132. package/dist/kernel/capabilities.d.ts +157 -0
  133. package/dist/kernel/capabilities.js +109 -0
  134. package/dist/kernel/collaborator-ports.d.ts +91 -0
  135. package/dist/kernel/collaborator-ports.js +1 -0
  136. package/dist/kernel/composition-resolver.d.ts +215 -0
  137. package/dist/kernel/composition-resolver.js +558 -0
  138. package/dist/kernel/composition.d.ts +10 -0
  139. package/dist/kernel/composition.js +1 -0
  140. package/dist/kernel/descriptor-loader.d.ts +13 -0
  141. package/dist/kernel/descriptor-loader.js +48 -0
  142. package/dist/kernel/document.d.ts +43 -0
  143. package/dist/kernel/document.js +71 -0
  144. package/dist/kernel/embedding.d.ts +28 -0
  145. package/dist/kernel/embedding.js +78 -0
  146. package/dist/kernel/errors.d.ts +62 -0
  147. package/dist/kernel/errors.js +82 -0
  148. package/dist/kernel/events.d.ts +6 -0
  149. package/dist/kernel/events.js +21 -0
  150. package/dist/kernel/evidence-capture.d.ts +69 -0
  151. package/dist/kernel/evidence-capture.js +138 -0
  152. package/dist/kernel/fs.d.ts +20 -0
  153. package/dist/kernel/fs.js +128 -0
  154. package/dist/kernel/generic-rw.d.ts +33 -0
  155. package/dist/kernel/generic-rw.js +235 -0
  156. package/dist/kernel/hooks.d.ts +172 -0
  157. package/dist/kernel/hooks.js +256 -0
  158. package/dist/kernel/index.d.ts +624 -0
  159. package/dist/kernel/index.js +1638 -0
  160. package/dist/kernel/instance.d.ts +211 -0
  161. package/dist/kernel/instance.js +487 -0
  162. package/dist/kernel/kind-registry.d.ts +183 -0
  163. package/dist/kernel/kind-registry.js +710 -0
  164. package/dist/kernel/kind_base.d.ts +106 -0
  165. package/dist/kernel/kind_base.js +244 -0
  166. package/dist/kernel/layer-resolver.d.ts +48 -0
  167. package/dist/kernel/layer-resolver.js +284 -0
  168. package/dist/kernel/lock-manager.d.ts +21 -0
  169. package/dist/kernel/lock-manager.js +43 -0
  170. package/dist/kernel/lock.d.ts +38 -0
  171. package/dist/kernel/lock.js +115 -0
  172. package/dist/kernel/meta.d.ts +135 -0
  173. package/dist/kernel/meta.js +817 -0
  174. package/dist/kernel/models.d.ts +3089 -0
  175. package/dist/kernel/models.js +764 -0
  176. package/dist/kernel/navigator.d.ts +36 -0
  177. package/dist/kernel/navigator.js +132 -0
  178. package/dist/kernel/port-surface.d.ts +33 -0
  179. package/dist/kernel/port-surface.js +180 -0
  180. package/dist/kernel/preview.d.ts +60 -0
  181. package/dist/kernel/preview.js +54 -0
  182. package/dist/kernel/prompt-budget.d.ts +39 -0
  183. package/dist/kernel/prompt-budget.js +43 -0
  184. package/dist/kernel/prompt-builder.d.ts +25 -0
  185. package/dist/kernel/prompt-builder.js +237 -0
  186. package/dist/kernel/protocols.d.ts +751 -0
  187. package/dist/kernel/protocols.js +493 -0
  188. package/dist/kernel/reports.d.ts +26 -0
  189. package/dist/kernel/reports.js +215 -0
  190. package/dist/kernel/resolver.d.ts +146 -0
  191. package/dist/kernel/resolver.js +232 -0
  192. package/dist/kernel/resource.d.ts +57 -0
  193. package/dist/kernel/resource.js +97 -0
  194. package/dist/kernel/runtime.d.ts +16 -0
  195. package/dist/kernel/runtime.js +18 -0
  196. package/dist/kernel/safety-scanner.d.ts +38 -0
  197. package/dist/kernel/safety-scanner.js +228 -0
  198. package/dist/kernel/serialize-to-files.d.ts +29 -0
  199. package/dist/kernel/serialize-to-files.js +23 -0
  200. package/dist/kernel/spec-access.d.ts +23 -0
  201. package/dist/kernel/spec-access.js +40 -0
  202. package/dist/kernel/studio_ui.d.ts +88 -0
  203. package/dist/kernel/studio_ui.js +135 -0
  204. package/dist/kernel/templates.d.ts +77 -0
  205. package/dist/kernel/templates.js +116 -0
  206. package/dist/kernel/tool-registry.d.ts +52 -0
  207. package/dist/kernel/tool-registry.js +89 -0
  208. package/dist/kernel/write-pipeline.d.ts +65 -0
  209. package/dist/kernel/write-pipeline.js +271 -0
  210. package/dist/kernel/writer-helpers.d.ts +24 -0
  211. package/dist/kernel/writer-helpers.js +42 -0
  212. package/dist/memory/decay.d.ts +31 -0
  213. package/dist/memory/decay.js +97 -0
  214. package/dist/memory/ecphory.d.ts +25 -0
  215. package/dist/memory/ecphory.js +178 -0
  216. package/dist/memory/encodingContext.d.ts +21 -0
  217. package/dist/memory/encodingContext.js +62 -0
  218. package/dist/memory/index.d.ts +23 -0
  219. package/dist/memory/index.js +23 -0
  220. package/dist/memory/memoryType.d.ts +7 -0
  221. package/dist/memory/memoryType.js +24 -0
  222. package/dist/memory/policy.d.ts +35 -0
  223. package/dist/memory/policy.js +35 -0
  224. package/dist/memory/retrieval.d.ts +21 -0
  225. package/dist/memory/retrieval.js +145 -0
  226. package/dist/testing/index.d.ts +8 -0
  227. package/dist/testing/index.js +8 -0
  228. package/dist/testing/recordSearchConformance.d.ts +43 -0
  229. package/dist/testing/recordSearchConformance.js +147 -0
  230. package/dist/viz/ascii.d.ts +7 -0
  231. package/dist/viz/ascii.js +60 -0
  232. package/dist/viz/health.d.ts +8 -0
  233. package/dist/viz/health.js +161 -0
  234. package/dist/viz/index.d.ts +10 -0
  235. package/dist/viz/index.js +10 -0
  236. package/dist/viz/matrix.d.ts +8 -0
  237. package/dist/viz/matrix.js +84 -0
  238. package/dist/viz/mermaid.d.ts +38 -0
  239. package/dist/viz/mermaid.js +706 -0
  240. package/package.json +82 -0
@@ -0,0 +1,211 @@
1
+ import { KindBase } from "../kernel/kind_base.js";
2
+ import { SD, TenantScope } from "../kernel/protocols.js";
3
+ // NOTE: the `ui = docs_ui(...)` Studio-sidebar metadata is Python-only (served
4
+ // by kinds-api); there is no TS `studio_ui` twin and the parity test does not
5
+ // cover `ui` (the HookType TS twin omits it too). Kept off the TS Kinds.
6
+ const API_VERSION = "github.com/ruinosus/dna/testkit/v1";
7
+ const ORIGIN = "github.com/ruinosus/dna/testkit";
8
+ // Excludes "unit" — unit tests live in the CI suites, not human/orchestrated guides.
9
+ const TEST_KINDS = ["manual", "smoke", "e2e", "regression", "integration"];
10
+ const GUIDE_STATUS = ["draft", "active", "deprecated"];
11
+ const RUN_OUTCOME = ["pass", "fail", "partial", "blocked"];
12
+ const STEP_RESULT = ["pass", "fail", "skip"];
13
+ class TestGuideKind extends KindBase {
14
+ apiVersion = API_VERSION;
15
+ kind = "TestGuide";
16
+ alias = "testkit-test-guide";
17
+ origin = ORIGIN;
18
+ scope = TenantScope.GLOBAL;
19
+ storage = SD.yaml("test-guides");
20
+ isPromptTarget = false;
21
+ promptTargetPriority = 0;
22
+ flattenInContext = false;
23
+ isSchemaAffecting = false;
24
+ // Inheritable by default (like HtmlArtifact/Research — an artifact, not a work-item).
25
+ graphStyle = { fill: "#2DD4BF", stroke: "#0D9488", textColor: "#fff" };
26
+ asciiIcon = "🧪";
27
+ displayLabel = "Test Guides";
28
+ docs = "A TestGuide is a declarative test SCRIPT: an ordered list of steps " +
29
+ "(action → expected) that validates one or more work items. A versioned, " +
30
+ "schema-validated, re-runnable doc. Links to its Story via `verifies`.";
31
+ depFilters() { return null; }
32
+ getDefaultAgentName() { return null; }
33
+ getLayerPolicies() { return null; }
34
+ parse(raw) { return raw; }
35
+ promptTemplate() { return null; }
36
+ schema() {
37
+ return {
38
+ type: "object",
39
+ required: ["description", "kind_of_test", "steps"],
40
+ additionalProperties: false,
41
+ properties: {
42
+ description: {
43
+ type: "string",
44
+ description: "What this guide validates (one line or short paragraph).",
45
+ },
46
+ kind_of_test: { type: "string", enum: TEST_KINDS },
47
+ status: { type: "string", enum: GUIDE_STATUS, default: "active" },
48
+ steps: {
49
+ type: "array",
50
+ minItems: 1,
51
+ items: {
52
+ type: "object",
53
+ required: ["action", "expected"],
54
+ additionalProperties: false,
55
+ properties: {
56
+ action: { type: "string", description: "What the tester does." },
57
+ expected: { type: "string", description: "Observable expected result." },
58
+ where: {
59
+ type: "string",
60
+ description: "Where in the product to do it (route/screen) so a non-dev can follow, e.g. '/scopes/:scope/sdlc/v2?t=focus'.",
61
+ },
62
+ },
63
+ },
64
+ },
65
+ verifies: {
66
+ type: "array",
67
+ items: { type: "string" },
68
+ default: [],
69
+ description: "Work items this guide verifies, as 'Kind/name' refs (e.g. 'Story/s-x').",
70
+ },
71
+ prerequisites: {
72
+ type: "array",
73
+ items: { type: "string" },
74
+ default: [],
75
+ description: "Setup needed before running, e.g. ['make up', 'tenant acme selected'].",
76
+ },
77
+ scope_hint: { type: "string", description: "Target area/scope for the run." },
78
+ owner: { type: "string", description: "Actor who owns this guide." },
79
+ labels: { type: "array", items: { type: "string" }, default: [] },
80
+ created_at: { type: "string", format: "date-time" },
81
+ updated_at: { type: "string", format: "date-time" },
82
+ },
83
+ };
84
+ }
85
+ describe(doc) {
86
+ const spec = (doc.spec ?? {});
87
+ const steps = spec.steps ?? [];
88
+ return `${spec.kind_of_test ?? "?"} · ${steps.length} steps [${spec.status ?? "active"}]`;
89
+ }
90
+ summary(doc) {
91
+ const spec = (doc.spec ?? {});
92
+ const steps = spec.steps ?? [];
93
+ return {
94
+ kind_of_test: spec.kind_of_test ?? "",
95
+ status: spec.status ?? "active",
96
+ steps_count: steps.length,
97
+ verifies: spec.verifies ?? [],
98
+ owner: spec.owner ?? "",
99
+ };
100
+ }
101
+ }
102
+ class TestRunKind extends KindBase {
103
+ apiVersion = API_VERSION;
104
+ kind = "TestRun";
105
+ alias = "testkit-test-run";
106
+ origin = ORIGIN;
107
+ scope = TenantScope.GLOBAL;
108
+ storage = SD.yaml("test-runs");
109
+ isPromptTarget = false;
110
+ promptTargetPriority = 0;
111
+ flattenInContext = false;
112
+ isSchemaAffecting = false;
113
+ // Inheritable by default (artifact, not a work-item).
114
+ graphStyle = { fill: "#34D399", stroke: "#059669", textColor: "#fff" };
115
+ asciiIcon = "🧾";
116
+ displayLabel = "Test Runs";
117
+ docs = "A TestRun is an EXECUTION record of a TestGuide: the outcome " +
118
+ "(pass/fail/partial/blocked), who ran it, per-step results and evidence. " +
119
+ "A passing run whose `verifies` points at a Story drives the derived " +
120
+ "journey's `verify` phase.";
121
+ depFilters() { return null; }
122
+ getDefaultAgentName() { return null; }
123
+ getLayerPolicies() { return null; }
124
+ parse(raw) { return raw; }
125
+ promptTemplate() { return null; }
126
+ schema() {
127
+ return {
128
+ type: "object",
129
+ required: ["guide_ref", "outcome"],
130
+ additionalProperties: false,
131
+ properties: {
132
+ guide_ref: { type: "string", description: "Name of the TestGuide that was executed." },
133
+ outcome: { type: "string", enum: RUN_OUTCOME },
134
+ verifies: {
135
+ type: "array",
136
+ items: { type: "string" },
137
+ default: [],
138
+ description: "Work items this run verifies (inherited from the guide); drives journey 'verify'.",
139
+ },
140
+ executed_by: { type: "string", description: "Actor who ran it." },
141
+ executed_at: { type: "string", format: "date-time" },
142
+ step_results: {
143
+ type: "array",
144
+ default: [],
145
+ items: {
146
+ type: "object",
147
+ required: ["step_index", "result"],
148
+ additionalProperties: false,
149
+ properties: {
150
+ step_index: { type: "integer", minimum: 0 },
151
+ result: { type: "string", enum: STEP_RESULT },
152
+ notes: { type: "string" },
153
+ screenshot: {
154
+ type: "string",
155
+ description: "Screenshot evidence for this step (data URL or asset ref).",
156
+ },
157
+ },
158
+ },
159
+ },
160
+ evidence: {
161
+ type: "array",
162
+ items: { type: "string" },
163
+ default: [],
164
+ description: "Refs/links backing the outcome, e.g. ['HtmlArtifact/ha-x', urls].",
165
+ },
166
+ screenshots: {
167
+ type: "array",
168
+ default: [],
169
+ items: {
170
+ type: "object",
171
+ properties: {
172
+ asset: { type: "string" },
173
+ mime: { type: "string" },
174
+ blob: { type: "string" },
175
+ },
176
+ required: ["asset"],
177
+ },
178
+ description: "Run-level evidence prints, Asset-backed (asset name + blob path), NOT inline base64.",
179
+ },
180
+ notes: { type: "string" },
181
+ labels: { type: "array", items: { type: "string" }, default: [] },
182
+ },
183
+ };
184
+ }
185
+ describe(doc) {
186
+ const spec = (doc.spec ?? {});
187
+ return `${spec.guide_ref ?? "?"} → ${spec.outcome ?? "?"}`;
188
+ }
189
+ summary(doc) {
190
+ const spec = (doc.spec ?? {});
191
+ return {
192
+ guide_ref: spec.guide_ref ?? "",
193
+ outcome: spec.outcome ?? "",
194
+ executed_by: spec.executed_by ?? "",
195
+ executed_at: spec.executed_at ?? null,
196
+ verifies: spec.verifies ?? [],
197
+ };
198
+ }
199
+ }
200
+ export class TestkitExtension {
201
+ name = "testkit";
202
+ version = "1.0.0";
203
+ register(kernel) {
204
+ kernel.kind(new TestGuideKind());
205
+ kernel.kind(new TestRunKind());
206
+ }
207
+ /** Parity with Python's `TestkitExtension.kinds()`. */
208
+ kinds() {
209
+ return [new TestGuideKind(), new TestRunKind()];
210
+ }
211
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * DNA SDK v3 — TypeScript entry point.
3
+ *
4
+ * Re-exports the microkernel (5-port architecture), adapters, and extensions.
5
+ */
6
+ export { Kernel } from "./kernel/index.js";
7
+ export { Runtime } from "./kernel/runtime.js";
8
+ export { ManifestInstance } from "./kernel/instance.js";
9
+ export { materialize } from "./kernel/templates.js";
10
+ export type { Template, MaterializeOptions, OnConflict } from "./kernel/templates.js";
11
+ export type { PreviewBlock } from "./kernel/preview.js";
12
+ export { Document } from "./kernel/document.js";
13
+ export { Resource, type ResourceDep } from "./kernel/resource.js";
14
+ export { PromptBuilder } from "./kernel/prompt-builder.js";
15
+ export { CompositionEngine } from "./kernel/composition-resolver.js";
16
+ export { BOOTSTRAP_KINDS, DEFAULT_NON_INHERITABLE_KINDS_V1, DEFAULT_INHERITABLE_KINDS_V1, MAX_RESOLUTION_DEPTH, ResolutionLayer, ResolutionPath, ResolvedDocument, mergeOverrideFull, mergeFieldLevel, type Contribution, type Raw, } from "./kernel/resolver.js";
17
+ export { CompositionResolver } from "./kernel/composition-resolver.js";
18
+ export { Navigator } from "./kernel/navigator.js";
19
+ export { StudioUIMetadata, UI_METADATA_FIELDS, type ModeId, type UIAction, type LabelI18n, type UIMetadataField, type StudioUIMetadataInit, } from "./kernel/studio_ui.js";
20
+ export { LockManager } from "./kernel/lock-manager.js";
21
+ export { ReportBuilder } from "./kernel/reports.js";
22
+ export { serializeRawToFiles } from "./kernel/serialize-to-files.js";
23
+ export * from "./viz/index.js";
24
+ export { createKernelWithBuiltins, quickInstance, createRuntimeWithBuiltins, quickManifest } from "./bootstrap.js";
25
+ export { HookRegistry, KNOWN_HOOK_NAMES } from "./kernel/hooks.js";
26
+ export type { HookContext, HookName, HookNameArg, Middleware, EventHandler, PreSaveContext, VetoHandler, } from "./kernel/hooks.js";
27
+ export type { SourcePort, CachePort, ResolverPort, ReaderPort, WriterPort, KindPort, KindPresentation, Extension, ExtensionHost, CompositionResult, CacheItem, ResolvedItem, StorageDescriptor, StoragePattern, BodyMode, SerializedFile, SerializedDocument, WritableSourcePort, QueryFilter, QueryOrder, CountResult, SourceQueryOpts, SourceCountOpts, RecordStorePort, RecordSearchProvider, EmbeddingPort, ToolPort, } from "./kernel/protocols.js";
28
+ export { TenantScope } from "./kernel/protocols.js";
29
+ export type { PreviewResult } from "./kernel/index.js";
30
+ export type { PreviewBlockKind } from "./kernel/preview.js";
31
+ export type { BuildPromptOpts } from "./kernel/instance.js";
32
+ export type { SourceCapabilities } from "./kernel/capabilities.js";
33
+ export type { CompositionSlot, HealthCheckHint, QuadrantHint, TimelineHint, } from "./kernel/composition-resolver.js";
34
+ export { sourceCapabilities, deriveCapabilities } from "./kernel/capabilities.js";
35
+ export type { KindLike } from "./kernel/resource.js";
36
+ export type { AsyncEventHandler } from "./kernel/hooks.js";
37
+ export type { CompositionProfile } from "./kernel/composition-resolver.js";
38
+ export type { BundleHandle } from "./kernel/bundle-handle.js";
39
+ export type { LayerSource } from "./kernel/layer-resolver.js";
40
+ export { ToolDefinition } from "./kernel/protocols.js";
41
+ export { FakeEmbeddingProvider, fakeEmbedOne, FAKE_EMBEDDING_DIMS, FAKE_EMBEDDING_MODEL_ID, } from "./kernel/embedding.js";
42
+ export { ToolRegistry, READ_UMBRELLA_GROUPS, expandGroupAliases, } from "./kernel/tool-registry.js";
43
+ export { PORT_SURFACE } from "./kernel/port-surface.js";
44
+ export { LayerPolicy, LayerPolicyViolationError, ResolveError, ResolveNotFoundError, ResolveAuthError, ResolveNetworkError, SD, QueryError, QUERY_OPS, resolveFieldPath, matchFilter, applyOrderBy, queryDocs, countDocs, } from "./kernel/protocols.js";
45
+ export { documentHash } from "./kernel/lock.js";
46
+ export { readSpecString, readSpecStringArray, readSpecRecord, readSpecRecordArray, } from "./kernel/spec-access.js";
47
+ export type { LockEntry, Lockfile } from "./kernel/lock.js";
48
+ export type { FSLike } from "./kernel/fs.js";
49
+ export { nodeFS, createMemoryFS } from "./kernel/fs.js";
50
+ export { MetadataSchema, GenomeSchema, LayerPolicySchema, AgentSchema, ActorSchema, UseCaseSchema, SkillSchema, SoulSchema, AgentDefinitionSchema, HookSchema, HookSpecSchema, SafetyPolicySchema, SafetyPolicySpecSchema, SafetyRuleSchema, RecognizerSchema, RecognizerSpecSchema, RecognizerPatternSchema, } from "./kernel/models.js";
51
+ export { FilesystemSource } from "./adapters/filesystem/source.js";
52
+ export { FilesystemCache } from "./adapters/filesystem/cache.js";
53
+ export { LocalResolver } from "./adapters/resolvers/local.js";
54
+ export { HelixExtension } from "./extensions/helix.js";
55
+ export { AgentSkillsExtension } from "./extensions/agentskills.js";
56
+ export { SoulSpecExtension } from "./extensions/soulspec.js";
57
+ export { AgentsMdExtension } from "./extensions/agentsmd.js";
58
+ export { GuardrailExtension } from "./extensions/guardrails.js";
59
+ export { HookExtension } from "./extensions/hooks.js";
60
+ export { SafetyPolicyExtension } from "./extensions/safety.js";
61
+ export { RecognizerExtension } from "./extensions/recognizer.js";
62
+ export { KindDefinitionExtension, KindDefinitionReader, KindDefinitionWriter } from "./extensions/kinddef.js";
63
+ export { EvidenceExtension, shouldCapture } from "./extensions/evidence.js";
64
+ export { DocExtension } from "./extensions/doc.js";
65
+ export { ResearchExtension } from "./extensions/research.js";
66
+ export { CollabExtension } from "./extensions/collab.js";
67
+ export { FederationExtension } from "./extensions/federation.js";
68
+ export { SdlcExtension } from "./extensions/sdlc.js";
69
+ export { ModelRegExtension } from "./extensions/modelreg.js";
70
+ export { AutomationExtension } from "./extensions/automation.js";
71
+ export { EvalExtension } from "./extensions/eval.js";
72
+ export { automationsFor, triggerKey, TRIGGER_TYPES, } from "./extensions/automation/query.js";
73
+ export type { TriggerType } from "./extensions/automation/query.js";
74
+ export { validateCronExpression, automationTriggerGuard, } from "./extensions/automation/write-guards.js";
75
+ export { CHARS_PER_TOKEN, estimateTokens, evaluateInstructionBudget, PromptBudgetExceededError, } from "./kernel/prompt-budget.js";
76
+ export type { BudgetVerdict } from "./kernel/prompt-budget.js";
77
+ export { DeclarativeKindPort, storageDictToDescriptor } from "./kernel/meta.js";
78
+ export { KindDefinitionSchema, KindDefinitionSpecSchema, KIND_DEFINITION_API_VERSION, KIND_DEFINITION_KIND } from "./kernel/models.js";
79
+ export type { TypedKindDefinition } from "./kernel/models.js";
80
+ export { DefaultLayerResolver, deepMerge } from "./kernel/layer-resolver.js";
package/dist/index.js ADDED
@@ -0,0 +1,102 @@
1
+ /**
2
+ * DNA SDK v3 — TypeScript entry point.
3
+ *
4
+ * Re-exports the microkernel (5-port architecture), adapters, and extensions.
5
+ */
6
+ // Kernel
7
+ export { Kernel } from "./kernel/index.js";
8
+ export { Runtime } from "./kernel/runtime.js";
9
+ export { ManifestInstance } from "./kernel/instance.js";
10
+ export { materialize } from "./kernel/templates.js";
11
+ export { Document } from "./kernel/document.js";
12
+ export { Resource } from "./kernel/resource.js";
13
+ export { PromptBuilder } from "./kernel/prompt-builder.js";
14
+ export { CompositionEngine } from "./kernel/composition-resolver.js";
15
+ // Composition Engine V2 resolver module (twin of kernel/resolver.py).
16
+ export { BOOTSTRAP_KINDS, DEFAULT_NON_INHERITABLE_KINDS_V1, DEFAULT_INHERITABLE_KINDS_V1, MAX_RESOLUTION_DEPTH, ResolutionLayer, ResolutionPath, ResolvedDocument, mergeOverrideFull, mergeFieldLevel, } from "./kernel/resolver.js";
17
+ // Composition Engine V2 orchestration (twin of kernel/composition_resolver.py).
18
+ export { CompositionResolver } from "./kernel/composition-resolver.js";
19
+ export { Navigator } from "./kernel/navigator.js";
20
+ export { StudioUIMetadata, UI_METADATA_FIELDS, } from "./kernel/studio_ui.js";
21
+ export { LockManager } from "./kernel/lock-manager.js";
22
+ export { ReportBuilder } from "./kernel/reports.js";
23
+ export { serializeRawToFiles } from "./kernel/serialize-to-files.js";
24
+ // Viz — diagram generators, health, matrix, ASCII tree
25
+ export * from "./viz/index.js";
26
+ // Opinionated bootstrap — extension wiring lives here, not in kernel/
27
+ export { createKernelWithBuiltins, quickInstance, createRuntimeWithBuiltins, quickManifest } from "./bootstrap.js";
28
+ export { HookRegistry, KNOWN_HOOK_NAMES } from "./kernel/hooks.js";
29
+ // i-005 — types REFERENCED by already-exported public API, previously
30
+ // broken xrefs in TypeDoc. Each is public surface a consumer needs to name:
31
+ // TenantScope — DeclarativeKindPort.scope (tenancy is a first-class
32
+ // kernel dimension; the Py twin exports it publicly)
33
+ // PreviewResult — return type of Kernel.previewDocument
34
+ // PreviewBlockKind — field type of the exported PreviewBlock
35
+ // BuildPromptOpts — opts of the blessed ManifestInstance.buildPrompt
36
+ // SourceCapabilities — fixture-tracked port (port-surface-parity.json)
37
+ // KindLike — Resource.kindRef contract
38
+ // AsyncEventHandler — accepted by HookRegistry.on (sibling of EventHandler)
39
+ // CompositionProfile — returned by ManifestInstance.profileFor, registered
40
+ // via the kernel's composition-profile registry
41
+ // BundleHandle — ReaderPort.detect/read param; readers/writers are a
42
+ // documented extension point (the Py twin re-exports
43
+ // it from dna.kernel.protocols for typing too)
44
+ // LayerSource — param of the exported DefaultLayerResolver.resolve
45
+ // None of these adds a ManifestInstance member or a port member, so the
46
+ // blessed_query_surface / port-surface fixtures are unaffected (type-only
47
+ // re-exports). Internals stay unexported via typedoc.json
48
+ // `intentionallyNotExported` (CompositionResolverHost, QueryableInstance,
49
+ // ManifestInstanceOpts, DeclarativeMarker).
50
+ export { TenantScope } from "./kernel/protocols.js";
51
+ export { sourceCapabilities, deriveCapabilities } from "./kernel/capabilities.js";
52
+ export { ToolDefinition } from "./kernel/protocols.js";
53
+ // rec-embedding-port — zero-dep deterministic embedding floor (the default).
54
+ export { FakeEmbeddingProvider, fakeEmbedOne, FAKE_EMBEDDING_DIMS, FAKE_EMBEDDING_MODEL_ID, } from "./kernel/embedding.js";
55
+ export { ToolRegistry, READ_UMBRELLA_GROUPS, expandGroupAliases, } from "./kernel/tool-registry.js";
56
+ // Port-surface parity manifest (keyof-bound; see port-surface.ts)
57
+ export { PORT_SURFACE } from "./kernel/port-surface.js";
58
+ export { LayerPolicy, LayerPolicyViolationError, ResolveError, ResolveNotFoundError, ResolveAuthError, ResolveNetworkError, SD,
59
+ // Two-planes F2 — pure helpers (shared by the FS adapter + parity fixture)
60
+ QueryError, QUERY_OPS, resolveFieldPath, matchFilter, applyOrderBy, queryDocs, countDocs, } from "./kernel/protocols.js";
61
+ export { documentHash } from "./kernel/lock.js";
62
+ export { readSpecString, readSpecStringArray, readSpecRecord, readSpecRecordArray, } from "./kernel/spec-access.js";
63
+ export { nodeFS, createMemoryFS } from "./kernel/fs.js";
64
+ export { MetadataSchema, GenomeSchema, LayerPolicySchema, AgentSchema, ActorSchema, UseCaseSchema, SkillSchema, SoulSchema, AgentDefinitionSchema, HookSchema, HookSpecSchema, SafetyPolicySchema, SafetyPolicySpecSchema, SafetyRuleSchema, RecognizerSchema, RecognizerSpecSchema, RecognizerPatternSchema, } from "./kernel/models.js";
65
+ // Adapters
66
+ export { FilesystemSource } from "./adapters/filesystem/source.js";
67
+ export { FilesystemCache } from "./adapters/filesystem/cache.js";
68
+ export { LocalResolver } from "./adapters/resolvers/local.js";
69
+ // Extensions
70
+ export { HelixExtension } from "./extensions/helix.js";
71
+ export { AgentSkillsExtension } from "./extensions/agentskills.js";
72
+ export { SoulSpecExtension } from "./extensions/soulspec.js";
73
+ export { AgentsMdExtension } from "./extensions/agentsmd.js";
74
+ export { GuardrailExtension } from "./extensions/guardrails.js";
75
+ export { HookExtension } from "./extensions/hooks.js";
76
+ export { SafetyPolicyExtension } from "./extensions/safety.js";
77
+ export { RecognizerExtension } from "./extensions/recognizer.js";
78
+ export { KindDefinitionExtension, KindDefinitionReader, KindDefinitionWriter } from "./extensions/kinddef.js";
79
+ export { EvidenceExtension, shouldCapture } from "./extensions/evidence.js";
80
+ export { DocExtension } from "./extensions/doc.js";
81
+ export { ResearchExtension } from "./extensions/research.js";
82
+ export { CollabExtension } from "./extensions/collab.js";
83
+ // s-export-unwired-ts-extensions — these 9 had an *Extension class but were
84
+ // never exported (external consumers couldn't import them) and 3 of them
85
+ // (Community/Research/Sdlc) were loaded by no bootstrap at all. See bootstrap.ts.
86
+ export { FederationExtension } from "./extensions/federation.js";
87
+ export { SdlcExtension } from "./extensions/sdlc.js";
88
+ // s-tier-a-modelprofile — ModelProfile registry + the prompt-budget
89
+ // machinery its write guard runs on (consumers need the error class to
90
+ // catch the veto; never hardcode token caps — read the ModelProfile).
91
+ export { ModelRegExtension } from "./extensions/modelreg.js";
92
+ // s-tier-a-automation — the Automation Kind (declare-in-data, host
93
+ // executes). Hosts import the query helpers to list what to run and the
94
+ // cron validator to pre-check expressions in their own surfaces.
95
+ export { AutomationExtension } from "./extensions/automation.js";
96
+ export { EvalExtension } from "./extensions/eval.js";
97
+ export { automationsFor, triggerKey, TRIGGER_TYPES, } from "./extensions/automation/query.js";
98
+ export { validateCronExpression, automationTriggerGuard, } from "./extensions/automation/write-guards.js";
99
+ export { CHARS_PER_TOKEN, estimateTokens, evaluateInstructionBudget, PromptBudgetExceededError, } from "./kernel/prompt-budget.js";
100
+ export { DeclarativeKindPort, storageDictToDescriptor } from "./kernel/meta.js";
101
+ export { KindDefinitionSchema, KindDefinitionSpecSchema, KIND_DEFINITION_API_VERSION, KIND_DEFINITION_KIND } from "./kernel/models.js";
102
+ export { DefaultLayerResolver, deepMerge } from "./kernel/layer-resolver.js";
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Internal text helpers used by the kernel parse pipeline.
3
+ */
4
+ /**
5
+ * Normalize trailing whitespace of a text block entering PROMPT
6
+ * COMPOSITION (i-013).
7
+ *
8
+ * Bundle bodies (SOUL.md, AGENTS.md, ...) are stored byte-faithfully —
9
+ * editors re-add a trailing newline, and the rw conformance kit requires
10
+ * the WRITE path to round-trip it. But at composition time the prompt
11
+ * template supplies its own joiners (`{{{soul_content}}}\n\n`), so a
12
+ * body's trailing newline stacked into `\n\n\n` in the composed prompt.
13
+ * Strip ONLY here, at the consumption boundary — never at read/write,
14
+ * which must stay byte-identical to storage.
15
+ *
16
+ * Twin of `strip_prompt_block` in packages/sdk-py/dna/kernel/_text.py.
17
+ */
18
+ export declare function stripPromptBlock(value: string): string;
19
+ /**
20
+ * Return the first useful line of a markdown/text blob.
21
+ *
22
+ * Strips leading heading markers (`#`) and surrounding whitespace, skips
23
+ * empty lines and divider-only lines (`---`, `===`, etc.). Truncates to
24
+ * `maxLen` chars with an ellipsis suffix.
25
+ *
26
+ * Returns `null` if no meaningful line is found.
27
+ */
28
+ export declare function deriveFirstLine(text: string | null | undefined, maxLen?: number): string | null;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Internal text helpers used by the kernel parse pipeline.
3
+ */
4
+ /**
5
+ * Normalize trailing whitespace of a text block entering PROMPT
6
+ * COMPOSITION (i-013).
7
+ *
8
+ * Bundle bodies (SOUL.md, AGENTS.md, ...) are stored byte-faithfully —
9
+ * editors re-add a trailing newline, and the rw conformance kit requires
10
+ * the WRITE path to round-trip it. But at composition time the prompt
11
+ * template supplies its own joiners (`{{{soul_content}}}\n\n`), so a
12
+ * body's trailing newline stacked into `\n\n\n` in the composed prompt.
13
+ * Strip ONLY here, at the consumption boundary — never at read/write,
14
+ * which must stay byte-identical to storage.
15
+ *
16
+ * Twin of `strip_prompt_block` in packages/sdk-py/dna/kernel/_text.py.
17
+ */
18
+ export function stripPromptBlock(value) {
19
+ return value.trimEnd();
20
+ }
21
+ /**
22
+ * Return the first useful line of a markdown/text blob.
23
+ *
24
+ * Strips leading heading markers (`#`) and surrounding whitespace, skips
25
+ * empty lines and divider-only lines (`---`, `===`, etc.). Truncates to
26
+ * `maxLen` chars with an ellipsis suffix.
27
+ *
28
+ * Returns `null` if no meaningful line is found.
29
+ */
30
+ export function deriveFirstLine(text, maxLen = 160) {
31
+ if (!text)
32
+ return null;
33
+ for (const raw of text.split(/\r?\n/)) {
34
+ const line = raw.trim().replace(/^#+/, "").trim();
35
+ if (!line)
36
+ continue;
37
+ if (/^[-=*_]+$/.test(line))
38
+ continue;
39
+ return line.length > maxLen ? line.slice(0, maxLen) + "..." : line;
40
+ }
41
+ return null;
42
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * BundleHandle — source-agnostic interface for reading + writing a
3
+ * bundle's entries.
4
+ *
5
+ * 1:1 parity with python/dna/kernel/bundle_handle.py.
6
+ *
7
+ * Implementations:
8
+ * - `FilesystemBundleHandle` — wraps a real filesystem directory.
9
+ * - `DictBundleHandle` — in-memory, used by SQL/Postgres adapters
10
+ * (rehydrate bundle entries from `dna_bundle_entries` rows into
11
+ * a dict, hand to readers).
12
+ * - `PostgresBundleHandle` (Postgres adapter) — backed by
13
+ * `dna_bundle_entries` rows.
14
+ *
15
+ * Entry naming convention: a posix-style relative path inside the
16
+ * bundle. Top-level entries are bare names (`"SKILL.md"`,
17
+ * `"IDENTITY.md"`); nested entries use forward slashes
18
+ * (`"scripts/run.py"`, `"references/spec.md"`).
19
+ *
20
+ * v1.0 async refactor: read/write methods return `Promise<...>`.
21
+ * Async-everywhere is the contract — sync local-FS impls wrap their
22
+ * sync IO in `Promise.resolve` (true `fs/promises` migration is a
23
+ * v1.2 cleanup).
24
+ */
25
+ export interface BundleHandle {
26
+ /** Bundle directory name (used as default doc name when frontmatter
27
+ * omits `metadata.name`). */
28
+ readonly name: string;
29
+ /** True if the named entry (file or directory) exists in this bundle. */
30
+ exists(entry: string): Promise<boolean>;
31
+ /** Read entry content as text. Throws if absent. */
32
+ readText(entry: string, encoding?: BufferEncoding): Promise<string>;
33
+ /** Read entry content as bytes. Throws if absent. */
34
+ readBytes(entry: string): Promise<Uint8Array>;
35
+ /**
36
+ * Yield entry names (relative to the bundle root).
37
+ *
38
+ * When `recursive=false` (default), only direct children are
39
+ * yielded — both regular files and subdirectories.
40
+ * When `recursive=true`, descend into subdirectories yielding only
41
+ * regular files (no directory entries).
42
+ */
43
+ iterEntries(recursive?: boolean): Promise<string[]>;
44
+ /** True if `entry` points at a regular file (not a directory). */
45
+ isFile(entry: string): Promise<boolean>;
46
+ /** Write text content. Read-only handles throw. */
47
+ writeText(entry: string, content: string, encoding?: BufferEncoding): Promise<void>;
48
+ /** Write bytes. Read-only handles throw. */
49
+ writeBytes(entry: string, content: Uint8Array): Promise<void>;
50
+ /**
51
+ * Filesystem path when the handle wraps a real directory; null
52
+ * otherwise. ESCAPE HATCH — prefer explicit read/write/iter methods.
53
+ * Use only when an external library demands a real path (e.g.
54
+ * `fs.cp`, third-party tooling).
55
+ */
56
+ readonly path: string | null;
57
+ }
58
+ export declare class FilesystemBundleHandle implements BundleHandle {
59
+ private readonly _root;
60
+ constructor(_root: string);
61
+ get name(): string;
62
+ get path(): string | null;
63
+ exists(entry: string): Promise<boolean>;
64
+ readText(entry: string, encoding?: BufferEncoding): Promise<string>;
65
+ readBytes(entry: string): Promise<Uint8Array>;
66
+ iterEntries(recursive?: boolean): Promise<string[]>;
67
+ isFile(entry: string): Promise<boolean>;
68
+ writeText(entry: string, content: string, encoding?: BufferEncoding): Promise<void>;
69
+ writeBytes(entry: string, content: Uint8Array): Promise<void>;
70
+ }
71
+ export declare class DictBundleHandle implements BundleHandle {
72
+ readonly name: string;
73
+ private _entries;
74
+ constructor(name: string, entries?: Record<string, string | Uint8Array>);
75
+ get path(): string | null;
76
+ exists(entry: string): Promise<boolean>;
77
+ readText(entry: string, _encoding?: BufferEncoding): Promise<string>;
78
+ readBytes(entry: string): Promise<Uint8Array>;
79
+ iterEntries(recursive?: boolean): Promise<string[]>;
80
+ isFile(entry: string): Promise<boolean>;
81
+ writeText(entry: string, content: string, _encoding?: BufferEncoding): Promise<void>;
82
+ writeBytes(entry: string, content: Uint8Array): Promise<void>;
83
+ }