@nanobpm/urban 0.52.0 → 0.53.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.
- package/README.md +47 -20
- package/dist/runtime/core/events.d.ts +135 -0
- package/dist/runtime/core/events.js +329 -0
- package/dist/runtime/core/extensions.d.ts +131 -0
- package/dist/runtime/core/extensions.js +137 -0
- package/dist/runtime/core/glob.d.ts +7 -6
- package/dist/runtime/core/glob.js +16 -14
- package/dist/runtime/core/host.d.ts +4 -1
- package/dist/runtime/core/modules/agent.d.ts +17 -0
- package/dist/runtime/core/modules/agent.js +63 -0
- package/dist/runtime/core/modules/deploy.d.ts +8 -5
- package/dist/runtime/core/modules/deploy.js +62 -16
- package/dist/runtime/core/modules/pages.js +397 -20
- package/dist/runtime/core/modules/surfaces.js +8 -0
- package/dist/runtime/core/phase.d.ts +168 -0
- package/dist/runtime/core/phase.js +367 -0
- package/dist/runtime/core/runtime.d.ts +17 -0
- package/dist/runtime/core/runtime.js +30 -0
- package/dist/runtime/index.d.ts +6 -0
- package/dist/runtime/index.js +7 -0
- package/dist/toolkit/derivers/system-brief.d.ts +62 -0
- package/dist/toolkit/derivers/system-brief.js +156 -0
- package/dist/toolkit/gen.d.ts +5 -5
- package/dist/toolkit/gen.js +20 -14
- package/dist/toolkit/index.d.ts +5 -0
- package/dist/toolkit/index.js +3 -0
- package/dist/toolkit/models.d.ts +4 -3
- package/dist/toolkit/models.js +4 -3
- package/package.json +1 -1
- package/src/runtime/core/events.test.ts +382 -0
- package/src/runtime/core/events.ts +370 -0
- package/src/runtime/core/extensions.test.ts +378 -0
- package/src/runtime/core/extensions.ts +276 -0
- package/src/runtime/core/glob.ts +15 -12
- package/src/runtime/core/host.ts +4 -1
- package/src/runtime/core/modules/agent.test.ts +104 -0
- package/src/runtime/core/modules/agent.ts +76 -0
- package/src/runtime/core/modules/deploy.test.ts +84 -16
- package/src/runtime/core/modules/deploy.ts +59 -16
- package/src/runtime/core/modules/pages.test.ts +309 -5
- package/src/runtime/core/modules/pages.ts +398 -20
- package/src/runtime/core/modules/surfaces.ts +9 -0
- package/src/runtime/core/phase.test.ts +350 -0
- package/src/runtime/core/phase.ts +526 -0
- package/src/runtime/core/runtime.extensions.test.ts +151 -0
- package/src/runtime/core/runtime.ts +49 -0
- package/src/runtime/devserver.test.ts +3 -0
- package/src/runtime/index.ts +57 -0
- package/src/toolkit/derivers/system-brief.test.ts +150 -0
- package/src/toolkit/derivers/system-brief.ts +210 -0
- package/src/toolkit/gen.test.ts +28 -4
- package/src/toolkit/gen.ts +20 -13
- package/src/toolkit/index.ts +14 -0
- package/src/toolkit/models.ts +4 -3
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { createUrbanApp } from "./core/runtime.ts";
|
|
2
2
|
export type { CreateUrbanAppOptions, MountFlags, UrbanApp, } from "./core/runtime.ts";
|
|
3
|
+
export { EventBus } from "./core/events.ts";
|
|
4
|
+
export type { DispatchMode, Disposer, EmitChannel, ErrorSink, EventBusOptions, Listener, Middleware, ParallelChannel, SerialChannel, WaterfallChannel, } from "./core/events.ts";
|
|
5
|
+
export { URBAN_EVENT_MODES, createUrbanEvents, mountExtensions, urbanEventMode } from "./core/extensions.ts";
|
|
6
|
+
export type { DispatchRequest, DispatchResponse, ExtensionHost, ExtensionRegistered, ExtensionSetupContext, GateDecision, GateRequest, LifecycleEvent, MountExtensionsOptions, ReconcileEvent, UrbanEventName, UrbanEvents, UrbanExtension, } from "./core/extensions.ts";
|
|
3
7
|
export { bindModeToHost, expandEnv, expandEnvString, isBindMode, loadManifest, parseManifest, resolveBindHost, resolveBindMode, workerJobType, ALL_INTERFACES_HOST, BIND_ENV_VAR, LOOPBACK_HOST, } from "./core/manifest.ts";
|
|
4
8
|
export type { ActionDecl, AppManifest, BindMode, ChatSurface, DataSource, DomainField, DomainType, LlmBinding, NetworkConfig, PagesSurface, Surfaces, TaskInboxSurface, Trigger, Worker, } from "./core/manifest.ts";
|
|
5
9
|
export { collectManifestIssues, ManifestValidationError, validateManifest, } from "./core/validate.ts";
|
|
@@ -35,6 +39,8 @@ export { applyAmbientLineage, buildLineageTree, deriveLineage, LINEAGE_KEY, LINE
|
|
|
35
39
|
export type { ApplyLineageOptions, LineageAttachment, LineageEdge, LineageEdgeType, LineageEnvelope, LineageNode, LineageTree, } from "./core/lineage.ts";
|
|
36
40
|
export { LINEAGE_ATTACHMENTS_TABLE, LINEAGE_EDGES_TABLE, LINEAGE_SCHEMA_SQL, LineageStore, systemClock as lineageSystemClock, } from "./core/modules/lineage-store.ts";
|
|
37
41
|
export type { Clock as LineageClock, LineageJobLike, LineageStoreOptions, } from "./core/modules/lineage-store.ts";
|
|
42
|
+
export { buildScopeIndex, derivePhase, deriveInstancePhases, furthestReached, rollupLineagePhase, SCOPE_CONTAINERS, } from "./core/phase.ts";
|
|
43
|
+
export type { CrumbKind, CrumbSource, DerivePhaseOptions, FurthestReached, InstancePhase, LineagePhaseRollup, Phase, PhaseCrumb, PhaseGranularity, ProvenanceProgressRow, ScopeElement, ScopeIndex, } from "./core/phase.ts";
|
|
38
44
|
export { deployModels, RESOURCES_DIR } from "./core/modules/deploy.ts";
|
|
39
45
|
export { defaultScheduler, MAX_TIMER_DELAY_MS } from "./core/modules/scheduler.ts";
|
|
40
46
|
export type { SchedulerDeps } from "./core/modules/scheduler.ts";
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// Public API for the Urban runtime (@nanobpm/urban, subpath ./runtime).
|
|
2
2
|
// Core runtime
|
|
3
3
|
export { createUrbanApp } from "./core/runtime.js";
|
|
4
|
+
// Extension-event taxonomy + microkernel (issue #262)
|
|
5
|
+
export { EventBus } from "./core/events.js";
|
|
6
|
+
export { URBAN_EVENT_MODES, createUrbanEvents, mountExtensions, urbanEventMode } from "./core/extensions.js";
|
|
4
7
|
// Manifest
|
|
5
8
|
export { bindModeToHost, expandEnv, expandEnvString, isBindMode, loadManifest, parseManifest, resolveBindHost, resolveBindMode, workerJobType, ALL_INTERFACES_HOST, BIND_ENV_VAR, LOOPBACK_HOST, } from "./core/manifest.js";
|
|
6
9
|
// Validation
|
|
@@ -33,6 +36,10 @@ export { evalCorrelation } from "./core/modules/triggers.js";
|
|
|
33
36
|
// progress (a root request → the instances/PRs/tasks it causes).
|
|
34
37
|
export { applyAmbientLineage, buildLineageTree, deriveLineage, LINEAGE_KEY, LINEAGE_NAMESPACE, mintRootRequestKey, readLineage, writeLineage, } from "./core/lineage.js";
|
|
35
38
|
export { LINEAGE_ATTACHMENTS_TABLE, LINEAGE_EDGES_TABLE, LINEAGE_SCHEMA_SQL, LineageStore, systemClock as lineageSystemClock, } from "./core/modules/lineage-store.js";
|
|
39
|
+
// Phase — the framework-level *domain phase* primitive (issue #266): derive "which phase is this
|
|
40
|
+
// instance in?" from the BPMN scope hierarchy + write-provenance (Tier 0, zero declaration), an
|
|
41
|
+
// optional `nano:phase` override (Tier 1), and a lineage rollup for the epic frontier (Tier 2).
|
|
42
|
+
export { buildScopeIndex, derivePhase, deriveInstancePhases, furthestReached, rollupLineagePhase, SCOPE_CONTAINERS, } from "./core/phase.js";
|
|
36
43
|
// Model deploy (deploy-by-convention under `resources/`, ADR 0062)
|
|
37
44
|
export { deployModels, RESOURCES_DIR } from "./core/modules/deploy.js";
|
|
38
45
|
export { defaultScheduler, MAX_TIMER_DELAY_MS } from "./core/modules/scheduler.js";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { DerivedArtifact, Deriver } from "../artifact.ts";
|
|
2
|
+
import { type ModelSource, type WorkerIo } from "./worker-io.ts";
|
|
3
|
+
/** Basenames of the two emitted artifacts. */
|
|
4
|
+
export declare const SYSTEM_BRIEF_MD = "system-brief.md";
|
|
5
|
+
export declare const SYSTEM_BRIEF_JSON = "system-brief.json";
|
|
6
|
+
/** Reserved `nano:meta` keys the brief recognises as ownership / provenance context (ADR 0060
|
|
7
|
+
* §1). All optional and additive — absence degrades the brief to structure-only. `adr` may be
|
|
8
|
+
* declared more than once (repeated `nano:meta`, matching the existing scan) to reference
|
|
9
|
+
* multiple ADRs; the scan collects them into `adrs[]`. */
|
|
10
|
+
export interface Ownership {
|
|
11
|
+
owner?: string;
|
|
12
|
+
team?: string;
|
|
13
|
+
slack?: string;
|
|
14
|
+
runbook?: string;
|
|
15
|
+
since?: string;
|
|
16
|
+
adrs: string[];
|
|
17
|
+
}
|
|
18
|
+
/** One decision the app encodes: a `businessRuleTask` with a `zeebe:calledDecision`. */
|
|
19
|
+
export interface DecisionRef {
|
|
20
|
+
process?: string;
|
|
21
|
+
elementId?: string;
|
|
22
|
+
decisionId: string;
|
|
23
|
+
}
|
|
24
|
+
/** The derived, machine-readable system model — the payload of `system-brief.json` and the
|
|
25
|
+
* input the runtime injects as session context / the retro plane consumes (ADR 0060 §3). */
|
|
26
|
+
export interface SystemBrief {
|
|
27
|
+
/** App id/name from the manifest, if provided. */
|
|
28
|
+
app?: string;
|
|
29
|
+
/** Every process id the models declare, in scan order. */
|
|
30
|
+
processes: string[];
|
|
31
|
+
/** Service-task call graph: each worker binding (task type + in/out envelope + process). The
|
|
32
|
+
* dependency edges are implicit — a process depends on the task types its service tasks invoke. */
|
|
33
|
+
workers: WorkerIo[];
|
|
34
|
+
/** Decisions (`businessRuleTask` → DMN) the models encode. */
|
|
35
|
+
decisions: DecisionRef[];
|
|
36
|
+
/** Ownership / provenance folded from reserved `nano:meta` keys. */
|
|
37
|
+
ownership: Ownership;
|
|
38
|
+
}
|
|
39
|
+
/** Scan one BPMN document for `businessRuleTask` → `zeebe:calledDecision` decision refs, in
|
|
40
|
+
* document order, tagged with the enclosing process (mirrors `scanModelWorkers`' shape). */
|
|
41
|
+
export declare function scanModelDecisions(xml: string): DecisionRef[];
|
|
42
|
+
/** Fold the models' reserved `nano:meta` entries into `Ownership`. Single-valued keys take the
|
|
43
|
+
* last (scan-order) write, matching `foldMeta`; `adr` is multi-valued and accumulates. */
|
|
44
|
+
export declare function foldOwnership(models: ModelSource[]): Ownership;
|
|
45
|
+
/** Fold all models + manifest into the machine-readable `SystemBrief`. Deterministic: models
|
|
46
|
+
* are scanned in path order. */
|
|
47
|
+
export declare function buildSystemBrief(models: ModelSource[], app?: string): SystemBrief;
|
|
48
|
+
/** Emit the agent- and human-readable `system-brief.md` from the machine model. Compact by
|
|
49
|
+
* design (call graph + owners, not model XML) to keep the per-session prompt budget small
|
|
50
|
+
* (ADR 0060 §3 / open question 1). */
|
|
51
|
+
export declare function emitSystemBriefMd(b: SystemBrief): string;
|
|
52
|
+
/**
|
|
53
|
+
* Derive `nano-generated/system-brief.md` + `system-brief.json` from BPMN models (ADR 0060 §1).
|
|
54
|
+
* Pure and deterministic (path-ordered scan), so it is a drop-in drift-checkable artifact like
|
|
55
|
+
* its sibling derivers.
|
|
56
|
+
*/
|
|
57
|
+
export declare function deriveSystemBrief(models: ModelSource[], app?: string): DerivedArtifact[];
|
|
58
|
+
/** The `Deriver` binding, peer to `worker-io` / `meta`, for wiring into `gen.ts`. */
|
|
59
|
+
export declare const systemBriefDeriver: Deriver<{
|
|
60
|
+
models: ModelSource[];
|
|
61
|
+
app?: string;
|
|
62
|
+
}>;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Deriver: BPMN models + manifest → `system-brief.md` / `system-brief.json`, the app's
|
|
2
|
+
// *institutional-memory* brief (ADR 0060). Where `worker-io.ts` emits worker *types* and
|
|
3
|
+
// `meta.ts` emits a *typed accessor*, this deriver folds the SAME scanned structure into
|
|
4
|
+
// agent- and human-readable **system context**: the app's processes, its service-task call
|
|
5
|
+
// graph, the decisions it encodes, and the ownership / "why" carried on
|
|
6
|
+
// the model as reserved `nano:meta` keys. It reuses the sibling scanners (single parse rule
|
|
7
|
+
// per vocabulary) and is pure (models in, artifacts out) so `urban gen --check` keeps it
|
|
8
|
+
// honest — the brief can never rot the way a hand-written README does (ADR 0060 §1).
|
|
9
|
+
//
|
|
10
|
+
// Wired into `runGen` (gen.ts) as a standard artifact and served at runtime via `/app/agent`
|
|
11
|
+
// (agent.ts, ADR 0060 §2): the shape, scanners, fold, and both emitters are real and tested.
|
|
12
|
+
import { GENERATED_DIR } from "../artifact.js";
|
|
13
|
+
import { byModelPath, scanModelWorkers } from "./worker-io.js";
|
|
14
|
+
import { scanModelMeta } from "./meta.js";
|
|
15
|
+
/** Basenames of the two emitted artifacts. */
|
|
16
|
+
export const SYSTEM_BRIEF_MD = "system-brief.md";
|
|
17
|
+
export const SYSTEM_BRIEF_JSON = "system-brief.json";
|
|
18
|
+
function attr(tag, name) {
|
|
19
|
+
const m = tag.match(new RegExp(`\\b${name}\\s*=\\s*"([^"]*)"`));
|
|
20
|
+
return m ? m[1] : undefined;
|
|
21
|
+
}
|
|
22
|
+
function processId(xml) {
|
|
23
|
+
const m = xml.match(/<bpmn:process\b[^>]*>/);
|
|
24
|
+
return m ? attr(m[0], "id") : undefined;
|
|
25
|
+
}
|
|
26
|
+
/** Scan one BPMN document for `businessRuleTask` → `zeebe:calledDecision` decision refs, in
|
|
27
|
+
* document order, tagged with the enclosing process (mirrors `scanModelWorkers`' shape). */
|
|
28
|
+
export function scanModelDecisions(xml) {
|
|
29
|
+
const proc = processId(xml);
|
|
30
|
+
const out = [];
|
|
31
|
+
const blockRe = /<bpmn:businessRuleTask\b([^>]*)>([\s\S]*?)<\/bpmn:businessRuleTask>/g;
|
|
32
|
+
let m;
|
|
33
|
+
while ((m = blockRe.exec(xml)) !== null) {
|
|
34
|
+
const elementId = attr(`<x ${m[1]}>`, "id");
|
|
35
|
+
const cd = m[2].match(/<zeebe:calledDecision\b[^>]*>/);
|
|
36
|
+
if (!cd)
|
|
37
|
+
continue;
|
|
38
|
+
const decisionId = attr(cd[0], "decisionId");
|
|
39
|
+
if (!decisionId)
|
|
40
|
+
continue;
|
|
41
|
+
out.push({ process: proc, elementId, decisionId });
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
/** Reserved single-valued ownership keys → their `Ownership` field. */
|
|
46
|
+
const OWNERSHIP_KEYS = {
|
|
47
|
+
owner: "owner",
|
|
48
|
+
team: "team",
|
|
49
|
+
slack: "slack",
|
|
50
|
+
runbook: "runbook",
|
|
51
|
+
since: "since",
|
|
52
|
+
};
|
|
53
|
+
/** Fold the models' reserved `nano:meta` entries into `Ownership`. Single-valued keys take the
|
|
54
|
+
* last (scan-order) write, matching `foldMeta`; `adr` is multi-valued and accumulates. */
|
|
55
|
+
export function foldOwnership(models) {
|
|
56
|
+
const own = { adrs: [] };
|
|
57
|
+
for (const model of [...models].sort(byModelPath)) {
|
|
58
|
+
for (const { key, value } of scanModelMeta(model.xml)) {
|
|
59
|
+
const k = key.trim().toLowerCase();
|
|
60
|
+
if (k === "adr") {
|
|
61
|
+
if (value && !own.adrs.includes(value))
|
|
62
|
+
own.adrs.push(value);
|
|
63
|
+
}
|
|
64
|
+
else if (Object.hasOwn(OWNERSHIP_KEYS, k)) {
|
|
65
|
+
own[OWNERSHIP_KEYS[k]] = value ?? "";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return own;
|
|
70
|
+
}
|
|
71
|
+
/** Fold all models + manifest into the machine-readable `SystemBrief`. Deterministic: models
|
|
72
|
+
* are scanned in path order. */
|
|
73
|
+
export function buildSystemBrief(models, app) {
|
|
74
|
+
const sorted = [...models].sort(byModelPath);
|
|
75
|
+
const workers = [];
|
|
76
|
+
const decisions = [];
|
|
77
|
+
const processes = [];
|
|
78
|
+
for (const model of sorted) {
|
|
79
|
+
const proc = processId(model.xml);
|
|
80
|
+
if (proc && !processes.includes(proc))
|
|
81
|
+
processes.push(proc);
|
|
82
|
+
workers.push(...scanModelWorkers(model.xml));
|
|
83
|
+
decisions.push(...scanModelDecisions(model.xml));
|
|
84
|
+
}
|
|
85
|
+
return { app, processes, workers, decisions, ownership: foldOwnership(models) };
|
|
86
|
+
}
|
|
87
|
+
/** Escape a Markdown table cell: neutralise `|` and newlines, which would otherwise break the
|
|
88
|
+
* table. Ownership values come from model-authored `nano:meta`, so this both keeps rendering
|
|
89
|
+
* honest and blunts Markdown/prompt injection into the agent-facing brief. Backticks are left
|
|
90
|
+
* intact — the emitter deliberately wraps ids in code spans. */
|
|
91
|
+
function mdCell(s) {
|
|
92
|
+
return s.replace(/\|/g, "\\|").replace(/\r?\n/g, " ");
|
|
93
|
+
}
|
|
94
|
+
function mdTable(headers, rows) {
|
|
95
|
+
if (rows.length === 0)
|
|
96
|
+
return "_none_\n";
|
|
97
|
+
const head = `| ${headers.join(" | ")} |\n| ${headers.map(() => "---").join(" | ")} |\n`;
|
|
98
|
+
return head + rows.map((r) => `| ${r.map((c) => mdCell(c || "")).join(" | ")} |`).join("\n") + "\n";
|
|
99
|
+
}
|
|
100
|
+
/** Emit the agent- and human-readable `system-brief.md` from the machine model. Compact by
|
|
101
|
+
* design (call graph + owners, not model XML) to keep the per-session prompt budget small
|
|
102
|
+
* (ADR 0060 §3 / open question 1). */
|
|
103
|
+
export function emitSystemBriefMd(b) {
|
|
104
|
+
const o = b.ownership;
|
|
105
|
+
let m = `# ${b.app ?? "App"} — system brief\n\n`;
|
|
106
|
+
m += "_Auto-derived from the process models (ADR 0060). Do not edit — regenerated by " +
|
|
107
|
+
"`urban gen`; drift fails `urban gen --check`._\n\n";
|
|
108
|
+
m += "## Ownership\n\n";
|
|
109
|
+
const ownRows = [
|
|
110
|
+
["Owner", o.owner ?? ""],
|
|
111
|
+
["Team", o.team ?? ""],
|
|
112
|
+
["Slack", o.slack ?? ""],
|
|
113
|
+
["Runbook", o.runbook ?? ""],
|
|
114
|
+
["Since", o.since ?? ""],
|
|
115
|
+
["ADRs", o.adrs.join(", ")],
|
|
116
|
+
].filter((r) => r[1]);
|
|
117
|
+
m += ownRows.length ? mdTable(["Field", "Value"], ownRows) : "_No ownership metadata declared " +
|
|
118
|
+
"(add reserved `nano:meta` keys: owner, team, slack, runbook, adr, since)._\n";
|
|
119
|
+
m += "\n";
|
|
120
|
+
m += "## Processes\n\n";
|
|
121
|
+
m += b.processes.length ? b.processes.map((p) => `- \`${p}\``).join("\n") + "\n" : "_none_\n";
|
|
122
|
+
m += "\n";
|
|
123
|
+
m += "## Service-task call graph (dependency edges)\n\n";
|
|
124
|
+
m += mdTable(["Process", "Task type (dependency)", "In", "Out"], b.workers.map((w) => [
|
|
125
|
+
w.process ? `\`${w.process}\`` : "",
|
|
126
|
+
`\`${w.taskType}\``,
|
|
127
|
+
w.in ? `\`${w.in}\`` : "",
|
|
128
|
+
w.out ? `\`${w.out}\`` : "",
|
|
129
|
+
]));
|
|
130
|
+
m += "\n";
|
|
131
|
+
m += "## Decisions (DMN)\n\n";
|
|
132
|
+
m += mdTable(["Process", "Element", "Decision"], b.decisions.map((d) => [
|
|
133
|
+
d.process ? `\`${d.process}\`` : "",
|
|
134
|
+
d.elementId ? `\`${d.elementId}\`` : "",
|
|
135
|
+
`\`${d.decisionId}\``,
|
|
136
|
+
]));
|
|
137
|
+
return m;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Derive `nano-generated/system-brief.md` + `system-brief.json` from BPMN models (ADR 0060 §1).
|
|
141
|
+
* Pure and deterministic (path-ordered scan), so it is a drop-in drift-checkable artifact like
|
|
142
|
+
* its sibling derivers.
|
|
143
|
+
*/
|
|
144
|
+
export function deriveSystemBrief(models, app) {
|
|
145
|
+
const brief = buildSystemBrief(models, app);
|
|
146
|
+
return [
|
|
147
|
+
{ path: `${GENERATED_DIR}/${SYSTEM_BRIEF_MD}`, content: emitSystemBriefMd(brief) },
|
|
148
|
+
{ path: `${GENERATED_DIR}/${SYSTEM_BRIEF_JSON}`, content: JSON.stringify(brief, null, 2) + "\n" },
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
/** The `Deriver` binding, peer to `worker-io` / `meta`, for wiring into `gen.ts`. */
|
|
152
|
+
export const systemBriefDeriver = {
|
|
153
|
+
id: "system-brief",
|
|
154
|
+
describe: "App institutional-memory brief (processes, call graph, decisions, ownership) — ADR 0060",
|
|
155
|
+
derive: ({ models, app }) => deriveSystemBrief(models, app),
|
|
156
|
+
};
|
package/dist/toolkit/gen.d.ts
CHANGED
|
@@ -57,13 +57,13 @@ declare function dirOf(p: string): string;
|
|
|
57
57
|
/** Resolve a `dir/*.ext` (or literal) manifest pattern to file paths relative to root. */
|
|
58
58
|
export declare function expandPattern(root: string, io: GenIO, pattern: string): Promise<string[]>;
|
|
59
59
|
/** The deploy-by-convention directory (ADR 0062): when the manifest declares no `models`, both the
|
|
60
|
-
* runtime deploy and this codegen scan discover deployables/models under it —
|
|
61
|
-
*
|
|
60
|
+
* runtime deploy and this codegen scan discover deployables/models under it — **recursively**,
|
|
61
|
+
* every file at any depth (issue #231). Deploy-only by convention. */
|
|
62
62
|
export declare const RESOURCES_DIR = "resources";
|
|
63
63
|
/**
|
|
64
|
-
* Discover model files under `resources/` by convention —
|
|
65
|
-
*
|
|
66
|
-
* and the deploy see the same set. Returns root-relative paths, sorted. Descending
|
|
64
|
+
* Discover model files under `resources/` by convention — **recursively**, every `.bpmn`/`.dmn`
|
|
65
|
+
* under `resources/` at any depth (issue #231) — mirroring the runtime deploy walk so the codegen
|
|
66
|
+
* scan and the deploy see the same set. Returns root-relative paths, sorted. Descending needs
|
|
67
67
|
* `io.listSubdirs`; without it only the files directly under `resources/` are scanned.
|
|
68
68
|
*/
|
|
69
69
|
export declare function discoverResourceModels(root: string, io: GenIO): Promise<string[]>;
|
package/dist/toolkit/gen.js
CHANGED
|
@@ -10,6 +10,7 @@ import { deriveMeta } from "./derivers/meta.js";
|
|
|
10
10
|
import { deriveMessageBindings } from "./derivers/messages.js";
|
|
11
11
|
import { resolveShapes, scanModelShapes } from "./derivers/shapes.js";
|
|
12
12
|
import { deriveApi } from "./derivers/api.js";
|
|
13
|
+
import { deriveSystemBrief } from "./derivers/system-brief.js";
|
|
13
14
|
import { parseSpec, sharedRequestBodySchemas } from "../openapi/spec.js";
|
|
14
15
|
import { deriveModels, MODEL_PROVENANCE } from "./models.js";
|
|
15
16
|
function join(root, rel) {
|
|
@@ -47,31 +48,31 @@ export async function expandPattern(root, io, pattern) {
|
|
|
47
48
|
.sort();
|
|
48
49
|
}
|
|
49
50
|
/** The deploy-by-convention directory (ADR 0062): when the manifest declares no `models`, both the
|
|
50
|
-
* runtime deploy and this codegen scan discover deployables/models under it —
|
|
51
|
-
*
|
|
51
|
+
* runtime deploy and this codegen scan discover deployables/models under it — **recursively**,
|
|
52
|
+
* every file at any depth (issue #231). Deploy-only by convention. */
|
|
52
53
|
export const RESOURCES_DIR = "resources";
|
|
53
54
|
/** Model file extensions the `nano:shape`/code-first scan reads by convention (BPMN + DMN). */
|
|
54
55
|
const MODEL_EXTS = [".bpmn", ".dmn"];
|
|
55
56
|
/**
|
|
56
|
-
* Discover model files under `resources/` by convention —
|
|
57
|
-
*
|
|
58
|
-
* and the deploy see the same set. Returns root-relative paths, sorted. Descending
|
|
57
|
+
* Discover model files under `resources/` by convention — **recursively**, every `.bpmn`/`.dmn`
|
|
58
|
+
* under `resources/` at any depth (issue #231) — mirroring the runtime deploy walk so the codegen
|
|
59
|
+
* scan and the deploy see the same set. Returns root-relative paths, sorted. Descending needs
|
|
59
60
|
* `io.listSubdirs`; without it only the files directly under `resources/` are scanned.
|
|
60
61
|
*/
|
|
61
62
|
export async function discoverResourceModels(root, io) {
|
|
62
63
|
const isModel = (n) => MODEL_EXTS.some((e) => n.endsWith(e));
|
|
63
64
|
const out = [];
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
out.push(`${RESOURCES_DIR}/${n}`);
|
|
67
|
-
}
|
|
68
|
-
const subdirs = io.listSubdirs ? await io.listSubdirs(join(root, RESOURCES_DIR)) : [];
|
|
69
|
-
for (const sub of subdirs.slice().sort()) {
|
|
70
|
-
for (const n of await io.listDir(join(root, `${RESOURCES_DIR}/${sub}`))) {
|
|
65
|
+
const walk = async (rel) => {
|
|
66
|
+
for (const n of await io.listDir(join(root, rel))) {
|
|
71
67
|
if (isModel(n))
|
|
72
|
-
out.push(`${
|
|
68
|
+
out.push(`${rel}/${n}`);
|
|
73
69
|
}
|
|
74
|
-
|
|
70
|
+
const subdirs = io.listSubdirs ? await io.listSubdirs(join(root, rel)) : [];
|
|
71
|
+
for (const sub of subdirs.slice().sort()) {
|
|
72
|
+
await walk(`${rel}/${sub}`);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
await walk(RESOURCES_DIR);
|
|
75
76
|
return out.sort();
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
@@ -162,6 +163,11 @@ async function collectAll(opts) {
|
|
|
162
163
|
artifacts.push(...deriveWorkerBindings(models, declaredTypeIds));
|
|
163
164
|
artifacts.push(...deriveMeta(models));
|
|
164
165
|
artifacts.push(...deriveMessageBindings(models, declaredTypeIds));
|
|
166
|
+
// Institutional-memory brief (ADR 0060): fold the same scanned model structure into the
|
|
167
|
+
// app's agent/human-readable system brief. Flows through `artifacts` like its siblings, so
|
|
168
|
+
// the `nano-generated/` stale sweep and the `urban gen --check` drift gate own the two new
|
|
169
|
+
// artifacts (system-brief.md / .json) with no extra bookkeeping.
|
|
170
|
+
artifacts.push(...deriveSystemBrief(models, manifest.id));
|
|
165
171
|
// Surface genuine data-envelope conflicts: a taskType whose variants disagree on a field's
|
|
166
172
|
// TYPE. The emitted contract is the union of the variants (sound for a shared handler), so a
|
|
167
173
|
// type clash would silently widen to `A | B` — warn instead so the author unifies the envelope.
|
package/dist/toolkit/index.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export type { MetaDecl } from "./derivers/meta.ts";
|
|
|
14
14
|
export { deriveMessageBindings, emitMessageBindings, emitMessageBindingsRuntime, messagesDeriver, scanModelMessages, MESSAGE_BINDINGS_DTS, MESSAGE_BINDINGS_TS, } from "./derivers/messages.ts";
|
|
15
15
|
export type { MessageIo, MessageBindingDecl } from "./derivers/messages.ts";
|
|
16
16
|
export { apiDeriver, deriveApi, emitApiBindings, emitApiBindingsRuntime, emitApiController, schemaToTs, API_BINDINGS_DTS, API_BINDINGS_TS, API_CONTROLLER_TS, } from "./derivers/api.ts";
|
|
17
|
+
export { buildSystemBrief, deriveSystemBrief, emitSystemBriefMd, foldOwnership, scanModelDecisions, systemBriefDeriver, SYSTEM_BRIEF_JSON, SYSTEM_BRIEF_MD, } from "./derivers/system-brief.ts";
|
|
18
|
+
export type { DecisionRef, Ownership, SystemBrief } from "./derivers/system-brief.ts";
|
|
17
19
|
export { collectOperations, HTTP_METHODS, isSafeOperationId, operationsWithoutId, operationsWithUnsafeId, parseSpec, refName, resolveSchema, toRouteMatcher, undeclaredPathParams, validateValue, } from "../openapi/spec.ts";
|
|
18
20
|
export type { HttpMethodLower, OpenApiDoc, OpenApiParameter, OpenApiSchema, OperationInfo, } from "../openapi/spec.ts";
|
|
19
21
|
export declare const DERIVERS: readonly [import("./artifact.ts").Deriver<import("./derivers/migrations.ts").ToolkitManifest>, import("./artifact.ts").Deriver<import("./derivers/migrations.ts").ToolkitManifest>, import("./artifact.ts").Deriver<{
|
|
@@ -28,6 +30,9 @@ export declare const DERIVERS: readonly [import("./artifact.ts").Deriver<import(
|
|
|
28
30
|
doc: import("../openapi/spec.ts").OpenApiDoc;
|
|
29
31
|
operationsDir?: string;
|
|
30
32
|
surfaceEject?: boolean;
|
|
33
|
+
}>, import("./artifact.ts").Deriver<{
|
|
34
|
+
models: import("./derivers/worker-io.ts").ModelSource[];
|
|
35
|
+
app?: string;
|
|
31
36
|
}>];
|
|
32
37
|
export { collectArtifacts, runGen, joinPath, readModels, expandPattern, previewModels } from "./gen.ts";
|
|
33
38
|
export type { GenIO, GenOptions, GenResult } from "./gen.ts";
|
package/dist/toolkit/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { byModelPath, typeRefFor } from "./derivers/worker-io.js";
|
|
|
12
12
|
export { deriveMeta, emitMeta, foldMeta, metaDeriver, scanModelMeta, META_TS, } from "./derivers/meta.js";
|
|
13
13
|
export { deriveMessageBindings, emitMessageBindings, emitMessageBindingsRuntime, messagesDeriver, scanModelMessages, MESSAGE_BINDINGS_DTS, MESSAGE_BINDINGS_TS, } from "./derivers/messages.js";
|
|
14
14
|
export { apiDeriver, deriveApi, emitApiBindings, emitApiBindingsRuntime, emitApiController, schemaToTs, API_BINDINGS_DTS, API_BINDINGS_TS, API_CONTROLLER_TS, } from "./derivers/api.js";
|
|
15
|
+
export { buildSystemBrief, deriveSystemBrief, emitSystemBriefMd, foldOwnership, scanModelDecisions, systemBriefDeriver, SYSTEM_BRIEF_JSON, SYSTEM_BRIEF_MD, } from "./derivers/system-brief.js";
|
|
15
16
|
// The OpenAPI machinery the deriver + runtime share (ADR 0058).
|
|
16
17
|
export { collectOperations, HTTP_METHODS, isSafeOperationId, operationsWithoutId, operationsWithUnsafeId, parseSpec, refName, resolveSchema, toRouteMatcher, undeclaredPathParams, validateValue, } from "../openapi/spec.js";
|
|
17
18
|
// The registry of all derivers (for discovery / IDE migration).
|
|
@@ -21,6 +22,7 @@ import { workerIoDeriver } from "./derivers/worker-io.js";
|
|
|
21
22
|
import { metaDeriver } from "./derivers/meta.js";
|
|
22
23
|
import { messagesDeriver } from "./derivers/messages.js";
|
|
23
24
|
import { apiDeriver } from "./derivers/api.js";
|
|
25
|
+
import { systemBriefDeriver } from "./derivers/system-brief.js";
|
|
24
26
|
export const DERIVERS = [
|
|
25
27
|
migrationsDeriver,
|
|
26
28
|
domainDeriver,
|
|
@@ -28,6 +30,7 @@ export const DERIVERS = [
|
|
|
28
30
|
metaDeriver,
|
|
29
31
|
messagesDeriver,
|
|
30
32
|
apiDeriver,
|
|
33
|
+
systemBriefDeriver,
|
|
31
34
|
];
|
|
32
35
|
// Gen orchestrator + IO
|
|
33
36
|
export { collectArtifacts, runGen, joinPath, readModels, expandPattern, previewModels } from "./gen.js";
|
package/dist/toolkit/models.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ import type { ModelSource } from "./derivers/worker-io.ts";
|
|
|
5
5
|
/** Default source glob for code-first flows (matches the code-first scaffold layout). */
|
|
6
6
|
export declare const DEFAULT_WORKFLOW_PATTERNS: string[];
|
|
7
7
|
/** Default output dir for derived models when the manifest declares no `models.processes`: under
|
|
8
|
-
* the deploy-by-convention `resources/` tree (ADR 0062),
|
|
9
|
-
*
|
|
10
|
-
* `processesOutDir` derives the dir from that glob instead (the
|
|
8
|
+
* the deploy-by-convention `resources/` tree (ADR 0062), so a derived model lands where the
|
|
9
|
+
* convention deploy + codegen scan (which walk `resources/` recursively) look for it. When
|
|
10
|
+
* `models.processes` IS set, `processesOutDir` derives the dir from that glob instead (the
|
|
11
|
+
* model-first override). */
|
|
11
12
|
export declare const PROCESSES_DIR = "resources/processes";
|
|
12
13
|
/** Marker stamped into every derived `.bpmn` (an XML comment) so re-gen overwrites and the
|
|
13
14
|
* stale sweep deletes ONLY derived output — never an authored, human-owned model. */
|
package/dist/toolkit/models.js
CHANGED
|
@@ -14,9 +14,10 @@ import { isRecord } from "../runtime/core/guards.js";
|
|
|
14
14
|
/** Default source glob for code-first flows (matches the code-first scaffold layout). */
|
|
15
15
|
export const DEFAULT_WORKFLOW_PATTERNS = ["workflows/*.ts"];
|
|
16
16
|
/** Default output dir for derived models when the manifest declares no `models.processes`: under
|
|
17
|
-
* the deploy-by-convention `resources/` tree (ADR 0062),
|
|
18
|
-
*
|
|
19
|
-
* `processesOutDir` derives the dir from that glob instead (the
|
|
17
|
+
* the deploy-by-convention `resources/` tree (ADR 0062), so a derived model lands where the
|
|
18
|
+
* convention deploy + codegen scan (which walk `resources/` recursively) look for it. When
|
|
19
|
+
* `models.processes` IS set, `processesOutDir` derives the dir from that glob instead (the
|
|
20
|
+
* model-first override). */
|
|
20
21
|
export const PROCESSES_DIR = "resources/processes";
|
|
21
22
|
/** Marker stamped into every derived `.bpmn` (an XML comment) so re-gen overwrites and the
|
|
22
23
|
* stale sweep deletes ONLY derived output — never an authored, human-owned model. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nanobpm/urban",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.0",
|
|
4
4
|
"description": "Urban: build and run code-first apps on Nano — runtime, derivation toolkit, and CLI in one. Author durable processes with @nanobpm/workflow (defineFlow), a typed datasource, forms, triggers and surfaces from a nano.app.json manifest, on Node or Deno.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|