@outcomeeng/spx 0.3.0 → 0.3.1

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/dist/cli.js CHANGED
@@ -1707,6 +1707,17 @@ var PRIORITY_ORDER = {
1707
1707
  low: 2
1708
1708
  };
1709
1709
  var DEFAULT_PRIORITY = "medium";
1710
+ var SESSION_FRONT_MATTER = {
1711
+ PRIORITY: "priority",
1712
+ TAGS: "tags",
1713
+ ID: "id",
1714
+ BRANCH: "branch",
1715
+ CREATED_AT: "created_at",
1716
+ AGENT_SESSION_ID: "agent_session_id",
1717
+ WORKING_DIRECTORY: "working_directory",
1718
+ SPECS: "specs",
1719
+ FILES: "files"
1720
+ };
1710
1721
 
1711
1722
  // src/session/list.ts
1712
1723
  var FRONT_MATTER_PATTERN = /^---\r?\n([\s\S]*?)\r?\n(?:---|\.\.\.)\r?\n?/;
@@ -1729,36 +1740,28 @@ function parseSessionMetadata(content) {
1729
1740
  tags: []
1730
1741
  };
1731
1742
  }
1732
- const priority = isValidPriority(parsed.priority) ? parsed.priority : DEFAULT_PRIORITY;
1733
- let tags = [];
1734
- if (Array.isArray(parsed.tags)) {
1735
- tags = parsed.tags.filter((t) => typeof t === "string");
1736
- }
1737
- const metadata = {
1738
- priority,
1739
- tags
1740
- };
1741
- if (typeof parsed.id === "string") {
1742
- metadata.id = parsed.id;
1743
- }
1744
- if (typeof parsed.branch === "string") {
1745
- metadata.branch = parsed.branch;
1746
- }
1747
- if (typeof parsed.created_at === "string") {
1748
- metadata.createdAt = parsed.created_at;
1749
- }
1750
- if (typeof parsed.working_directory === "string") {
1751
- metadata.workingDirectory = parsed.working_directory;
1752
- }
1753
- if (Array.isArray(parsed.specs)) {
1754
- metadata.specs = parsed.specs.filter(
1755
- (s) => typeof s === "string"
1756
- );
1757
- }
1758
- if (Array.isArray(parsed.files)) {
1759
- metadata.files = parsed.files.filter(
1760
- (f) => typeof f === "string"
1761
- );
1743
+ const rawPriority = parsed[SESSION_FRONT_MATTER.PRIORITY];
1744
+ const priority = isValidPriority(rawPriority) ? rawPriority : DEFAULT_PRIORITY;
1745
+ const rawTags = parsed[SESSION_FRONT_MATTER.TAGS];
1746
+ const tags = Array.isArray(rawTags) ? rawTags.filter((t) => typeof t === "string") : [];
1747
+ const metadata = { priority, tags };
1748
+ const id = parsed[SESSION_FRONT_MATTER.ID];
1749
+ if (typeof id === "string") metadata.id = id;
1750
+ const branch = parsed[SESSION_FRONT_MATTER.BRANCH];
1751
+ if (typeof branch === "string") metadata.branch = branch;
1752
+ const createdAt = parsed[SESSION_FRONT_MATTER.CREATED_AT];
1753
+ if (typeof createdAt === "string") metadata.createdAt = createdAt;
1754
+ const agentSessionId = parsed[SESSION_FRONT_MATTER.AGENT_SESSION_ID];
1755
+ if (typeof agentSessionId === "string") metadata.agentSessionId = agentSessionId;
1756
+ const workingDirectory = parsed[SESSION_FRONT_MATTER.WORKING_DIRECTORY];
1757
+ if (typeof workingDirectory === "string") metadata.workingDirectory = workingDirectory;
1758
+ const specs = parsed[SESSION_FRONT_MATTER.SPECS];
1759
+ if (Array.isArray(specs)) {
1760
+ metadata.specs = specs.filter((s) => typeof s === "string");
1761
+ }
1762
+ const files = parsed[SESSION_FRONT_MATTER.FILES];
1763
+ if (Array.isArray(files)) {
1764
+ metadata.files = files.filter((f) => typeof f === "string");
1762
1765
  }
1763
1766
  return metadata;
1764
1767
  } catch {
@@ -1855,6 +1858,16 @@ import { join as join5, resolve as resolve4 } from "path";
1855
1858
 
1856
1859
  // src/session/create.ts
1857
1860
  var MIN_CONTENT_LENGTH = 1;
1861
+ var FRONT_MATTER_OPEN = /^---\r?\n/;
1862
+ function preFillSessionContent(content, params) {
1863
+ const match = FRONT_MATTER_OPEN.exec(content);
1864
+ if (!match) return content;
1865
+ const lines = [`${SESSION_FRONT_MATTER.CREATED_AT}: "${params.createdAt.toISOString()}"`];
1866
+ if (params.agentSessionId !== void 0) {
1867
+ lines.push(`${SESSION_FRONT_MATTER.AGENT_SESSION_ID}: "${params.agentSessionId}"`);
1868
+ }
1869
+ return match[0] + lines.join("\n") + "\n" + content.slice(match[0].length);
1870
+ }
1858
1871
  function validateSessionContent(content) {
1859
1872
  if (!content || content.trim().length < MIN_CONTENT_LENGTH) {
1860
1873
  return {
@@ -1892,7 +1905,12 @@ ${content}`;
1892
1905
  async function handoffCommand(options) {
1893
1906
  const { config, warning } = await resolveSessionConfig({ sessionsDir: options.sessionsDir });
1894
1907
  const sessionId = generateSessionId();
1895
- const fullContent = buildSessionContent(options.content);
1908
+ const baseContent = buildSessionContent(options.content);
1909
+ const agentSessionId = process.env.CLAUDE_SESSION_ID ?? process.env.CODEX_THREAD_ID;
1910
+ const fullContent = preFillSessionContent(baseContent, {
1911
+ createdAt: /* @__PURE__ */ new Date(),
1912
+ agentSessionId
1913
+ });
1896
1914
  const validation = validateSessionContent(fullContent);
1897
1915
  if (!validation.valid) {
1898
1916
  throw new SessionInvalidContentError(validation.error ?? "Unknown validation error");