@useorgx/wizard 0.1.55 → 0.1.56

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 CHANGED
@@ -32,6 +32,7 @@ The wizard modifies local tool configuration only. Depending on the command, it
32
32
  - Every profile or preview writes both the full evidence report and a compact, machine-safe `work-graph-agent-brief-*.md` with provenance, the growth edge, and a ready prompt for the smallest verifiable repair.
33
33
  - `work-graph preview --from all` shows the same profile story locally without publishing.
34
34
  - `work-graph runtime-event --source codex|claude --summary "..."` lets an agent write public-safe runtime evidence that the next AQ profile can collect.
35
+ - `map [query...] --deep-search` runs the v1 Operating Map discovery flow over connected company signals and cited deep research, prints source health and low-confidence ProcessCards, and keeps ownership/timing/"done" confirmation human-gated. Add `--candidate <id-or-number> --yes` to explicitly propose one card as an OperatingProcess; the wizard never auto-confirms or activates inferred workflow ownership.
35
36
  - `surface list` shows supported surfaces and current status.
36
37
  - `surface add <name>` patches a specific surface.
37
38
  - `surface remove <name>` removes OrgX-managed config from a specific surface.
@@ -88,6 +89,7 @@ Set `ORGX_TELEMETRY_DISABLED=1` or `ORGX_TELEMETRY_ENABLED=0` to opt out.
88
89
  - Repeated setup runs are intentionally quiet. Daily Brief can be configured with defaults, customized, or skipped; skips for Daily Brief, first initiative creation, onboarding task creation, agent roster setup, and the first intent prompt are remembered per workspace so the wizard does not ask again on every run.
89
90
  - After the first initiative is ready, setup prints the `/live/<initiative>` URL and a copyable prompt for the user's configured AI tool: continue the initiative, show the next action, and start with the onboarding task.
90
91
  - The AQ loop is: run profile, claim the public Work Graph, start the selected repair quest in OrgX, attach proof, rerun the profile, and compare the AQ delta.
92
+ - The Operating Map loop is: `wizard map --deep-search "Map the intake, handoffs, systems of record, and completion criteria"`, inspect citations/source health/limitations, propose only a reviewed ProcessCard, confirm it in OrgX, then use the resulting OperatingProcess as the source for adoption and ValueCase projections. A cited report without a schema-valid candidate block remains observation-only.
91
93
  - `wizard workspace current` reads the current OrgX workspace from `GET /api/v1/workspaces/current`, with a fallback to workspace listing if that route is unavailable.
92
94
  - `wizard workspace list` lists all accessible workspaces.
93
95
  - `wizard workspace create "Founders" --description "Initial OrgX workspace"` creates a new workspace through `POST /api/entities`.
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/cli.ts
4
4
 
5
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="707a7fe5-404e-5aec-9c75-30f0f5d859d9")}catch(e){}}();
5
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="02842523-d681-5cea-96aa-0f0c896e9fb5")}catch(e){}}();
6
6
  import * as clack from "@clack/prompts";
7
7
  import { spawnSync as spawnSync5 } from "child_process";
8
8
  import { readFileSync as readFileSync8 } from "fs";
