@useorgx/wizard 0.1.64 → 0.1.66

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,8 +32,8 @@ 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
- - `hooks install [--targets codex,claude-code]` installs bounded local capture hooks. Terminal events write compact session summaries to a durable queue, then request a detached single-flight delivery worker. The hook does not read credentials or perform network I/O. Set `ORGX_SESSION_SUMMARY_AUTO_FLUSH=off` for local-only capture and manual delivery. The legacy transcript-derived execution-graph emit remains off unless `ORGX_EMIT_EXECUTION_GRAPH=1` is set.
36
- - `ORGX_SESSION_WORK_CONTEXT` can carry one explicit, bounded JSON annotation for intent, authority, cost, artifact references, and evidence references. The Wizard does not infer this context from prompts; invalid or oversized annotations are omitted, and unknown fields are removed before cloud delivery.
35
+ - `hooks install [--targets codex,claude-code]` installs bounded local capture hooks. Terminal session events and adapter-supplied `RunEnd` events write compact summaries to a durable queue, then request a detached single-flight delivery worker. `RunEnd` represents one completed agent run inside a conversation that may continue. The hook does not read credentials or perform network I/O. Set `ORGX_SESSION_SUMMARY_AUTO_FLUSH=off` for local-only capture and manual delivery. The legacy transcript-derived execution-graph emit remains off unless `ORGX_EMIT_EXECUTION_GRAPH=1` is set.
36
+ - `ORGX_SESSION_WORK_CONTEXT` can carry one explicit, bounded JSON annotation for intent, authority, cost, artifact and evidence references, plus exact Context Capsule, decision, constraint, expectation, applied-learning, and prior-receipt references. Capsule delivery requires both the capsule reference and delivery timestamp. The Wizard does not infer this context from prompts; invalid or oversized annotations are omitted, and unknown fields are removed before cloud delivery.
37
37
  - `hooks flush [--limit 100]` is the manual delivery and recovery path. It uses the same queue lease as automatic delivery and removes each valid file only after a successful server acknowledgement. Failed captures stay queued for retry; malformed captures move to the owner-only `session-summary-captures/quarantine/` directory and make a manual flush fail visibly without being deleted.
38
38
  - `hooks doctor` shows hook wiring, automatic-delivery configuration, active and quarantined capture counts, and the legacy spool count without changing local configuration.
39
39
  - `hooks backfill` previews compact summaries distilled from the legacy spool. It does not upload or archive anything unless you add `--post --yes`; `--truncate` also requires both flags and archives the original spool only after every upload succeeds.
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]="cf979138-322b-5229-81f2-931f9cdf95d2")}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]="783f771d-d176-55f3-b036-2be49833854e")}catch(e){}}();
6
6
  import * as clack from "@clack/prompts";
7
7
  import { spawnSync as spawnSync5 } from "child_process";
8
8
  import { readFileSync as readFileSync10 } from "fs";
