@sun-asterisk/sungen 3.1.2-beta.117 → 3.1.2-beta.118

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.
@@ -0,0 +1,9 @@
1
+ import { Command } from 'commander';
2
+ /**
3
+ * `sungen context` — run the Discover → Contextualize phase (AO-3) for a unit and emit the
4
+ * normalized Context + generation-unit work-list. The `/sungen:design` loop calls this first so it
5
+ * knows WHAT to generate (the endpoints/screens + their modes) before authoring scenarios. Pure +
6
+ * deterministic; writes `.sungen/reports/<unit>-context.json`.
7
+ */
8
+ export declare function registerContextCommand(program: Command): void;
9
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuC7D"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.registerContextCommand = registerContextCommand;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const context_discovery_1 = require("../../orchestrator/context-discovery");
40
+ /**
41
+ * `sungen context` — run the Discover → Contextualize phase (AO-3) for a unit and emit the
42
+ * normalized Context + generation-unit work-list. The `/sungen:design` loop calls this first so it
43
+ * knows WHAT to generate (the endpoints/screens + their modes) before authoring scenarios. Pure +
44
+ * deterministic; writes `.sungen/reports/<unit>-context.json`.
45
+ */
46
+ function registerContextCommand(program) {
47
+ program
48
+ .command('context')
49
+ .description('Discover + contextualize a unit (screen/flow/api area) → Context + generation units')
50
+ .option('-s, --screen <name>', 'Screen name')
51
+ .option('--flow <name>', 'Flow name (resolved as flows/<name>)')
52
+ .option('--api <name>', 'API-first area or api flow (resolved as api/<name>)')
53
+ .option('--json', 'Print the raw JSON')
54
+ .action(async (o) => {
55
+ try {
56
+ const unitId = o.api ? `api/${o.api}` : o.flow ? `flows/${o.flow}` : o.screen;
57
+ if (!unitId)
58
+ throw new Error('Provide --screen <name>, --flow <name>, or --api <area>.');
59
+ const cwd = process.cwd();
60
+ const result = await (0, context_discovery_1.discoverUnitContext)(unitId, cwd);
61
+ const outDir = path.join(cwd, '.sungen', 'reports');
62
+ fs.mkdirSync(outDir, { recursive: true });
63
+ const slug = unitId.replace(/\//g, '-');
64
+ const outPath = path.join(outDir, `${slug}-context.json`);
65
+ fs.writeFileSync(outPath, JSON.stringify(result, null, 2), 'utf-8');
66
+ if (o.json) {
67
+ console.log(JSON.stringify(result, null, 2));
68
+ return;
69
+ }
70
+ const L = console.log;
71
+ const facts = result.context.facts;
72
+ L(`\n━━━ Context: ${unitId} (capability: ${result.capability}) ━━━`);
73
+ const srcKeys = Object.keys(result.context.sources);
74
+ L(` Sources: ${srcKeys.length ? srcKeys.join(', ') : '(none)'}`);
75
+ if (facts.endpoints?.length) {
76
+ L(` Endpoints (${facts.endpoints.length}):`);
77
+ for (const e of facts.endpoints)
78
+ L(` • ${e.method} ${e.path} (@api:${e.name})`);
79
+ }
80
+ const byMode = result.units.reduce((m, u) => { m[u.mode] = (m[u.mode] || 0) + 1; return m; }, {});
81
+ L(` Generation units: ${result.units.length} — ${Object.entries(byMode).map(([m, n]) => `${m}×${n}`).join(' · ') || '(none)'}`);
82
+ L(`\n Report: ${path.relative(cwd, outPath)}\n`);
83
+ }
84
+ catch (e) {
85
+ console.error('Error:', e instanceof Error ? e.message : e);
86
+ process.exit(1);
87
+ }
88
+ });
89
+ }
90
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/cli/commands/context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,wDAuCC;AAjDD,uCAAyB;AACzB,2CAA6B;AAC7B,4EAA2E;AAE3E;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,OAAgB;IACrD,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,qFAAqF,CAAC;SAClG,MAAM,CAAC,qBAAqB,EAAE,aAAa,CAAC;SAC5C,MAAM,CAAC,eAAe,EAAE,sCAAsC,CAAC;SAC/D,MAAM,CAAC,cAAc,EAAE,qDAAqD,CAAC;SAC7E,MAAM,CAAC,QAAQ,EAAE,oBAAoB,CAAC;SACtC,MAAM,CAAC,KAAK,EAAE,CAAmE,EAAE,EAAE;QACpF,IAAI,CAAC;YACH,MAAM,MAAM,GA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OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
package/dist/cli/index.js CHANGED
@@ -27,6 +27,7 @@ const challenge_1 = require("./commands/challenge");
27
27
  const blindspot_1 = require("./commands/blindspot");
28
28
  const capability_1 = require("./commands/capability");
29
29
  const flow_check_1 = require("./commands/flow-check");
30
+ const context_1 = require("./commands/context");
30
31
  const registry_1 = require("../capabilities/registry");
31
32
  const discover_1 = require("../capabilities/discover");
32
33
  // Read version from package.json so `--version` never drifts from the released version.
@@ -60,6 +61,7 @@ async function main() {
60
61
  (0, blindspot_1.registerBlindspotCommand)(program);
61
62
  (0, capability_1.registerCapabilityCommand)(program);
62
63
  (0, flow_check_1.registerFlowCheckCommand)(program);
64
+ (0, context_1.registerContextCommand)(program);
63
65
  (0, ingest_1.registerIngestCommand)(program);
64
66
  (0, eval_1.registerEvalCommand)(program);
65
67
  // Capability-contributed CLI commands (Capability SPI): drivers own their authoring commands
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;AACA;;;GAGG;;AAEH,yCAAoC;AACpC,0CAAsD;AACtD,wCAAoD;AACpD,kDAA8D;AAC9D,kDAA8D;AAC9D,8CAA0D;AAC1D,kDAA8D;AAC9D,4CAAwD;AACxD,kDAA6D;AAC7D,oDAAgE;AAChE,4CAAwD;AACxD,8CAA0D;AAC1D,0CAAsD;AACtD,kDAA8D;AAC9D,8CAA0D;AAC1D,kDAA8D;AAC9D,0DAAqE;AACrE,4CAAwD;AACxD,oDAAgE;AAChE,oDAAgE;AAChE,sDAAkE;AAClE,sDAAiE;AACjE,uDAA8D;AAC9D,uDAA2E;AAE3E,wFAAwF;AAC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AAG,IAAI,6BAAkB,CAAC,GAAG,EAAE,EAAE,CAAC;QAC3C,KAAK,MAAM,eAAe,IAAI,GAAG,CAAC,WAAW,IAAI,EAAE;YAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAChF,CAAC;IAED,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -7,6 +7,8 @@ export { capabilityRegistry, CapabilityRegistry } from './capabilities/registry'
7
7
  export type { CapabilityDescriptor } from './capabilities/registry';
8
8
  export type { Sensor, SensorFinding, AdvisoryScanInput, GateInput } from './capabilities/sensor';
9
9
  export type { Context, DiscoveryProvider, ContextMapper, GenerationUnit } from './capabilities/context';
10
+ export { discoverUnitContext } from './orchestrator/context-discovery';
11
+ export type { DiscoveredContext } from './orchestrator/context-discovery';
10
12
  export type { PatternContext, StepPattern, StepTemplateData } from './generators/test-generator/patterns/types';
11
13
  export type { MappedStep } from './generators/test-generator/step-mapper';
12
14
  export type { ParsedStep } from './generators/gherkin-parser';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACjF,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACjG,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,MAA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,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAChH,YAAY,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,YAAY,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AAGhH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAClF,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAI1D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAChI,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -5,11 +5,13 @@
5
5
  * imports from a driver (discovery loads them at runtime). Keep this surface small and intentional.
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.depthWarnOnly = exports.depthThresholdFor = exports.dataThemesFor = exports.assertionDepth = exports.viewpointGate = exports.loadCatalog = exports.lintCatalog = exports.compileQuery = exports.resolveQuery = exports.parseQueryOverrides = exports.resolvePathVariables = exports.inferPath = exports.getPathCode = exports.CapabilityRegistry = exports.capabilityRegistry = void 0;
8
+ exports.depthWarnOnly = exports.depthThresholdFor = exports.dataThemesFor = exports.assertionDepth = exports.viewpointGate = exports.loadCatalog = exports.lintCatalog = exports.compileQuery = exports.resolveQuery = exports.parseQueryOverrides = exports.resolvePathVariables = exports.inferPath = exports.getPathCode = exports.discoverUnitContext = exports.CapabilityRegistry = exports.capabilityRegistry = void 0;
9
9
  // --- Capability SPI ---
10
10
  var registry_1 = require("./capabilities/registry");
11
11
  Object.defineProperty(exports, "capabilityRegistry", { enumerable: true, get: function () { return registry_1.capabilityRegistry; } });
12
12
  Object.defineProperty(exports, "CapabilityRegistry", { enumerable: true, get: function () { return registry_1.CapabilityRegistry; } });
13
+ var context_discovery_1 = require("./orchestrator/context-discovery");
14
+ Object.defineProperty(exports, "discoverUnitContext", { enumerable: true, get: function () { return context_discovery_1.discoverUnitContext; } });
13
15
  var path_inference_1 = require("./generators/test-generator/utils/path-inference");
14
16
  Object.defineProperty(exports, "getPathCode", { enumerable: true, get: function () { return path_inference_1.getPathCode; } });
15
17
  Object.defineProperty(exports, "inferPath", { enumerable: true, get: function () { return path_inference_1.inferPath; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,yBAAyB;AACzB,oDAAiF;AAAxE,8GAAA,kBAAkB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AAS/C,mFAAgH;AAAvG,6GAAA,WAAW,OAAA;AAAE,2GAAA,SAAS,OAAA;AAAE,sHAAA,oBAAoB,OAAA;AAErD,gGAAgG;AAChG,uEAAqE;AAA5D,2HAAA,mBAAmB,OAAA;AAE5B,mGAAmG;AACnG,yDAAkF;AAAzE,6GAAA,YAAY,OAAA;AAAE,6GAAA,YAAY,OAAA;AAAE,4GAAA,WAAW,OAAA;AAGhD,8EAA8E;AAC9E,mGAAmG;AACnG,6CAAgI;AAAvH,sGAAA,WAAW,OAAA;AAAE,wGAAA,aAAa,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,wGAAA,aAAa,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AAAE,wGAAA,aAAa,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,yBAAyB;AACzB,oDAAiF;AAAxE,8GAAA,kBAAkB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AAI/C,sEAAuE;AAA9D,wHAAA,mBAAmB,OAAA;AAO5B,mFAAgH;AAAvG,6GAAA,WAAW,OAAA;AAAE,2GAAA,SAAS,OAAA;AAAE,sHAAA,oBAAoB,OAAA;AAErD,gGAAgG;AAChG,uEAAqE;AAA5D,2HAAA,mBAAmB,OAAA;AAE5B,mGAAmG;AACnG,yDAAkF;AAAzE,6GAAA,YAAY,OAAA;AAAE,6GAAA,YAAY,OAAA;AAAE,4GAAA,WAAW,OAAA;AAGhD,8EAA8E;AAC9E,mGAAmG;AACnG,6CAAgI;AAAvH,sGAAA,WAAW,OAAA;AAAE,wGAAA,aAAa,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,wGAAA,aAAa,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AAAE,wGAAA,aAAa,OAAA"}
@@ -0,0 +1,12 @@
1
+ import type { Context, GenerationUnit } from '../capabilities/context';
2
+ export interface DiscoveredContext {
3
+ capability: string;
4
+ context: Context;
5
+ units: GenerationUnit[];
6
+ }
7
+ /**
8
+ * Run the Discover → Contextualize phase for a unit. `unitId` is the catalog-resolution id
9
+ * (`<screen>` · `flows/<flow>` · `api/<area>` · `api/flows/<flow>`).
10
+ */
11
+ export declare function discoverUnitContext(unitId: string, cwd?: string): Promise<DiscoveredContext>;
12
+ //# sourceMappingURL=context-discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-discovery.d.ts","sourceRoot":"","sources":["../../src/orchestrator/context-discovery.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEvE,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AASD;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAmBjH"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.discoverUnitContext = discoverUnitContext;
4
+ /**
5
+ * Orchestration phase: Discover → Contextualize (AO-3).
6
+ *
7
+ * The capability SPI declared `discovery` (sources → Context slice) + `contextMapper` (Context →
8
+ * generation units) since R1, but nothing consumed them. This is the deterministic consumer the
9
+ * orchestration loop (`/sungen:design`) calls before generating: resolve the unit's capability,
10
+ * run ITS discovery + contextMapper, and hand back the normalized Context + the generation-unit
11
+ * work-list. Capability-agnostic — a screen, an api area, or a future `mobile/` unit all flow here.
12
+ */
13
+ const registry_1 = require("../capabilities/registry");
14
+ const discover_1 = require("../capabilities/discover");
15
+ /** Map a unit id (relative to qa/) to a discovery target. */
16
+ function targetForUnit(unitId) {
17
+ if (unitId.startsWith('api/'))
18
+ return { kind: 'api', id: unitId };
19
+ if (unitId.startsWith('flows/'))
20
+ return { kind: 'flow', id: unitId };
21
+ return { kind: 'screen', id: unitId };
22
+ }
23
+ /**
24
+ * Run the Discover → Contextualize phase for a unit. `unitId` is the catalog-resolution id
25
+ * (`<screen>` · `flows/<flow>` · `api/<area>` · `api/flows/<flow>`).
26
+ */
27
+ async function discoverUnitContext(unitId, cwd = process.cwd()) {
28
+ (0, discover_1.discoverAndRegisterCapabilities)();
29
+ const target = targetForUnit(unitId);
30
+ // The discovering capability is the first whose DiscoveryProvider claims the target; else the default.
31
+ const cap = registry_1.capabilityRegistry.all().find((c) => c.discovery?.appliesTo?.(target))
32
+ ?? (registry_1.capabilityRegistry.defaultCapabilityId() ? registry_1.capabilityRegistry.get(registry_1.capabilityRegistry.defaultCapabilityId()) : undefined);
33
+ let context = { target: { ...target, capability: cap?.id }, sources: {}, facts: {} };
34
+ if (cap?.discovery) {
35
+ const slice = await cap.discovery.discover(target, { cwd });
36
+ context = {
37
+ target: { ...target, capability: cap.id },
38
+ sources: { ...context.sources, ...(slice.sources ?? {}) },
39
+ facts: { ...context.facts, ...(slice.facts ?? {}) },
40
+ ...(slice.connectivity ? { connectivity: slice.connectivity } : {}),
41
+ };
42
+ }
43
+ const units = cap?.contextMapper?.decompose(context) ?? [];
44
+ return { capability: cap?.id ?? 'ui', context, units };
45
+ }
46
+ //# sourceMappingURL=context-discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-discovery.js","sourceRoot":"","sources":["../../src/orchestrator/context-discovery.ts"],"names":[],"mappings":";;AA8BA,kDAmBC;AAjDD;;;;;;;;GAQG;AACH,uDAA8D;AAC9D,uDAA2E;AAS3E,6DAA6D;AAC7D,SAAS,aAAa,CAAC,MAAc;IACnC,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;IAClE,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;IACrE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,mBAAmB,CAAC,MAAc,EAAE,MAAc,OAAO,CAAC,GAAG,EAAE;IACnF,IAAA,0CAA+B,GAAE,CAAC;IAClC,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC,uGAAuG;IACvG,MAAM,GAAG,GAAG,6BAAkB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC;WAC7E,CAAC,6BAAkB,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,6BAAkB,CAAC,GAAG,CAAC,6BAAkB,CAAC,mBAAmB,EAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAEhI,IAAI,OAAO,GAAY,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC9F,IAAI,GAAG,EAAE,SAAS,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QAC5D,OAAO,GAAG;YACR,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,EAAE;YACzC,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE;YACzD,KAAK,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE;YACnD,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpE,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,EAAE,aAAa,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC3D,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,IAAI,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACzD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sun-asterisk/sungen",
3
- "version": "3.1.2-beta.117",
3
+ "version": "3.1.2-beta.118",
4
4
  "description": "Deterministic E2E Test Compiler - Gherkin + Selectors → Playwright tests",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -33,7 +33,7 @@
33
33
  "node": ">=18.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "@sungen/driver-ui": "3.1.2-beta.117",
36
+ "@sungen/driver-ui": "3.1.2-beta.118",
37
37
  "@anthropic-ai/sdk": "^0.71.0",
38
38
  "@babel/parser": "^7.28.5",
39
39
  "@babel/traverse": "^7.28.5",
@@ -0,0 +1,51 @@
1
+ import { Command } from 'commander';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ import { discoverUnitContext } from '../../orchestrator/context-discovery';
5
+
6
+ /**
7
+ * `sungen context` — run the Discover → Contextualize phase (AO-3) for a unit and emit the
8
+ * normalized Context + generation-unit work-list. The `/sungen:design` loop calls this first so it
9
+ * knows WHAT to generate (the endpoints/screens + their modes) before authoring scenarios. Pure +
10
+ * deterministic; writes `.sungen/reports/<unit>-context.json`.
11
+ */
12
+ export function registerContextCommand(program: Command): void {
13
+ program
14
+ .command('context')
15
+ .description('Discover + contextualize a unit (screen/flow/api area) → Context + generation units')
16
+ .option('-s, --screen <name>', 'Screen name')
17
+ .option('--flow <name>', 'Flow name (resolved as flows/<name>)')
18
+ .option('--api <name>', 'API-first area or api flow (resolved as api/<name>)')
19
+ .option('--json', 'Print the raw JSON')
20
+ .action(async (o: { screen?: string; flow?: string; api?: string; json?: boolean }) => {
21
+ try {
22
+ const unitId = o.api ? `api/${o.api}` : o.flow ? `flows/${o.flow}` : o.screen;
23
+ if (!unitId) throw new Error('Provide --screen <name>, --flow <name>, or --api <area>.');
24
+ const cwd = process.cwd();
25
+ const result = await discoverUnitContext(unitId, cwd);
26
+
27
+ const outDir = path.join(cwd, '.sungen', 'reports');
28
+ fs.mkdirSync(outDir, { recursive: true });
29
+ const slug = unitId.replace(/\//g, '-');
30
+ const outPath = path.join(outDir, `${slug}-context.json`);
31
+ fs.writeFileSync(outPath, JSON.stringify(result, null, 2), 'utf-8');
32
+ if (o.json) { console.log(JSON.stringify(result, null, 2)); return; }
33
+
34
+ const L = console.log;
35
+ const facts = result.context.facts as { endpoints?: Array<{ name: string; method: string; path: string }> };
36
+ L(`\n━━━ Context: ${unitId} (capability: ${result.capability}) ━━━`);
37
+ const srcKeys = Object.keys(result.context.sources);
38
+ L(` Sources: ${srcKeys.length ? srcKeys.join(', ') : '(none)'}`);
39
+ if (facts.endpoints?.length) {
40
+ L(` Endpoints (${facts.endpoints.length}):`);
41
+ for (const e of facts.endpoints) L(` • ${e.method} ${e.path} (@api:${e.name})`);
42
+ }
43
+ const byMode = result.units.reduce<Record<string, number>>((m, u) => { m[u.mode] = (m[u.mode] || 0) + 1; return m; }, {});
44
+ L(` Generation units: ${result.units.length} — ${Object.entries(byMode).map(([m, n]) => `${m}×${n}`).join(' · ') || '(none)'}`);
45
+ L(`\n Report: ${path.relative(cwd, outPath)}\n`);
46
+ } catch (e) {
47
+ console.error('Error:', e instanceof Error ? e.message : e);
48
+ process.exit(1);
49
+ }
50
+ });
51
+ }
package/src/cli/index.ts CHANGED
@@ -26,6 +26,7 @@ import { registerChallengeCommand } from './commands/challenge';
26
26
  import { registerBlindspotCommand } from './commands/blindspot';
27
27
  import { registerCapabilityCommand } from './commands/capability';
28
28
  import { registerFlowCheckCommand } from './commands/flow-check';
29
+ import { registerContextCommand } from './commands/context';
29
30
  import { capabilityRegistry } from '../capabilities/registry';
30
31
  import { discoverAndRegisterCapabilities } from '../capabilities/discover';
31
32
 
@@ -64,6 +65,7 @@ async function main() {
64
65
  registerBlindspotCommand(program);
65
66
  registerCapabilityCommand(program);
66
67
  registerFlowCheckCommand(program);
68
+ registerContextCommand(program);
67
69
  registerIngestCommand(program);
68
70
  registerEvalCommand(program);
69
71
 
package/src/index.ts CHANGED
@@ -9,6 +9,8 @@ export { capabilityRegistry, CapabilityRegistry } from './capabilities/registry'
9
9
  export type { CapabilityDescriptor } from './capabilities/registry';
10
10
  export type { Sensor, SensorFinding, AdvisoryScanInput, GateInput } from './capabilities/sensor';
11
11
  export type { Context, DiscoveryProvider, ContextMapper, GenerationUnit } from './capabilities/context';
12
+ export { discoverUnitContext } from './orchestrator/context-discovery';
13
+ export type { DiscoveredContext } from './orchestrator/context-discovery';
12
14
 
13
15
  // --- Step-pattern authoring (a driver contributes step patterns via its descriptor) ---
14
16
  export type { PatternContext, StepPattern, StepTemplateData } from './generators/test-generator/patterns/types';
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Orchestration phase: Discover → Contextualize (AO-3).
3
+ *
4
+ * The capability SPI declared `discovery` (sources → Context slice) + `contextMapper` (Context →
5
+ * generation units) since R1, but nothing consumed them. This is the deterministic consumer the
6
+ * orchestration loop (`/sungen:design`) calls before generating: resolve the unit's capability,
7
+ * run ITS discovery + contextMapper, and hand back the normalized Context + the generation-unit
8
+ * work-list. Capability-agnostic — a screen, an api area, or a future `mobile/` unit all flow here.
9
+ */
10
+ import { capabilityRegistry } from '../capabilities/registry';
11
+ import { discoverAndRegisterCapabilities } from '../capabilities/discover';
12
+ import type { Context, GenerationUnit } from '../capabilities/context';
13
+
14
+ export interface DiscoveredContext {
15
+ capability: string;
16
+ context: Context;
17
+ units: GenerationUnit[];
18
+ }
19
+
20
+ /** Map a unit id (relative to qa/) to a discovery target. */
21
+ function targetForUnit(unitId: string): Context['target'] {
22
+ if (unitId.startsWith('api/')) return { kind: 'api', id: unitId };
23
+ if (unitId.startsWith('flows/')) return { kind: 'flow', id: unitId };
24
+ return { kind: 'screen', id: unitId };
25
+ }
26
+
27
+ /**
28
+ * Run the Discover → Contextualize phase for a unit. `unitId` is the catalog-resolution id
29
+ * (`<screen>` · `flows/<flow>` · `api/<area>` · `api/flows/<flow>`).
30
+ */
31
+ export async function discoverUnitContext(unitId: string, cwd: string = process.cwd()): Promise<DiscoveredContext> {
32
+ discoverAndRegisterCapabilities();
33
+ const target = targetForUnit(unitId);
34
+ // The discovering capability is the first whose DiscoveryProvider claims the target; else the default.
35
+ const cap = capabilityRegistry.all().find((c) => c.discovery?.appliesTo?.(target))
36
+ ?? (capabilityRegistry.defaultCapabilityId() ? capabilityRegistry.get(capabilityRegistry.defaultCapabilityId()!) : undefined);
37
+
38
+ let context: Context = { target: { ...target, capability: cap?.id }, sources: {}, facts: {} };
39
+ if (cap?.discovery) {
40
+ const slice = await cap.discovery.discover(target, { cwd });
41
+ context = {
42
+ target: { ...target, capability: cap.id },
43
+ sources: { ...context.sources, ...(slice.sources ?? {}) },
44
+ facts: { ...context.facts, ...(slice.facts ?? {}) },
45
+ ...(slice.connectivity ? { connectivity: slice.connectivity } : {}),
46
+ };
47
+ }
48
+ const units = cap?.contextMapper?.decompose(context) ?? [];
49
+ return { capability: cap?.id ?? 'ui', context, units };
50
+ }