@@ -6211,7 +6211,7 @@ function initializeWizardSentry() {
6211
6211
  Sentry.init({
6212
6212
  dsn,
6213
6213
  environment: process.env.ORGX_SENTRY_ENVIRONMENT || "production",
6214
- release: "useorgx-wizard@0.1.55",
6214
+ release: "useorgx-wizard@0.1.56",
6215
6215
  tracesSampleRate: sampleRate(process.env.ORGX_SENTRY_TRACES_SAMPLE_RATE),
6216
6216
  enableLogs: true,
6217
6217
  sendDefaultPii: false,
@@ -8592,11 +8592,138 @@ Rollback: ${plan.recommended_follow_up.rollback}`,
8592
8592
  );
8593
8593
  }
8594
8594
 
8595
+ // src/lib/operating-map.ts
8596
+ import { createHash as createHash6 } from "crypto";
8597
+ function parseResponseBody6(text2) {
8598
+ if (!text2) return null;
8599
+ try {
8600
+ return JSON.parse(text2);
8601
+ } catch {
8602
+ return text2;
8603
+ }
8604
+ }
8605
+ function formatHttpError5(status, body) {
8606
+ if (typeof body === "string" && body.trim()) return `HTTP ${status}: ${body}`;
8607
+ if (isRecord(body) && isRecord(body.error)) {
8608
+ const code = typeof body.error.code === "string" ? body.error.code : "api_error";
8609
+ const message = typeof body.error.message === "string" ? body.error.message : `HTTP ${status}`;
8610
+ return `HTTP ${status} ${code}: ${message}`;
8611
+ }
8612
+ return `HTTP ${status}`;
8613
+ }
8614
+ function extractData(payload) {
8615
+ return isRecord(payload) && "data" in payload ? payload.data : payload;
8616
+ }
8617
+ function parseDiscoveryResult(payload) {
8618
+ const data = extractData(payload);
8619
+ if (!isRecord(data) || !isRecord(data.run) || !Array.isArray(data.processCards)) {
8620
+ throw new Error("OrgX returned an incomplete operating-map discovery payload.");
8621
+ }
8622
+ const run = data.run;
8623
+ if (typeof run.id !== "string" || typeof run.mode !== "string" || typeof run.status !== "string") {
8624
+ throw new Error("OrgX returned an invalid operating-map discovery run.");
8625
+ }
8626
+ return {
8627
+ run: {
8628
+ id: run.id,
8629
+ mode: run.mode,
8630
+ status: run.status,
8631
+ query: typeof run.query === "string" ? run.query : null,
8632
+ observationCount: typeof run.observationCount === "number" ? run.observationCount : 0,
8633
+ candidateProcessCardCount: typeof run.candidateProcessCardCount === "number" ? run.candidateProcessCardCount : data.processCards.length,
8634
+ citationCount: typeof run.citationCount === "number" ? run.citationCount : 0,
8635
+ sourceHealth: Array.isArray(run.sourceHealth) ? run.sourceHealth : [],
8636
+ limitations: Array.isArray(run.limitations) ? run.limitations.filter((item) => typeof item === "string") : []
8637
+ },
8638
+ observations: Array.isArray(data.observations) ? data.observations.filter(isRecord) : [],
8639
+ processCards: data.processCards.filter(isRecord).map((card) => {
8640
+ const ref = isRecord(card.processCandidateRef) ? card.processCandidateRef : {};
8641
+ return {
8642
+ processCandidateRef: {
8643
+ id: typeof ref.id === "string" ? ref.id : "",
8644
+ workspaceId: typeof ref.workspaceId === "string" ? ref.workspaceId : ""
8645
+ },
8646
+ displayName: typeof card.displayName === "string" ? card.displayName : "Unnamed workflow",
8647
+ confidence: typeof card.confidence === "number" ? card.confidence : 0,
8648
+ nextConfirmationQuestion: typeof card.nextConfirmationQuestion === "string" ? card.nextConfirmationQuestion : null,
8649
+ candidateTrigger: isRecord(card.candidateTrigger) ? card.candidateTrigger : {},
8650
+ handoffDelays: Array.isArray(card.handoffDelays) ? card.handoffDelays.filter(isRecord).map((handoff) => ({
8651
+ from: typeof handoff.from === "string" ? handoff.from : "unknown",
8652
+ to: typeof handoff.to === "string" ? handoff.to : "unknown",
8653
+ delayMinutes: typeof handoff.delayMinutes === "number" ? handoff.delayMinutes : null
8654
+ })) : [],
8655
+ riskFlags: Array.isArray(card.riskFlags) ? card.riskFlags.filter((item) => typeof item === "string") : []
8656
+ };
8657
+ }),
8658
+ confirmedProcessRefs: Array.isArray(data.confirmedProcessRefs) ? data.confirmedProcessRefs.filter(isRecord).flatMap(
8659
+ (ref) => typeof ref.id === "string" && typeof ref.workspaceId === "string" ? [{ id: ref.id, workspaceId: ref.workspaceId }] : []
8660
+ ) : []
8661
+ };
8662
+ }
8663
+ async function requireOrgxAuth4(options = {}) {
8664
+ const auth = await resolveOrgxAuth(options);
8665
+ if (!auth) {
8666
+ throw new Error("No OrgX API key configured. Run `wizard auth login` or set ORGX_API_KEY first.");
8667
+ }
8668
+ return auth;
8669
+ }
8670
+ function defaultOperatingMapIdempotencyKey(input) {
8671
+ const digest = createHash6("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 32);
8672
+ return `wizard:operating-map:${input.workspaceId}:${digest}`;
8673
+ }
8674
+ async function startOperatingMapDiscovery(input, options = {}) {
8675
+ const auth = await requireOrgxAuth4(options);
8676
+ const response = await fetchWithRetry(buildOrgxApiUrl("/v1/discovery-runs", auth.baseUrl), {
8677
+ method: "POST",
8678
+ headers: {
8679
+ Authorization: `Bearer ${auth.apiKey}`,
8680
+ "Content-Type": "application/json",
8681
+ "Idempotency-Key": input.idempotencyKey
8682
+ },
8683
+ body: JSON.stringify({
8684
+ workspace_id: input.workspaceId,
8685
+ mode: input.mode ?? "bounded_sync",
8686
+ query: input.query ?? null,
8687
+ source_kinds: input.sourceKinds ?? []
8688
+ })
8689
+ });
8690
+ const body = parseResponseBody6(await response.text());
8691
+ if (!response.ok) {
8692
+ throw new Error(`Unable to start the operating-map discovery run. ${formatHttpError5(response.status, body)}`);
8693
+ }
8694
+ const result = parseDiscoveryResult(body);
8695
+ const meta = isRecord(body) && isRecord(body.meta) ? body.meta : {};
8696
+ return { result, duplicate: meta.duplicate === true };
8697
+ }
8698
+ async function proposeOperatingProcessFromMap(input, options = {}) {
8699
+ const auth = await requireOrgxAuth4(options);
8700
+ const response = await fetchWithRetry(
8701
+ buildOrgxApiUrl(`/v1/discovery-runs/${encodeURIComponent(input.discoveryRunId)}/propose`, auth.baseUrl),
8702
+ {
8703
+ method: "POST",
8704
+ headers: {
8705
+ Authorization: `Bearer ${auth.apiKey}`,
8706
+ "Content-Type": "application/json",
8707
+ "Idempotency-Key": input.idempotencyKey
8708
+ },
8709
+ body: JSON.stringify({
8710
+ workspace_id: input.workspaceId,
8711
+ process_candidate_id: input.processCandidateId
8712
+ })
8713
+ }
8714
+ );
8715
+ const body = parseResponseBody6(await response.text());
8716
+ if (!response.ok) {
8717
+ throw new Error(`Unable to propose the OperatingProcess. ${formatHttpError5(response.status, body)}`);
8718
+ }
8719
+ return extractData(body);
8720
+ }
8721
+
8595
8722
  // src/lib/work-graph.ts
8596
- import { createHash as createHash7 } from "crypto";
8723
+ import { createHash as createHash8 } from "crypto";
8597
8724
 
8598
8725
  // src/lib/work-graph-investigation.ts
8599
- import { createHash as createHash6 } from "crypto";
8726
+ import { createHash as createHash7 } from "crypto";
8600
8727
  var WORK_GRAPH_INVESTIGATION_SCHEMA_VERSION = "2.0.0";
8601
8728
  var WORK_GRAPH_INVESTIGATION_CLIENTS = [
8602
8729
  "claude_code",
@@ -8729,7 +8856,7 @@ var CAPABILITY_CEILINGS = {
8729
8856
  }
8730
8857
  };
8731
8858
  function hash3(value, length = 16) {
8732
- return createHash6("sha256").update(JSON.stringify(value)).digest("hex").slice(0, length);
8859
+ return createHash7("sha256").update(JSON.stringify(value)).digest("hex").slice(0, length);
8733
8860
  }
8734
8861
  function clamp(value, min = 0, max = 1) {
8735
8862
  return Math.max(min, Math.min(max, value));
@@ -9831,7 +9958,7 @@ function clampScore2(value) {
9831
9958
  return Math.max(0, Math.min(100, Math.round(value)));
9832
9959
  }
9833
9960
  function hashJson(value) {
9834
- return createHash7("sha256").update(JSON.stringify(value)).digest("hex");
9961
+ return createHash8("sha256").update(JSON.stringify(value)).digest("hex");
9835
9962
  }
9836
9963
  function normalizeFingerprintText(value) {
9837
9964
  return value.toLowerCase().replace(/https?:\/\/\S+/g, "url").replace(/[0-9a-f]{12,}/g, "hash").replace(/\b[0-9a-f]{8}-[0-9a-f-]{27,}\b/g, "uuid").replace(/\s+/g, " ").trim().slice(0, 600);
@@ -13043,14 +13170,14 @@ function renderAqAgentBrief(report, links = {}) {
13043
13170
  }
13044
13171
 
13045
13172
  // src/lib/work-graph-publish.ts
13046
- import { createHash as createHash8, randomUUID as randomUUID2 } from "crypto";
13173
+ import { createHash as createHash9, randomUUID as randomUUID2 } from "crypto";
13047
13174
  import { gzipSync } from "zlib";
13048
13175
  var WORK_GRAPH_REPORT_GZIP_THRESHOLD_BYTES = 4e6;
13049
13176
  var WORK_GRAPH_REPORT_CHUNK_UPLOAD_THRESHOLD_BYTES = 5e5;
13050
13177
  var WORK_GRAPH_REPORT_CHUNK_CHARS = 3e4;
13051
13178
  var WORK_GRAPH_REPORT_CHUNK_UPLOAD_TIMEOUT_MS = 3e5;
13052
13179
  function hashText(value) {
13053
- return createHash8("sha256").update(value).digest("hex");
13180
+ return createHash9("sha256").update(value).digest("hex");
13054
13181
  }
13055
13182
  function buildWorkGraphReportPostPayload(report, options = {}) {
13056
13183
  return {
@@ -13257,7 +13384,7 @@ async function publishWorkGraphEvents(fingerprint, patch, options = {}) {
13257
13384
  }
13258
13385
 
13259
13386
  // src/lib/work-graph-hook-events.ts
13260
- import { createHash as createHash9 } from "crypto";
13387
+ import { createHash as createHash10 } from "crypto";
13261
13388
  import { existsSync as existsSync8, readFileSync as readFileSync6 } from "fs";
13262
13389
  var SOURCE_CLIENTS = [
13263
13390
  "codex",
@@ -13292,7 +13419,7 @@ function asStringArray(value) {
13292
13419
  return value.filter((item) => typeof item === "string" && item.trim().length > 0);
13293
13420
  }
13294
13421
  function stableHash(value) {
13295
- return createHash9("sha256").update(value).digest("hex").slice(0, 20);
13422
+ return createHash10("sha256").update(value).digest("hex").slice(0, 20);
13296
13423
  }
13297
13424
  function normalizeSourceClient2(value) {
13298
13425
  const raw = asString2(value)?.toLowerCase();
@@ -15031,6 +15158,86 @@ async function runAuditCommand(options) {
15031
15158
  console.log(` ${ICON.ok} ${pc3.green("follow-up ")} ${pc3.bold(followUp.title)} ${pc3.dim(followUp.id)}`);
15032
15159
  }
15033
15160
  }
15161
+ async function runOperatingMapCommand(queryParts, options) {
15162
+ const auth = await resolveOrgxAuth();
15163
+ if (!auth) {
15164
+ throw new Error("Operating-map discovery requires OrgX auth. Run `wizard auth login` first.");
15165
+ }
15166
+ const workspace = options.workspaceId?.trim() ? { id: options.workspaceId.trim(), name: options.workspaceId.trim() } : await getCurrentWorkspace();
15167
+ if (!workspace) {
15168
+ throw new Error("No current OrgX workspace found. Run `wizard workspace create <name>` first.");
15169
+ }
15170
+ const query = queryParts.join(" ").trim() || null;
15171
+ const mode = options.deepSearch ? "deep_search" : "bounded_sync";
15172
+ const sourceKinds = (options.source ?? "").split(",").map((source) => source.trim()).filter(Boolean);
15173
+ const idempotencyKey = options.idempotencyKey?.trim() || defaultOperatingMapIdempotencyKey({
15174
+ workspaceId: workspace.id,
15175
+ mode,
15176
+ query,
15177
+ sourceKinds
15178
+ });
15179
+ const spinner = createOrgxSpinner(mode === "deep_search" ? "Mapping workflows with cited deep search" : "Mapping observed workflows");
15180
+ spinner.start();
15181
+ const discovery = await startOperatingMapDiscovery({
15182
+ workspaceId: workspace.id,
15183
+ mode,
15184
+ query,
15185
+ sourceKinds,
15186
+ idempotencyKey
15187
+ });
15188
+ spinner.succeed(discovery.duplicate ? "Replayed the existing operating-map discovery" : "Operating-map discovery complete");
15189
+ const payload = {
15190
+ workspaceId: workspace.id,
15191
+ idempotencyKey,
15192
+ duplicate: discovery.duplicate,
15193
+ run: discovery.result.run,
15194
+ processCards: discovery.result.processCards
15195
+ };
15196
+ if (options.json) {
15197
+ console.log(JSON.stringify(payload, null, 2));
15198
+ } else {
15199
+ console.log(` ${ICON.ok} ${pc3.green("observations ")} ${pc3.dim(String(discovery.result.run.observationCount))}`);
15200
+ console.log(` ${ICON.ok} ${pc3.green("candidates ")} ${pc3.dim(String(discovery.result.processCards.length))}`);
15201
+ console.log(` ${ICON.ok} ${pc3.green("citations ")} ${pc3.dim(String(discovery.result.run.citationCount))}`);
15202
+ for (const [index, card] of discovery.result.processCards.entries()) {
15203
+ console.log("");
15204
+ console.log(` ${pc3.bold(`${index + 1}. ${card.displayName}`)} ${pc3.dim(`${Math.round(card.confidence * 100)}% confidence \xB7 ${card.processCandidateRef.id}`)}`);
15205
+ if (card.nextConfirmationQuestion) console.log(` ${pc3.yellow("confirm:")} ${card.nextConfirmationQuestion}`);
15206
+ if (card.riskFlags.length > 0) console.log(` ${pc3.yellow("limits:")} ${card.riskFlags.join("; ")}`);
15207
+ }
15208
+ if (discovery.result.run.limitations.length > 0) {
15209
+ console.log("");
15210
+ console.log(` ${pc3.yellow("limitations:")} ${discovery.result.run.limitations.join("; ")}`);
15211
+ }
15212
+ }
15213
+ const candidate = options.candidate?.trim();
15214
+ if (!candidate) return;
15215
+ const selected = /^\d+$/.test(candidate) ? discovery.result.processCards[Number(candidate) - 1] : discovery.result.processCards.find((card) => card.processCandidateRef.id === candidate);
15216
+ if (!selected?.processCandidateRef.id) {
15217
+ throw new Error(`Process candidate ${candidate} was not found in discovery run ${discovery.result.run.id}.`);
15218
+ }
15219
+ const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
15220
+ if (!options.yes) {
15221
+ if (!interactive) throw new Error("Proposing an OperatingProcess requires --yes in non-interactive mode.");
15222
+ const confirmed = await clack.confirm({
15223
+ message: `Propose \u201C${selected.displayName}\u201D as an OperatingProcess (still requires human confirmation)?`,
15224
+ initialValue: false
15225
+ });
15226
+ if (clack.isCancel(confirmed) || !confirmed) return;
15227
+ }
15228
+ const proposal = await proposeOperatingProcessFromMap({
15229
+ workspaceId: workspace.id,
15230
+ discoveryRunId: discovery.result.run.id,
15231
+ processCandidateId: selected.processCandidateRef.id,
15232
+ idempotencyKey: `wizard:operating-process:${discovery.result.run.id}:${selected.processCandidateRef.id}`
15233
+ });
15234
+ if (options.json) {
15235
+ console.log(JSON.stringify({ ...payload, proposal }, null, 2));
15236
+ } else {
15237
+ console.log(` ${ICON.ok} ${pc3.green("proposal ")} ${pc3.dim(selected.displayName)}`);
15238
+ console.log(` ${pc3.dim("Next step ")} Review and confirm the OperatingProcess in OrgX; the wizard never auto-activates inferred workflow ownership.`);
15239
+ }
15240
+ }
15034
15241
  function runWorkGraphExtractionSchemaCommand(options) {
15035
15242
  const protocol = buildWorkGraphExtractionProtocol();
15036
15243
  const outputPath = options.output?.trim() ? resolve3(options.output.trim()) : "";
@@ -16319,7 +16526,7 @@ async function main() {
16319
16526
  initializeWizardSentry();
16320
16527
  const program = new Command();
16321
16528
  program.name("orgx-wizard").description("Add OrgX MCP configs, skills/rules, and companion plugins to your local AI tools.").showHelpAfterError();
16322
- const pkgVersion = true ? "0.1.55" : void 0;
16529
+ const pkgVersion = true ? "0.1.56" : void 0;
16323
16530
  program.version(pkgVersion ?? "unknown", "-V, --version");
16324
16531
  program.hook("preAction", (_thisCommand, actionCommand) => {
16325
16532
  if (Boolean(actionCommand.optsWithGlobals().json)) return;
@@ -17040,6 +17247,15 @@ async function main() {
17040
17247
  });
17041
17248
  await runAuditCommand(options);
17042
17249
  });
17250
+ program.command("map").alias("discovery").description("Map observed company workflows into evidence-gated OperatingProcess candidates.").argument("[query...]", "workflow, handoff, or system-of-record question for discovery/deep search").option("--deep-search", "query cited external research in addition to connected repository signals").option("--source <kinds>", "comma-separated source kinds to report and constrain (for example github,notion,slack)").option("--workspace-id <id>", "workspace id override; defaults to the current OrgX workspace").option("--candidate <id-or-number>", "propose one returned ProcessCard by id or 1-based display number").option("--idempotency-key <key>", "stable retry key; defaults to a hash of workspace, mode, query, and sources").option("--yes", "approve the explicit proposal in non-interactive mode").option("--json", "emit machine-readable discovery/proposal output").action(async (queryParts, options) => {
17251
+ await safeTrackWizardTelemetry("operating_map_started", {
17252
+ command: "map",
17253
+ deep_search: Boolean(options.deepSearch),
17254
+ has_candidate: Boolean(options.candidate),
17255
+ json: Boolean(options.json)
17256
+ });
17257
+ await runOperatingMapCommand(queryParts, options);
17258
+ });
17043
17259
  const workGraph = program.command("work-graph").description("Run AQ from real AI-work receipts and surface the first repair that raises execution capacity.");
17044
17260
  workGraph.command("extraction-schema").description("Print the packaged AI-client audit skill used to search sessions, messages, tools, domains, and logs.").option("--output <path>", "write the schema prompt to a file").option("--json", "emit the protocol as JSON instead of Markdown").action(async (options) => {
17045
17261
  await safeTrackWizardTelemetry("work_graph_extraction_schema_started", {
@@ -17348,4 +17564,4 @@ main().catch(async (error) => {
17348
17564
  process.exitCode = 1;
17349
17565
  });
17350
17566
  //# sourceMappingURL=cli.js.map
17351
- //# debugId=707a7fe5-404e-5aec-9c75-30f0f5d859d9
17567
+ //# debugId=02842523-d681-5cea-96aa-0f0c896e9fb5