@@ -6354,7 +6354,7 @@ function initializeWizardSentry() {
6354
6354
  Sentry.init({
6355
6355
  dsn,
6356
6356
  environment: process.env.ORGX_SENTRY_ENVIRONMENT || "production",
6357
- release: "useorgx-wizard@0.1.64",
6357
+ release: "useorgx-wizard@0.1.66",
6358
6358
  tracesSampleRate: sampleRate(process.env.ORGX_SENTRY_TRACES_SAMPLE_RATE),
6359
6359
  enableLogs: true,
6360
6360
  sendDefaultPii: false,
@@ -13969,7 +13969,9 @@ function actionResult(event, sourceClient) {
13969
13969
  // Claude's PostToolUse contract fires only after success. Codex documents
13970
13970
  // PostToolUse for completed tools, including non-zero Bash exits, so its
13971
13971
  // outcome must remain explicitly unclassified without reading tool output.
13972
- return sourceClient === "claude-code" ? "succeeded" : "completed_unknown";
13972
+ return sourceClient === "claude-code" || sourceClient === "cursor" || sourceClient === "opencode"
13973
+ ? "succeeded"
13974
+ : "completed_unknown";
13973
13975
  }
13974
13976
 
13975
13977
  function pendingIndex(state, toolUseId) {
@@ -14135,7 +14137,7 @@ function buildExecutionObservation(state, captureKind) {
14135
14137
  return {
14136
14138
  schema_version: "orgx-session-execution-observation/v1",
14137
14139
  boundary: captureKind || "legacy_unspecified",
14138
- terminal_observed: captureKind === "session_end",
14140
+ terminal_observed: captureKind === "run_end" || captureKind === "session_end",
14139
14141
  actions: actions,
14140
14142
  actions_completed_observed: state.tool_calls,
14141
14143
  actions_omitted: omitted,
@@ -14281,7 +14283,7 @@ function workRefs(value) {
14281
14283
 
14282
14284
  function workIso(value) {
14283
14285
  var text = workString(value, 100);
14284
- return text && /^d{4}-d{2}-d{2}Td{2}:d{2}:d{2}(?:.d+)?(?:Z|[+-]d{2}:d{2})$/.test(text) && !Number.isNaN(Date.parse(text))
14286
+ return text && /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$/.test(text) && !Number.isNaN(Date.parse(text))
14285
14287
  ? text
14286
14288
  : null;
14287
14289
  }
@@ -14316,6 +14318,18 @@ export function parseExplicitWorkContext(value) {
14316
14318
  var validUntil = authority.valid_until === undefined ? undefined : workIso(authority.valid_until);
14317
14319
  var artifactRefs = workRefs(parsed.artifact_refs);
14318
14320
  var evidenceRefs = workRefs(parsed.evidence_refs);
14321
+ var semantic = parsed.semantic_refs === undefined ? undefined : workObject(parsed.semantic_refs);
14322
+ var contextCapsuleRef = !semantic || semantic.context_capsule_ref === undefined
14323
+ ? undefined
14324
+ : workRef(semantic.context_capsule_ref);
14325
+ var contextDeliveredAt = !semantic || semantic.context_delivered_at === undefined
14326
+ ? undefined
14327
+ : workIso(semantic.context_delivered_at);
14328
+ var decisionRefs = !semantic ? [] : workRefs(semantic.decision_refs);
14329
+ var constraintRefs = !semantic ? [] : workRefs(semantic.constraint_refs);
14330
+ var expectationRefs = !semantic ? [] : workRefs(semantic.expectation_refs);
14331
+ var learningRefs = !semantic ? [] : workRefs(semantic.learning_refs);
14332
+ var priorReceiptRefs = !semantic ? [] : workRefs(semantic.prior_receipt_refs);
14319
14333
  var currency = workString(cost.currency, 12);
14320
14334
  var source = cost.source === undefined ? undefined : workString(cost.source, 120);
14321
14335
  if (!summary || objective === null || acceptance === null || intentConstraints === null || requestRef === null) return null;
@@ -14326,6 +14340,11 @@ export function parseExplicitWorkContext(value) {
14326
14340
  if (!currency || !/^[A-Z][A-Z0-9_-]{1,11}$/.test(currency) || typeof cost.total !== "number" || !Number.isFinite(cost.total) || cost.total < 0 || cost.total > 100000 || source === null) return null;
14327
14341
  if (cost.estimated !== undefined && typeof cost.estimated !== "boolean") return null;
14328
14342
  if (artifactRefs === null || evidenceRefs === null) return null;
14343
+ if (parsed.semantic_refs !== undefined && !semantic) return null;
14344
+ if (contextCapsuleRef === null || contextDeliveredAt === null || decisionRefs === null || constraintRefs === null || expectationRefs === null || learningRefs === null || priorReceiptRefs === null) return null;
14345
+ if (Boolean(contextCapsuleRef) !== Boolean(contextDeliveredAt)) return null;
14346
+ var semanticRefCount = decisionRefs.length + constraintRefs.length + expectationRefs.length + learningRefs.length + priorReceiptRefs.length + (contextCapsuleRef ? 1 : 0);
14347
+ if (semantic !== undefined && (semanticRefCount === 0 || semanticRefCount > 20)) return null;
14329
14348
  var normalizedIntent = { summary: summary, acceptance_criteria: acceptance, constraints: intentConstraints };
14330
14349
  if (objective) normalizedIntent.objective = objective;
14331
14350
  if (requestRef) normalizedIntent.request_ref = requestRef;
@@ -14341,6 +14360,20 @@ export function parseExplicitWorkContext(value) {
14341
14360
  if (validUntil) normalizedAuthority.valid_until = validUntil;
14342
14361
  var normalizedCost = { currency: currency, total: cost.total, estimated: cost.estimated !== false };
14343
14362
  if (source) normalizedCost.source = source;
14363
+ var normalizedSemantic;
14364
+ if (semantic !== undefined) {
14365
+ normalizedSemantic = {
14366
+ decision_refs: decisionRefs,
14367
+ constraint_refs: constraintRefs,
14368
+ expectation_refs: expectationRefs,
14369
+ learning_refs: learningRefs,
14370
+ prior_receipt_refs: priorReceiptRefs,
14371
+ };
14372
+ if (contextCapsuleRef) {
14373
+ normalizedSemantic.context_capsule_ref = contextCapsuleRef;
14374
+ normalizedSemantic.context_delivered_at = contextDeliveredAt;
14375
+ }
14376
+ }
14344
14377
  return {
14345
14378
  schema_version: "orgx-session-work-context/v1",
14346
14379
  provenance: "producer_asserted",
@@ -14349,6 +14382,7 @@ export function parseExplicitWorkContext(value) {
14349
14382
  cost: normalizedCost,
14350
14383
  artifact_refs: artifactRefs,
14351
14384
  evidence_refs: evidenceRefs,
14385
+ ...(normalizedSemantic ? { semantic_refs: normalizedSemantic } : {}),
14352
14386
  };
14353
14387
  }
14354
14388
 
@@ -14411,7 +14445,15 @@ export async function main(options) {
14411
14445
  var explicitWorkContext = parseExplicitWorkContext(env.ORGX_SESSION_WORK_CONTEXT);
14412
14446
 
14413
14447
  var event = pickString(args.event, payload.hook_event_name, payload.hookEventName, "unknown");
14414
- var sessionId = pickString(payload.session_id, payload.sessionId, args.session_id);
14448
+ var sessionId = pickString(
14449
+ payload.session_id,
14450
+ payload.sessionId,
14451
+ payload.conversation_id,
14452
+ payload.conversationId,
14453
+ payload.thread_id,
14454
+ payload.threadId,
14455
+ args.session_id
14456
+ );
14415
14457
  if (!sessionId) return { ok: true, skipped: "missing_session_id" };
14416
14458
 
14417
14459
  var sourceClient = pickString(args.source_client, env.ORGX_SOURCE_CLIENT, "claude-code");
@@ -14419,7 +14461,7 @@ export async function main(options) {
14419
14461
  var stateDir = dir ? dir : pickString(args.state_dir, env.ORGX_SESSION_STATE_DIR);
14420
14462
  var path = statePath(sessionId, stateDir);
14421
14463
 
14422
- var terminal = event === "Stop" || event === "SessionEnd";
14464
+ var terminal = event === "Stop" || event === "RunEnd" || event === "SessionEnd";
14423
14465
 
14424
14466
  if (!terminal) {
14425
14467
  // Hot path: one small file read + write. Never a network call.
@@ -14455,13 +14497,17 @@ export async function main(options) {
14455
14497
  if (explicitWorkContext) finalState.work_context = explicitWorkContext;
14456
14498
  var initiativeId = pickString(env.ORGX_INITIATIVE_ID, args.initiative);
14457
14499
  var queueDir = pickString(args.queue_dir, env.ORGX_SESSION_SUMMARY_QUEUE_DIR) || defaultQueueDir();
14458
- var captureKind = event === "SessionEnd" ? "session_end" : "turn_boundary";
14500
+ var captureKind = event === "SessionEnd"
14501
+ ? "session_end"
14502
+ : event === "RunEnd"
14503
+ ? "run_end"
14504
+ : "turn_boundary";
14459
14505
  var summary = buildSummary(finalState, nowIso, captureKind);
14460
14506
  var queued = enqueueSummaryCapture(queueDir, summary, initiativeId, nowIso, captureKind);
14461
14507
  if (!queued) return { ok: true, skipped: "queue_write_failed", summary: summary };
14462
14508
  var deliveryTriggered = triggerQueueDelivery(args, env, queueDir, spawnImpl);
14463
14509
 
14464
- if (event === "SessionEnd") {
14510
+ if (event === "RunEnd" || event === "SessionEnd") {
14465
14511
  try {
14466
14512
  rmSync(path, { force: true });
14467
14513
  } catch (e) {
@@ -14474,7 +14520,7 @@ export async function main(options) {
14474
14520
  queued: true,
14475
14521
  queue_path: queued.path,
14476
14522
  delivery_triggered: deliveryTriggered,
14477
- final: event === "SessionEnd",
14523
+ final: event === "RunEnd" || event === "SessionEnd",
14478
14524
  summary: summary,
14479
14525
  };
14480
14526
  }
@@ -15227,6 +15273,29 @@ var referenceList = z.array(externalReferenceSchema).max(20).default([]).transfo
15227
15273
  return a < b ? -1 : a > b ? 1 : 0;
15228
15274
  });
15229
15275
  });
15276
+ var semanticReferencesSchema = z.object({
15277
+ context_capsule_ref: externalReferenceSchema.optional(),
15278
+ context_delivered_at: z.string().datetime({ offset: true }).optional(),
15279
+ decision_refs: referenceList,
15280
+ constraint_refs: referenceList,
15281
+ expectation_refs: referenceList,
15282
+ learning_refs: referenceList,
15283
+ prior_receipt_refs: referenceList
15284
+ }).superRefine((value, context) => {
15285
+ if (Boolean(value.context_capsule_ref) !== Boolean(value.context_delivered_at)) {
15286
+ context.addIssue({
15287
+ code: z.ZodIssueCode.custom,
15288
+ message: "context_capsule_ref and context_delivered_at must be supplied together"
15289
+ });
15290
+ }
15291
+ const totalRefs = value.decision_refs.length + value.constraint_refs.length + value.expectation_refs.length + value.learning_refs.length + value.prior_receipt_refs.length + (value.context_capsule_ref ? 1 : 0);
15292
+ if (totalRefs === 0 || totalRefs > 20) {
15293
+ context.addIssue({
15294
+ code: z.ZodIssueCode.custom,
15295
+ message: "semantic_refs must contain between 1 and 20 references"
15296
+ });
15297
+ }
15298
+ });
15230
15299
  var authoritySchema = z.object({
15231
15300
  mode: z.enum([
15232
15301
  "explicit",
@@ -15271,7 +15340,8 @@ var sessionWorkContextInputSchema = z.object({
15271
15340
  source: boundedText(120).optional()
15272
15341
  }),
15273
15342
  artifact_refs: referenceList,
15274
- evidence_refs: referenceList
15343
+ evidence_refs: referenceList,
15344
+ semantic_refs: semanticReferencesSchema.optional()
15275
15345
  });
15276
15346
  function normalizeSessionWorkContext(value) {
15277
15347
  const parsed = sessionWorkContextInputSchema.safeParse(value);
@@ -15341,6 +15411,7 @@ function normalizeSessionExecutionObservation(value) {
15341
15411
  const boundary = boundedString(value.boundary, 40);
15342
15412
  if (!boundary || ![
15343
15413
  "turn_boundary",
15414
+ "run_end",
15344
15415
  "session_end",
15345
15416
  "historical_backfill",
15346
15417
  "legacy_unspecified"
@@ -15654,7 +15725,7 @@ function parseSessionSummaryCapture(raw) {
15654
15725
  // Captures created by wizard 0.1.56 before this field existed must remain
15655
15726
  // deliverable. Preserve the uncertainty instead of guessing that an old
15656
15727
  // snapshot represented a real SessionEnd.
15657
- capture_kind: value.capture_kind === "turn_boundary" || value.capture_kind === "session_end" ? value.capture_kind : "legacy_unspecified",
15728
+ capture_kind: value.capture_kind === "turn_boundary" || value.capture_kind === "run_end" || value.capture_kind === "session_end" ? value.capture_kind : "legacy_unspecified",
15658
15729
  queued_at: value.queued_at,
15659
15730
  session: value.session,
15660
15731
  ...typeof value.initiative_id === "string" ? { initiative_id: value.initiative_id } : {}
@@ -18507,7 +18578,7 @@ async function main() {
18507
18578
  initializeWizardSentry();
18508
18579
  const program = new Command();
18509
18580
  program.name("orgx-wizard").description("Add OrgX MCP configs, skills/rules, and companion plugins to your local AI tools.").showHelpAfterError();
18510
- const pkgVersion = true ? "0.1.64" : void 0;
18581
+ const pkgVersion = true ? "0.1.66" : void 0;
18511
18582
  program.version(pkgVersion ?? "unknown", "-V, --version");
18512
18583
  program.hook("preAction", (_thisCommand, actionCommand) => {
18513
18584
  if (Boolean(actionCommand.optsWithGlobals().json)) return;
@@ -19551,4 +19622,4 @@ main().catch(async (error) => {
19551
19622
  process.exitCode = 1;
19552
19623
  });
19553
19624
  //# sourceMappingURL=cli.js.map
19554
- //# debugId=cf979138-322b-5229-81f2-931f9cdf95d2
19625
+ //# debugId=783f771d-d176-55f3-b036-2be49833854e