@bonginkan/maria 4.4.0 → 4.4.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.cjs CHANGED
@@ -20,12 +20,12 @@ var fs7 = require('fs-extra');
20
20
  var util = require('util');
21
21
  var promises = require('timers/promises');
22
22
  var dns = require('dns/promises');
23
- var zod = require('zod');
24
23
  var process6 = require('process');
25
24
  var readline = require('readline');
26
25
  var buffer = require('buffer');
27
26
  var net = require('net');
28
27
  var zlib = require('zlib');
28
+ var zod = require('zod');
29
29
  var yaml = require('js-yaml');
30
30
  var neo4j = require('neo4j-driver');
31
31
  var typescriptEstree = require('@typescript-eslint/typescript-estree');
@@ -1736,7 +1736,7 @@ var init_AuthenticationManager = __esm({
1736
1736
  const response = await fetch(`${this.apiBase}/api/user/profile`, {
1737
1737
  headers: {
1738
1738
  "Authorization": `Bearer ${tokens2.accessToken}`,
1739
- "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.4.0"}`
1739
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.4.1"}`
1740
1740
  }
1741
1741
  });
1742
1742
  if (response.status === 401) {
@@ -2461,7 +2461,7 @@ async function callApi(path66, init3 = {}) {
2461
2461
  "Authorization": `Bearer ${token}`,
2462
2462
  "X-Device-Id": getDeviceId(),
2463
2463
  "X-Session-Id": getSessionId() || "",
2464
- "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.4.0"}`,
2464
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.4.1"}`,
2465
2465
  "Content-Type": init3.headers?.["Content-Type"] || "application/json"
2466
2466
  });
2467
2467
  const doFetch = async (token) => {
@@ -10043,10 +10043,10 @@ var init_ignore = __esm({
10043
10043
  ignored(p) {
10044
10044
  const fullpath = p.fullpath();
10045
10045
  const fullpaths = `${fullpath}/`;
10046
- const relative5 = p.relative() || ".";
10047
- const relatives = `${relative5}/`;
10046
+ const relative6 = p.relative() || ".";
10047
+ const relatives = `${relative6}/`;
10048
10048
  for (const m2 of this.relative) {
10049
- if (m2.match(relative5) || m2.match(relatives))
10049
+ if (m2.match(relative6) || m2.match(relatives))
10050
10050
  return true;
10051
10051
  }
10052
10052
  for (const m2 of this.absolute) {
@@ -10057,9 +10057,9 @@ var init_ignore = __esm({
10057
10057
  }
10058
10058
  childrenIgnored(p) {
10059
10059
  const fullpath = p.fullpath() + "/";
10060
- const relative5 = (p.relative() || ".") + "/";
10060
+ const relative6 = (p.relative() || ".") + "/";
10061
10061
  for (const m2 of this.relativeChildren) {
10062
- if (m2.match(relative5))
10062
+ if (m2.match(relative6))
10063
10063
  return true;
10064
10064
  }
10065
10065
  for (const m2 of this.absoluteChildren) {
@@ -16622,8 +16622,8 @@ var require_package = __commonJS({
16622
16622
  "package.json"(exports, module) {
16623
16623
  module.exports = {
16624
16624
  name: "@bonginkan/maria",
16625
- version: "4.4.0",
16626
- description: "\u{1F680} MARIA v4.4.0 - Enterprise AI Development Platform with identity system and character voice implementation. Features 74 production-ready commands with comprehensive fallback implementation, local LLM support, and zero external dependencies. Includes natural language coding, AI safety evaluation, intelligent evolution system, episodic memory with PII masking, and real-time monitoring dashboard. Built with TypeScript AST-powered code generation, OAuth2.0 + PKCE authentication, quantum-resistant cryptography, and enterprise-grade performance.",
16625
+ version: "4.4.1",
16626
+ description: "\u{1F680} MARIA v4.4.1 - Enterprise AI Development Platform with identity system and character voice implementation. Features 74 production-ready commands with comprehensive fallback implementation, local LLM support, and zero external dependencies. Includes natural language coding, AI safety evaluation, intelligent evolution system, episodic memory with PII masking, and real-time monitoring dashboard. Built with TypeScript AST-powered code generation, OAuth2.0 + PKCE authentication, quantum-resistant cryptography, and enterprise-grade performance.",
16627
16627
  keywords: [
16628
16628
  "ai",
16629
16629
  "cli",
@@ -23828,193 +23828,6 @@ ${(/* @__PURE__ */ new Date()).toISOString()}`;
23828
23828
  };
23829
23829
  }
23830
23830
  });
23831
- function assertSnapshot(data) {
23832
- const res = SnapshotZ.safeParse(data);
23833
- if (!res.success) {
23834
- const details = res.error.issues.map((i2) => `${i2.path.join(".") || "<root>"} ${i2.message}`).join(" | ");
23835
- throw new ValidationError2(`Invalid snapshot: ${details}`);
23836
- }
23837
- }
23838
- var SnapshotZ, ValidationError2;
23839
- var init_validators = __esm({
23840
- "src/memory/validators.ts"() {
23841
- SnapshotZ = zod.z.object({
23842
- snapshotVersion: zod.z.literal(1),
23843
- projectId: zod.z.string().optional(),
23844
- taskId: zod.z.string().min(1),
23845
- timestamp: zod.z.string().datetime(),
23846
- // ISO-8601 UTC expected
23847
- summary: zod.z.string().min(1),
23848
- decisions: zod.z.array(zod.z.string()).optional(),
23849
- artifacts: zod.z.array(zod.z.string()).optional(),
23850
- links: zod.z.array(
23851
- zod.z.object({
23852
- type: zod.z.enum(["doc", "fs", "url", "firestore"]),
23853
- ref: zod.z.string().min(1)
23854
- })
23855
- ).optional(),
23856
- hash: zod.z.string().optional(),
23857
- score: zod.z.object({
23858
- testsPassRate: zod.z.number().min(0).max(1).optional(),
23859
- coverage: zod.z.number().min(0).max(1).optional()
23860
- }).optional(),
23861
- tags: zod.z.array(zod.z.string()).optional(),
23862
- resumePrompt: zod.z.string().optional()
23863
- });
23864
- ValidationError2 = class extends Error {
23865
- constructor(message) {
23866
- super(message);
23867
- this.name = "ValidationError";
23868
- }
23869
- };
23870
- }
23871
- });
23872
- function storeFactory(ctx2) {
23873
- const mode = process.env.MARIA_STORE || "mock";
23874
- ctx2.logger?.info?.(`[resume] store=${mode}`);
23875
- if (mode === "firestore") {
23876
- try {
23877
- const db = ctx2.firestore || tryGetFirestore();
23878
- if (db) return new FirestoreSnapshotStore(db);
23879
- console.warn("[resume] firestore not available; falling back to mock store");
23880
- } catch (e2) {
23881
- console.warn("[resume] firestore error; falling back to mock store:", e2?.message || e2);
23882
- }
23883
- }
23884
- return new MockSnapshotStore(ctx2.cwd || process.cwd());
23885
- }
23886
- function tryGetFirestore() {
23887
- try {
23888
- const admin = __require("firebase-admin");
23889
- if (!admin.apps || admin.apps.length === 0) {
23890
- try {
23891
- admin.initializeApp();
23892
- } catch {
23893
- }
23894
- }
23895
- const { getFirestore } = __require("firebase-admin/firestore");
23896
- return getFirestore();
23897
- } catch {
23898
- return null;
23899
- }
23900
- }
23901
- async function trySaveSnapshot(projectId, taskId, data) {
23902
- try {
23903
- const db = tryGetFirestore();
23904
- if (!db) return false;
23905
- const tsId = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").split(".")[0] + "Z";
23906
- const ref = db.collection("projects").doc(projectId).collection("tasks").doc(taskId).collection("snapshots").doc(tsId);
23907
- await ref.set({
23908
- snapshotVersion: 1,
23909
- projectId,
23910
- taskId,
23911
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
23912
- summary: data.summary,
23913
- decisions: data.decisions || [],
23914
- artifacts: data.artifacts || [],
23915
- links: (data.refs || []).map((r2) => ({ type: "fs", ref: r2 })),
23916
- resumePrompt: data.resumePrompt || ""
23917
- });
23918
- return true;
23919
- } catch {
23920
- return false;
23921
- }
23922
- }
23923
- var MockSnapshotStore, FirestoreSnapshotStore;
23924
- var init_firestore = __esm({
23925
- "src/memory/firestore.ts"() {
23926
- init_validators();
23927
- MockSnapshotStore = class {
23928
- constructor(cwd2 = process.cwd()) {
23929
- this.cwd = cwd2;
23930
- }
23931
- async getLatest(_projectId, limit = 1) {
23932
- const s2 = this.readLocal();
23933
- return s2.slice(0, limit);
23934
- }
23935
- async getByTask(_projectId, taskId, limit = 5) {
23936
- const s2 = this.readLocal().filter((x2) => x2.taskId === taskId);
23937
- return s2.slice(0, limit);
23938
- }
23939
- async getByDate(_projectId, dateISO, limit = 5) {
23940
- const s2 = this.readLocal().filter((x2) => x2.timestamp?.startsWith(dateISO));
23941
- return s2.slice(0, limit);
23942
- }
23943
- readLocal() {
23944
- const sessionPath = path11__namespace.default.join(this.cwd, ".maria", "memory", "session.json");
23945
- const candidates = [];
23946
- try {
23947
- const raw = JSON.parse(fs20__namespace.default.readFileSync(sessionPath, "utf8"));
23948
- const ctx2 = raw?.context;
23949
- if (ctx2?.summary) {
23950
- const synthetic = {
23951
- snapshotVersion: 1,
23952
- projectId: "default",
23953
- taskId: raw.taskId || "resume.task",
23954
- timestamp: raw.resumeAt || (/* @__PURE__ */ new Date()).toISOString(),
23955
- summary: ctx2.summary,
23956
- decisions: ctx2.decisions || [],
23957
- artifacts: ctx2.artifacts || [],
23958
- links: (ctx2.refs || []).map((r2) => ({ type: "url", ref: r2 }))
23959
- };
23960
- assertSnapshot(synthetic);
23961
- candidates.push(synthetic);
23962
- }
23963
- } catch {
23964
- }
23965
- if (candidates.length === 0) {
23966
- const fallback2 = {
23967
- snapshotVersion: 1,
23968
- projectId: "default",
23969
- taskId: "example.task",
23970
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
23971
- summary: "\u524D\u56DE\u4F5C\u696D\u306E\u7D9A\u304D\u3002/code \u3092\u518D\u958B\u3067\u304D\u308B\u3088\u3046\u306B\u6E96\u5099\u6E08\u307F\u3002",
23972
- decisions: ["\u81EA\u52D5\u30C6\u30B9\u30C8\u306F\u6700\u4F4E\u9650", "\u7834\u58CA\u7684\u5909\u66F4\u306F\u3057\u306A\u3044"],
23973
- artifacts: ["README.md"],
23974
- links: [{ type: "doc", ref: "docs/RESUME_FUNCTION_DESIGN.md" }],
23975
- resumePrompt: "\u6628\u65E5\u306E\u7D9A\u304D\u304B\u3089\u518D\u958B\u3057\u3066\u3001\u5DEE\u5206\u306E\u307F\u9069\u7528\u3057\u3066\u4E0B\u3055\u3044\u3002"
23976
- };
23977
- assertSnapshot(fallback2);
23978
- candidates.push(fallback2);
23979
- }
23980
- return candidates;
23981
- }
23982
- };
23983
- FirestoreSnapshotStore = class {
23984
- constructor(db) {
23985
- this.db = db;
23986
- }
23987
- async getLatest(projectId, limit = 1) {
23988
- const q = this.db.collectionGroup("snapshots").where("projectId", "==", projectId).orderBy("timestamp", "desc").limit(limit);
23989
- const ss = await q.get();
23990
- return this.validateDocs(ss.docs.map((d) => d.data()));
23991
- }
23992
- async getByTask(projectId, taskId, limit = 5) {
23993
- const q = this.db.collection("projects").doc(projectId).collection("tasks").doc(taskId).collection("snapshots").orderBy("timestamp", "desc").limit(limit);
23994
- const ss = await q.get();
23995
- return this.validateDocs(ss.docs.map((d) => d.data()));
23996
- }
23997
- async getByDate(projectId, dateISO, limit = 5) {
23998
- const start = new Date(dateISO).toISOString();
23999
- const end = new Date(new Date(dateISO).getTime() + 24 * 60 * 60 * 1e3).toISOString();
24000
- const q = this.db.collectionGroup("snapshots").where("projectId", "==", projectId).where("timestamp", ">=", start).where("timestamp", "<", end).orderBy("timestamp", "desc").limit(limit);
24001
- const ss = await q.get();
24002
- return this.validateDocs(ss.docs.map((d) => d.data()));
24003
- }
24004
- validateDocs(rows) {
24005
- const out = [];
24006
- for (const r2 of rows) {
24007
- try {
24008
- assertSnapshot(r2);
24009
- out.push(r2);
24010
- } catch {
24011
- }
24012
- }
24013
- return out;
24014
- }
24015
- };
24016
- }
24017
- });
24018
23831
 
24019
23832
  // src/slash-commands/categories/media/image.command.ts
24020
23833
  var image_command_exports = {};
@@ -24029,7 +23842,7 @@ var init_image_command = __esm({
24029
23842
  init_Normalizer();
24030
23843
  init_ImagePipeline();
24031
23844
  init_session();
24032
- init_firestore();
23845
+ init_api_caller();
24033
23846
  init_cli_auth();
24034
23847
  init_api_client();
24035
23848
  init_cli_auth();
@@ -24137,6 +23950,22 @@ var init_image_command = __esm({
24137
23950
  await api.consumeQuota({ requests: 1, image: Math.max(1, savedPaths.length) });
24138
23951
  } catch {
24139
23952
  }
23953
+ try {
23954
+ new SessionMemory(context2.environment.cwd).save({
23955
+ taskId: "media.image.remote",
23956
+ resumeAt: (/* @__PURE__ */ new Date()).toISOString(),
23957
+ context: { summary: `Generated (remote) ${cli.size[0]}x${cli.size[1]} ${cli.format}`, decisions: [], artifacts: savedPaths, refs: savedPaths }
23958
+ });
23959
+ await callAPI("/api/v1/snapshots", {
23960
+ method: "POST",
23961
+ body: { projectId: "default", taskId: "media.image.remote", summary: `Generated (remote) ${cli.size[0]}x${cli.size[1]} ${cli.format}`, decisions: [], artifacts: savedPaths, refs: savedPaths, resumePrompt: "Continue media work based on last remote output" }
23962
+ });
23963
+ } catch (err) {
23964
+ try {
23965
+ console.warn("[snapshots] save failed:", err?.message || String(err));
23966
+ } catch {
23967
+ }
23968
+ }
24140
23969
  return this.success(output4, void 0, void 0);
24141
23970
  }
24142
23971
  if (Array.isArray(filesList) && filesList.length > 0) {
@@ -24180,6 +24009,22 @@ var init_image_command = __esm({
24180
24009
  await api.consumeQuota({ requests: 1, image: Math.max(1, savedPaths.length) });
24181
24010
  } catch {
24182
24011
  }
24012
+ try {
24013
+ new SessionMemory(context2.environment.cwd).save({
24014
+ taskId: "media.image.remote",
24015
+ resumeAt: (/* @__PURE__ */ new Date()).toISOString(),
24016
+ context: { summary: `Generated (remote) ${cli.size[0]}x${cli.size[1]} ${cli.format}`, decisions: [], artifacts: savedPaths, refs: savedPaths }
24017
+ });
24018
+ await callAPI("/api/v1/snapshots", {
24019
+ method: "POST",
24020
+ body: { projectId: "default", taskId: "media.image.remote", summary: `Generated (remote) ${cli.size[0]}x${cli.size[1]} ${cli.format}`, decisions: [], artifacts: savedPaths, refs: savedPaths, resumePrompt: "Continue media work based on last remote output" }
24021
+ });
24022
+ } catch (err) {
24023
+ try {
24024
+ console.warn("[snapshots] save failed:", err?.message || String(err));
24025
+ } catch {
24026
+ }
24027
+ }
24183
24028
  return this.success(output4, void 0, void 0);
24184
24029
  }
24185
24030
  if (urls.length > 0) {
@@ -24201,6 +24046,22 @@ var init_image_command = __esm({
24201
24046
  await api.consumeQuota({ requests: 1, image: consumed });
24202
24047
  } catch {
24203
24048
  }
24049
+ try {
24050
+ new SessionMemory(context2.environment.cwd).save({
24051
+ taskId: "media.image.remote",
24052
+ resumeAt: (/* @__PURE__ */ new Date()).toISOString(),
24053
+ context: { summary: `Generated (remote) ${cli.size[0]}x${cli.size[1]} ${cli.format}`, decisions: [], artifacts: urls, refs: urls }
24054
+ });
24055
+ await callAPI("/api/v1/snapshots", {
24056
+ method: "POST",
24057
+ body: { projectId: "default", taskId: "media.image.remote", summary: `Generated (remote) ${cli.size[0]}x${cli.size[1]} ${cli.format}`, decisions: [], artifacts: urls, refs: urls, resumePrompt: "Continue media work based on last remote output" }
24058
+ });
24059
+ } catch (err) {
24060
+ try {
24061
+ console.warn("[snapshots] save failed:", err?.message || String(err));
24062
+ } catch {
24063
+ }
24064
+ }
24204
24065
  return this.success(output4, void 0, void 0);
24205
24066
  }
24206
24067
  const { formatRemoteAcceptedImage: formatRemoteAcceptedImage2 } = await Promise.resolve().then(() => (init_cli_style(), cli_style_exports));
@@ -24218,13 +24079,7 @@ var init_image_command = __esm({
24218
24079
  resumeAt: (/* @__PURE__ */ new Date()).toISOString(),
24219
24080
  context: { summary: `Generated (remote) ${cli.size[0]}x${cli.size[1]} ${cli.format}`, decisions: [], artifacts: urls, refs: urls }
24220
24081
  });
24221
- await trySaveSnapshot("default", "media.image.remote", {
24222
- summary: `Generated (remote) ${cli.size[0]}x${cli.size[1]} ${cli.format}`,
24223
- decisions: [],
24224
- artifacts: urls,
24225
- refs: urls,
24226
- resumePrompt: "Continue media work based on last remote output"
24227
- });
24082
+ await callAPI("/api/v1/snapshots", { method: "POST", body: { projectId: "default", taskId: "media.image.remote", summary: `Generated (remote) ${cli.size[0]}x${cli.size[1]} ${cli.format}`, decisions: [], artifacts: urls, refs: urls, resumePrompt: "Continue media work based on last remote output" } });
24228
24083
  } catch {
24229
24084
  }
24230
24085
  try {
@@ -24268,13 +24123,7 @@ var init_image_command = __esm({
24268
24123
  refs: [res.saved.manifestPath]
24269
24124
  }
24270
24125
  });
24271
- await trySaveSnapshot("default", "media.image", {
24272
- summary: `Generated ${ok} image(s) ${cli.size[0]}x${cli.size[1]} ${cli.format}`,
24273
- decisions: [],
24274
- artifacts: res.saved.files,
24275
- refs: [res.saved.manifestPath],
24276
- resumePrompt: "Continue media work based on last output"
24277
- });
24126
+ await callAPI("/api/v1/snapshots", { method: "POST", body: { projectId: "default", taskId: "media.image", summary: `Generated ${ok} image(s) ${cli.size[0]}x${cli.size[1]} ${cli.format}`, decisions: [], artifacts: res.saved.files, refs: [res.saved.manifestPath], resumePrompt: "Continue media work based on last output" } });
24278
24127
  } catch {
24279
24128
  }
24280
24129
  try {
@@ -24542,7 +24391,7 @@ var init_video_command = __esm({
24542
24391
  init_Normalizer();
24543
24392
  init_VideoPipeline();
24544
24393
  init_session();
24545
- init_firestore();
24394
+ init_api_caller();
24546
24395
  init_cli_auth();
24547
24396
  init_api_client();
24548
24397
  init_cli_auth();
@@ -24691,6 +24540,15 @@ var init_video_command = __esm({
24691
24540
  await api.consumeQuota({ requests: 1, video: savedPaths.length > 0 ? 1 : 0 });
24692
24541
  } catch {
24693
24542
  }
24543
+ try {
24544
+ new SessionMemory(root).save({ taskId: "media.video.remote", resumeAt: (/* @__PURE__ */ new Date()).toISOString(), context: { summary: `Generated (remote) video ${cli.duration}s @${cli.fps}fps ${cli.size[0]}x${cli.size[1]}`, decisions: [], artifacts: savedPaths, refs: savedPaths } });
24545
+ await callAPI("/api/v1/snapshots", { method: "POST", body: { projectId: "default", taskId: "media.video.remote", summary: `Generated (remote) video ${cli.duration}s @${cli.fps}fps ${cli.size[0]}x${cli.size[1]}`, decisions: [], artifacts: savedPaths, refs: savedPaths, resumePrompt: "Continue media work based on last remote output" } });
24546
+ } catch (err) {
24547
+ try {
24548
+ console.warn("[snapshots] save failed:", err?.message || String(err));
24549
+ } catch {
24550
+ }
24551
+ }
24694
24552
  return this.success(output4);
24695
24553
  }
24696
24554
  const { formatRemoteAcceptedVideo: formatRemoteAcceptedVideo2 } = await Promise.resolve().then(() => (init_cli_style(), cli_style_exports));
@@ -24714,13 +24572,7 @@ var init_video_command = __esm({
24714
24572
  refs: []
24715
24573
  }
24716
24574
  });
24717
- await trySaveSnapshot("default", "media.video.remote", {
24718
- summary: `Generated (remote) video ${cli.duration}s @${cli.fps}fps ${cli.size[0]}x${cli.size[1]}`,
24719
- decisions: [],
24720
- artifacts: [],
24721
- refs: [],
24722
- resumePrompt: "Continue media work based on last remote output"
24723
- });
24575
+ await callAPI("/api/v1/snapshots", { method: "POST", body: { projectId: "default", taskId: "media.video.remote", summary: `Generated (remote) video ${cli.duration}s @${cli.fps}fps ${cli.size[0]}x${cli.size[1]}`, decisions: [], artifacts: [], refs: [], resumePrompt: "Continue media work based on last remote output" } });
24724
24576
  } catch {
24725
24577
  }
24726
24578
  try {
@@ -24762,13 +24614,7 @@ var init_video_command = __esm({
24762
24614
  refs: [res.saved.manifestPath]
24763
24615
  }
24764
24616
  });
24765
- await trySaveSnapshot("default", "media.video", {
24766
- summary: `Generated video ${cli.duration}s @${cli.fps}fps ${cli.size[0]}x${cli.size[1]}${res.warnFallback ? " (frames fallback)" : ""}`,
24767
- decisions: [],
24768
- artifacts: res.saved.files,
24769
- refs: [res.saved.manifestPath],
24770
- resumePrompt: "Continue media work based on last output"
24771
- });
24617
+ await callAPI("/api/v1/snapshots", { method: "POST", body: { projectId: "default", taskId: "media.video", summary: `Generated video ${cli.duration}s @${cli.fps}fps ${cli.size[0]}x${cli.size[1]}${res.warnFallback ? " (frames fallback)" : ""}`, decisions: [], artifacts: res.saved.files, refs: [res.saved.manifestPath], resumePrompt: "Continue media work based on last output" } });
24772
24618
  } catch {
24773
24619
  }
24774
24620
  try {
@@ -26666,40 +26512,40 @@ var init_about_command = __esm({
26666
26512
  async execute(args2, context2) {
26667
26513
  const output3 = [];
26668
26514
  output3.push("");
26669
- output3.push(chalk40__default.default.cyan.bold("\u{1F916} About MARIA v4.4.0"));
26515
+ output3.push(chalk40__default.default.cyan.bold("About MARIA v4.4.1"));
26670
26516
  output3.push(chalk40__default.default.gray("\u2550".repeat(40)));
26671
26517
  output3.push("");
26672
26518
  output3.push(chalk40__default.default.white.bold("MARIA - Minimal API, Maximum Power"));
26673
26519
  output3.push("");
26674
- output3.push(chalk40__default.default.white("\u{1F3AF} Revolutionary AI Development Platform:"));
26520
+ output3.push(chalk40__default.default.white("Revolutionary AI Development Platform:"));
26675
26521
  output3.push(" \u2022 Natural Language Code Operations");
26676
26522
  output3.push(" \u2022 Graph RAG Knowledge System");
26677
26523
  output3.push(" \u2022 Dual Memory Architecture");
26678
26524
  output3.push(" \u2022 Enterprise-Grade Security");
26679
26525
  output3.push(" \u2022 Multimodal AI Generation");
26680
26526
  output3.push("");
26681
- output3.push(chalk40__default.default.white("\u{1F31F} Key Features:"));
26527
+ output3.push(chalk40__default.default.white("Key Features:"));
26682
26528
  output3.push(" \u2022 /code - Natural language coding");
26683
26529
  output3.push(" \u2022 68+ Slash Commands");
26684
26530
  output3.push(" \u2022 8 AI Provider Support");
26685
26531
  output3.push(" \u2022 Business Operations Suite");
26686
26532
  output3.push(" \u2022 Real-time Streaming");
26687
26533
  output3.push("");
26688
- output3.push(chalk40__default.default.white("\u{1F468}\u200D\u{1F4BB} Created by:"));
26534
+ output3.push(chalk40__default.default.white("Created by:"));
26689
26535
  output3.push(" \u2022 Bonginkan Team");
26690
26536
  output3.push(" \u2022 Enterprise AI Solutions");
26691
26537
  output3.push("");
26692
- output3.push(chalk40__default.default.white("\u{1F517} Links:"));
26538
+ output3.push(chalk40__default.default.white("Links:"));
26693
26539
  output3.push(chalk40__default.default.blue(" Website: https://maria-code.ai"));
26694
26540
  output3.push(chalk40__default.default.blue(" Company: https://bonginkan.ai"));
26695
26541
  output3.push(chalk40__default.default.blue(" Discord: https://discord.gg/SMSmSGcEQy"));
26696
26542
  output3.push(chalk40__default.default.blue(" GitHub: https://github.com/bonginkan/maria"));
26697
26543
  output3.push(chalk40__default.default.blue(" NPM: https://www.npmjs.com/package/@bonginkan/maria"));
26698
26544
  output3.push("");
26699
- output3.push(chalk40__default.default.white("\u{1F4C4} License: MIT"));
26700
- output3.push(chalk40__default.default.white("\u{1F3D7}\uFE0F Built with: TypeScript, Node.js, React"));
26545
+ output3.push(chalk40__default.default.white("License: MIT"));
26546
+ output3.push(chalk40__default.default.white("Built with: TypeScript, Node.js, React"));
26701
26547
  output3.push("");
26702
- output3.push(chalk40__default.default.green("Thank you for using MARIA! \u{1F680}"));
26548
+ output3.push(chalk40__default.default.green("Thank you for using MARIA!"));
26703
26549
  output3.push("");
26704
26550
  return {
26705
26551
  success: true,
@@ -38954,10 +38800,11 @@ var NovelCommand, novel_command_default;
38954
38800
  var init_novel_command = __esm({
38955
38801
  "src/slash-commands/categories/creative/novel.command.ts"() {
38956
38802
  init_base_command();
38957
- init_code_utils();
38958
38803
  init_api_caller();
38804
+ init_code_utils();
38959
38805
  init_NovelArgumentInference();
38960
38806
  init_animations();
38807
+ init_session();
38961
38808
  NovelCommand = class extends BaseCommand {
38962
38809
  name = "novel";
38963
38810
  category = "creative";
@@ -39053,6 +38900,12 @@ var init_novel_command = __esm({
39053
38900
  await writeText(planPath, plan);
39054
38901
  if (planOnly) {
39055
38902
  const msg2 = [`Saved plan to ${planPath}`, "", "Files:", `- ${planPath}`].join("\n");
38903
+ try {
38904
+ const summary = `Novel plan saved: ${path11__namespace.relative(root, planPath)}`;
38905
+ new SessionMemory(root).save({ taskId: "llm.novel", resumeAt: (/* @__PURE__ */ new Date()).toISOString(), context: { summary, decisions: [], artifacts: [planPath], refs: [planPath] } });
38906
+ await callAPI("/api/v1/snapshots", { method: "POST", body: { projectId: "default", taskId: "llm.novel", summary, decisions: [], artifacts: [path11__namespace.relative(root, planPath)], refs: [path11__namespace.relative(root, planPath)], resumePrompt: ideaText } });
38907
+ } catch {
38908
+ }
39056
38909
  return this.success(msg2, { dir: novelDir, plan: planPath });
39057
38910
  }
39058
38911
  const chapterObjs = await (async () => {
@@ -39087,6 +38940,13 @@ ${ch.content}` : ch.content;
39087
38940
  "Files:",
39088
38941
  ...saved.map((p) => `- ${p}`)
39089
38942
  ].join("\n");
38943
+ try {
38944
+ const rels = saved.map((p) => path11__namespace.relative(root, p));
38945
+ const summary = `Novel generated: ${title}`;
38946
+ new SessionMemory(root).save({ taskId: "llm.novel", resumeAt: (/* @__PURE__ */ new Date()).toISOString(), context: { summary, decisions: [], artifacts: rels, refs: rels } });
38947
+ await callAPI("/api/v1/snapshots", { method: "POST", body: { projectId: "default", taskId: "llm.novel", summary, decisions: [], artifacts: rels, refs: rels, resumePrompt: ideaText } });
38948
+ } catch {
38949
+ }
39090
38950
  return this.success(msg, { dir: novelDir, files: saved });
39091
38951
  }
39092
38952
  };
@@ -41854,11 +41714,12 @@ var LANGUAGE_EXTENSIONS, CodeCommand, codeCommand, metadata3;
41854
41714
  var init_code_command = __esm({
41855
41715
  "src/slash-commands/categories/code/code.command.ts"() {
41856
41716
  init_base_command();
41857
- init_api_caller();
41858
41717
  init_rate_limit_handler();
41859
41718
  init_animations();
41860
41719
  init_code_utils();
41861
41720
  init_ArgumentInference();
41721
+ init_session();
41722
+ init_api_caller();
41862
41723
  LANGUAGE_EXTENSIONS = {
41863
41724
  javascript: ".js",
41864
41725
  typescript: ".ts",
@@ -42022,6 +41883,12 @@ var init_code_command = __esm({
42022
41883
  const outPath = path66.join(plansDir, fileName);
42023
41884
  await fs54.writeFile(outPath, md.join("\n") + "\n", "utf8");
42024
41885
  const rel = path66.relative(root, outPath);
41886
+ try {
41887
+ const summary = `Code plan saved: ${rel}`;
41888
+ new SessionMemory(root).save({ taskId: "llm.code", resumeAt: (/* @__PURE__ */ new Date()).toISOString(), context: { summary, decisions: [], artifacts: [rel], refs: [rel] } });
41889
+ await callAPI("/api/v1/snapshots", { method: "POST", body: { projectId: "default", taskId: "llm.code", summary, decisions: [], artifacts: [rel], refs: [rel], resumePrompt: request } });
41890
+ } catch {
41891
+ }
42025
41892
  return this.success(`Code plan saved: ${rel}`);
42026
41893
  }
42027
41894
  const detail = res?.detailLines;
@@ -42029,6 +41896,14 @@ var init_code_command = __esm({
42029
41896
  return this.success(detail.join("\n"));
42030
41897
  }
42031
41898
  const out = Array.isArray(res?.summaryLines) ? res.summaryLines.join("\n") : "";
41899
+ try {
41900
+ const artifacts = [];
41901
+ const refs = [];
41902
+ const summary = out || "Code generation completed";
41903
+ new SessionMemory(root).save({ taskId: "llm.code", resumeAt: (/* @__PURE__ */ new Date()).toISOString(), context: { summary, decisions: [], artifacts, refs } });
41904
+ await callAPI("/api/v1/snapshots", { method: "POST", body: { projectId: "default", taskId: "llm.code", summary, decisions: [], artifacts, refs, resumePrompt: request } });
41905
+ } catch {
41906
+ }
42032
41907
  return this.success(out);
42033
41908
  } finally {
42034
41909
  if (startedLocalSpinner && spinner) {
@@ -42708,6 +42583,218 @@ var init_resume_plan = __esm({
42708
42583
  "src/memory/resume-plan.ts"() {
42709
42584
  }
42710
42585
  });
42586
+ function assertSnapshot(data) {
42587
+ const res = SnapshotZ.safeParse(data);
42588
+ if (!res.success) {
42589
+ const details = res.error.issues.map((i2) => `${i2.path.join(".") || "<root>"} ${i2.message}`).join(" | ");
42590
+ throw new ValidationError2(`Invalid snapshot: ${details}`);
42591
+ }
42592
+ }
42593
+ var SnapshotZ, ValidationError2;
42594
+ var init_validators = __esm({
42595
+ "src/memory/validators.ts"() {
42596
+ SnapshotZ = zod.z.object({
42597
+ snapshotVersion: zod.z.literal(1),
42598
+ projectId: zod.z.string().optional(),
42599
+ taskId: zod.z.string().min(1),
42600
+ timestamp: zod.z.string().datetime(),
42601
+ // ISO-8601 UTC expected
42602
+ summary: zod.z.string().min(1),
42603
+ decisions: zod.z.array(zod.z.string()).optional(),
42604
+ artifacts: zod.z.array(zod.z.string()).optional(),
42605
+ links: zod.z.array(
42606
+ zod.z.object({
42607
+ type: zod.z.enum(["doc", "fs", "url", "firestore"]),
42608
+ ref: zod.z.string().min(1)
42609
+ })
42610
+ ).optional(),
42611
+ hash: zod.z.string().optional(),
42612
+ score: zod.z.object({
42613
+ testsPassRate: zod.z.number().min(0).max(1).optional(),
42614
+ coverage: zod.z.number().min(0).max(1).optional()
42615
+ }).optional(),
42616
+ tags: zod.z.array(zod.z.string()).optional(),
42617
+ resumePrompt: zod.z.string().optional()
42618
+ });
42619
+ ValidationError2 = class extends Error {
42620
+ constructor(message) {
42621
+ super(message);
42622
+ this.name = "ValidationError";
42623
+ }
42624
+ };
42625
+ }
42626
+ });
42627
+ function storeFactory(ctx2) {
42628
+ const mode = process.env.MARIA_STORE || "firestore";
42629
+ if (process.env.MARIA_DEBUG === "1") ctx2.logger?.info?.(`[resume] store=${mode}`);
42630
+ if (mode === "firestore") {
42631
+ try {
42632
+ const uid = ctx2.uid;
42633
+ const projectId = ctx2.projectId || "default";
42634
+ if (uid) return new HttpSnapshotStore(projectId);
42635
+ const db = ctx2.firestore || tryGetFirestore();
42636
+ if (db) return new FirestoreSnapshotStore(db);
42637
+ console.warn("[resume] http/firestore not available; falling back to mock store");
42638
+ } catch (e2) {
42639
+ console.warn("[resume] firestore error; falling back to mock store:", e2?.message || e2);
42640
+ }
42641
+ }
42642
+ return new MockSnapshotStore(ctx2.cwd || process.cwd());
42643
+ }
42644
+ function tryGetFirestore() {
42645
+ try {
42646
+ const admin = __require("firebase-admin");
42647
+ if (!admin.apps || admin.apps.length === 0) {
42648
+ try {
42649
+ admin.initializeApp();
42650
+ } catch {
42651
+ }
42652
+ }
42653
+ const { getFirestore } = __require("firebase-admin/firestore");
42654
+ return getFirestore();
42655
+ } catch {
42656
+ return null;
42657
+ }
42658
+ }
42659
+ var MockSnapshotStore, FirestoreSnapshotStore, HttpSnapshotStore;
42660
+ var init_firestore = __esm({
42661
+ "src/memory/firestore.ts"() {
42662
+ init_validators();
42663
+ MockSnapshotStore = class {
42664
+ constructor(cwd2 = process.cwd()) {
42665
+ this.cwd = cwd2;
42666
+ }
42667
+ async getLatest(_projectId, limit = 1) {
42668
+ const s2 = this.readLocal();
42669
+ return s2.slice(0, limit);
42670
+ }
42671
+ async getByTask(_projectId, taskId, limit = 5) {
42672
+ const s2 = this.readLocal().filter((x2) => x2.taskId === taskId);
42673
+ return s2.slice(0, limit);
42674
+ }
42675
+ async getByDate(_projectId, dateISO, limit = 5) {
42676
+ const s2 = this.readLocal().filter((x2) => x2.timestamp?.startsWith(dateISO));
42677
+ return s2.slice(0, limit);
42678
+ }
42679
+ readLocal() {
42680
+ const sessionPath = path11__namespace.default.join(this.cwd, ".maria", "memory", "session.json");
42681
+ const candidates = [];
42682
+ try {
42683
+ const raw = JSON.parse(fs20__namespace.default.readFileSync(sessionPath, "utf8"));
42684
+ const ctx2 = raw?.context;
42685
+ if (ctx2?.summary) {
42686
+ const synthetic = {
42687
+ snapshotVersion: 1,
42688
+ projectId: "default",
42689
+ taskId: raw.taskId || "resume.task",
42690
+ timestamp: raw.resumeAt || (/* @__PURE__ */ new Date()).toISOString(),
42691
+ summary: ctx2.summary,
42692
+ decisions: ctx2.decisions || [],
42693
+ artifacts: ctx2.artifacts || [],
42694
+ links: (ctx2.refs || []).map((r2) => ({ type: "url", ref: r2 }))
42695
+ };
42696
+ assertSnapshot(synthetic);
42697
+ const snap = synthetic;
42698
+ candidates.push(snap);
42699
+ }
42700
+ } catch {
42701
+ }
42702
+ if (candidates.length === 0) {
42703
+ const fallback2 = {
42704
+ snapshotVersion: 1,
42705
+ projectId: "default",
42706
+ taskId: "example.task",
42707
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
42708
+ summary: "\u524D\u56DE\u4F5C\u696D\u306E\u7D9A\u304D\u3002/code \u3092\u518D\u958B\u3067\u304D\u308B\u3088\u3046\u306B\u6E96\u5099\u6E08\u307F\u3002",
42709
+ decisions: ["\u81EA\u52D5\u30C6\u30B9\u30C8\u306F\u6700\u4F4E\u9650", "\u7834\u58CA\u7684\u5909\u66F4\u306F\u3057\u306A\u3044"],
42710
+ artifacts: ["README.md"],
42711
+ links: [{ type: "doc", ref: "docs/RESUME_FUNCTION_DESIGN.md" }],
42712
+ resumePrompt: "\u6628\u65E5\u306E\u7D9A\u304D\u304B\u3089\u518D\u958B\u3057\u3066\u3001\u5DEE\u5206\u306E\u307F\u9069\u7528\u3057\u3066\u4E0B\u3055\u3044\u3002"
42713
+ };
42714
+ assertSnapshot(fallback2);
42715
+ const snap = fallback2;
42716
+ candidates.push(snap);
42717
+ }
42718
+ return candidates;
42719
+ }
42720
+ };
42721
+ FirestoreSnapshotStore = class {
42722
+ constructor(db) {
42723
+ this.db = db;
42724
+ }
42725
+ async getLatest(projectId, limit = 1) {
42726
+ const q = this.db.collectionGroup("snapshots").where("projectId", "==", projectId).orderBy("timestamp", "desc").limit(limit);
42727
+ const ss = await q.get();
42728
+ return this.validateDocs(ss.docs.map((d) => d.data()));
42729
+ }
42730
+ async getByTask(projectId, taskId, limit = 5) {
42731
+ const q = this.db.collection("projects").doc(projectId).collection("tasks").doc(taskId).collection("snapshots").orderBy("timestamp", "desc").limit(limit);
42732
+ const ss = await q.get();
42733
+ return this.validateDocs(ss.docs.map((d) => d.data()));
42734
+ }
42735
+ async getByDate(projectId, dateISO, limit = 5) {
42736
+ const start = new Date(dateISO).toISOString();
42737
+ const end = new Date(new Date(dateISO).getTime() + 24 * 60 * 60 * 1e3).toISOString();
42738
+ const q = this.db.collectionGroup("snapshots").where("projectId", "==", projectId).where("timestamp", ">=", start).where("timestamp", "<", end).orderBy("timestamp", "desc").limit(limit);
42739
+ const ss = await q.get();
42740
+ return this.validateDocs(ss.docs.map((d) => d.data()));
42741
+ }
42742
+ validateDocs(rows) {
42743
+ const out = [];
42744
+ for (const r2 of rows) {
42745
+ try {
42746
+ assertSnapshot(r2);
42747
+ out.push(r2);
42748
+ } catch {
42749
+ }
42750
+ }
42751
+ return out;
42752
+ }
42753
+ };
42754
+ HttpSnapshotStore = class {
42755
+ constructor(projectId) {
42756
+ this.projectId = projectId;
42757
+ }
42758
+ async fetchJson(pathname) {
42759
+ const { callAPI: callAPI2 } = await Promise.resolve().then(() => (init_api_caller(), api_caller_exports));
42760
+ return await callAPI2(pathname, { method: "GET" });
42761
+ }
42762
+ async getLatest(projectId, limit = 5) {
42763
+ const pid = projectId || this.projectId || "default";
42764
+ const resp = await this.fetchJson(`/api/v1/get-snapshots?projectId=${encodeURIComponent(pid)}&limit=${limit}`);
42765
+ const arr = Array.isArray(resp?.data?.snapshots) ? resp.data.snapshots : [];
42766
+ return this.validate(arr);
42767
+ }
42768
+ async getByTask(projectId, taskId, limit = 5) {
42769
+ const pid = projectId || this.projectId || "default";
42770
+ const resp = await this.fetchJson(`/api/v1/get-snapshots?projectId=${encodeURIComponent(pid)}&taskId=${encodeURIComponent(taskId)}&limit=${limit}`);
42771
+ const arr = Array.isArray(resp?.data?.snapshots) ? resp.data.snapshots : [];
42772
+ return this.validate(arr);
42773
+ }
42774
+ async getByDate(projectId, dateISO, limit = 5) {
42775
+ const pid = projectId || this.projectId || "default";
42776
+ const resp = await this.fetchJson(`/api/v1/get-snapshots?projectId=${encodeURIComponent(pid)}&date=${encodeURIComponent(dateISO)}&limit=${limit}`);
42777
+ const arr = Array.isArray(resp?.data?.snapshots) ? resp.data.snapshots : [];
42778
+ return this.validate(arr);
42779
+ }
42780
+ validate(rows) {
42781
+ const out = [];
42782
+ for (const r2 of rows) {
42783
+ try {
42784
+ assertSnapshot(r2);
42785
+ out.push(r2);
42786
+ } catch {
42787
+ }
42788
+ }
42789
+ if (out.length === 0) {
42790
+ const mock = new MockSnapshotStore(process.cwd());
42791
+ return (async () => await mock.getLatest(this.projectId, 1))();
42792
+ }
42793
+ return out;
42794
+ }
42795
+ };
42796
+ }
42797
+ });
42711
42798
 
42712
42799
  // src/memory/rehydrator.ts
42713
42800
  function rehydrateSnapshot(s2, opts = {}) {
@@ -42844,27 +42931,59 @@ function truncate2(s2, n) {
42844
42931
  }
42845
42932
  function promptLine(timeoutMs = 15e3) {
42846
42933
  return new Promise((resolve19) => {
42847
- const rl = readline__namespace.default.createInterface({ input: process.stdin, output: process.stdout });
42848
- const done = (ok, line) => {
42934
+ let finished = false;
42935
+ const input3 = process.stdin;
42936
+ const wasRaw = !!input3.isRaw;
42937
+ const finish = (ok, line) => {
42938
+ if (finished) return;
42939
+ finished = true;
42849
42940
  try {
42850
- rl.close();
42941
+ input3.removeListener("keypress", onKey);
42942
+ } catch {
42943
+ }
42944
+ try {
42945
+ if (input3.isTTY) input3.setRawMode(wasRaw);
42851
42946
  } catch {
42852
42947
  }
42853
42948
  resolve19({ ok, line });
42854
42949
  };
42855
- const t2 = setTimeout(() => done(true, "1"), timeoutMs);
42856
- rl.question("\u756A\u53F7\u3092\u5165\u529B > ", (l) => {
42857
- clearTimeout(t2);
42858
- done(true, l);
42859
- });
42860
- rl.once("SIGINT", () => {
42861
- clearTimeout(t2);
42862
- done(false);
42863
- });
42864
- rl.once("close", () => {
42865
- clearTimeout(t2);
42866
- done(false);
42867
- });
42950
+ const t2 = setTimeout(() => finish(true, "1"), timeoutMs);
42951
+ try {
42952
+ process.stdout.write("Enter number > ");
42953
+ } catch {
42954
+ }
42955
+ try {
42956
+ if (input3.isTTY) input3.setRawMode(true);
42957
+ } catch {
42958
+ }
42959
+ readline__namespace.emitKeypressEvents(input3);
42960
+ let buffer = "";
42961
+ const onKey = (_str, key) => {
42962
+ if (key?.ctrl && key.name === "c") {
42963
+ clearTimeout(t2);
42964
+ finish(false);
42965
+ return;
42966
+ }
42967
+ if (key?.name === "escape") {
42968
+ clearTimeout(t2);
42969
+ finish(false);
42970
+ return;
42971
+ }
42972
+ if (key?.name === "return" || key?.name === "enter") {
42973
+ clearTimeout(t2);
42974
+ const value = buffer.trim() || "1";
42975
+ finish(true, value);
42976
+ return;
42977
+ }
42978
+ if (key?.name === "backspace") {
42979
+ buffer = buffer.slice(0, -1);
42980
+ return;
42981
+ }
42982
+ if (/^[0-9]$/.test(_str)) {
42983
+ buffer += _str;
42984
+ }
42985
+ };
42986
+ input3.on("keypress", onKey);
42868
42987
  });
42869
42988
  }
42870
42989
  async function readLastDebugStatusSafe(cwd2) {
@@ -42917,7 +43036,8 @@ var init_resume_command = __esm({
42917
43036
  const dbg = await readLastDebugStatusSafe(context2.environment.cwd);
42918
43037
  const opts = this.parseOptions(args2.raw);
42919
43038
  const projectId = "default";
42920
- const store2 = storeFactory({ cwd: context2.environment.cwd, logger: console });
43039
+ const uid = context2.user?.id || void 0;
43040
+ const store2 = storeFactory({ cwd: context2.environment.cwd, logger: console, uid, projectId });
42921
43041
  let candidates = [];
42922
43042
  if (opts.taskId) candidates = await store2.getByTask(projectId, opts.taskId, opts.limit || 5);
42923
43043
  else if (opts.date) candidates = await store2.getByDate(projectId, opts.date, opts.limit || 5);
@@ -42971,9 +43091,9 @@ var init_resume_command = __esm({
42971
43091
  context: plan.context
42972
43092
  });
42973
43093
  const lines = [];
42974
- if (dbg && (opts.debugLatest || !opts.debugList && !opts.noDebug)) {
43094
+ if (process.env.MARIA_DEBUG === "1" && dbg && (opts.debugLatest || !opts.debugList && !opts.noDebug)) {
42975
43095
  lines.push("");
42976
- lines.push("\u{1F9ED} Last debug-fix status");
43096
+ lines.push("Last debug-fix status");
42977
43097
  lines.push("".padEnd(30, "\u2550"));
42978
43098
  lines.push(`hash: ${dbg.promptHash.slice(0, 12)} \xB7 plan=${dbg.planUsed || "none"} \xB7 category=${dbg.errorCategory || (dbg.verify?.ok ? "ok" : "unknown")} \xB7 exit=${typeof dbg.exitCode === "number" ? dbg.exitCode : dbg.verify?.ok ? 0 : 1}`);
42979
43099
  if (dbg.verify && !dbg.verify.ok && dbg.verify.stage) {
@@ -42981,12 +43101,12 @@ var init_resume_command = __esm({
42981
43101
  }
42982
43102
  lines.push("");
42983
43103
  }
42984
- if (opts.debugList) {
43104
+ if (process.env.MARIA_DEBUG === "1" && opts.debugList) {
42985
43105
  const count = Number.isFinite(opts.debugLimit) ? Math.max(1, Math.min(50, Number(opts.debugLimit))) : 5;
42986
43106
  const list = await readDebugJournalListSafe(context2.environment.cwd, count);
42987
43107
  if (list.length) {
42988
43108
  lines.push("");
42989
- lines.push(`\u{1F9ED} Debug history (latest ${list.length})`);
43109
+ lines.push(`Debug history (latest ${list.length})`);
42990
43110
  lines.push("".padEnd(34, "\u2550"));
42991
43111
  for (const it of list) {
42992
43112
  const t2 = it.createdAt ? new Date(it.createdAt).toISOString().replace("T", " ").replace("Z", "Z") : "";
@@ -42997,7 +43117,7 @@ var init_resume_command = __esm({
42997
43117
  }
42998
43118
  }
42999
43119
  lines.push(`
43000
- \u{1F4CC} Resuming: ${s2.taskId}`);
43120
+ Resuming: ${s2.taskId}`);
43001
43121
  lines.push(`Summary: ${truncate2(plan.context.summary, 400)}`);
43002
43122
  if (plan.context.decisions?.length) lines.push(`Decisions: ${plan.context.decisions.join(" / ")}`);
43003
43123
  if (plan.context.artifacts?.length) lines.push(`Artifacts: ${plan.context.artifacts.slice(0, 10).join(", ")}`);
@@ -43050,7 +43170,6 @@ var init_resume_command = __esm({
43050
43170
  lines.push("\u26A0 /code execution threw \u2014 showing suggestion instead");
43051
43171
  lines.push("");
43052
43172
  }
43053
- lines.push(`\u{1F449} Next: /code "${plan.nextPrompt}" ${plan.codeFlags.join(" ")}`.trim());
43054
43173
  return this.success(lines.join("\n"), { elapsedMs: Date.now() - start });
43055
43174
  } catch (e2) {
43056
43175
  return this.error("Failed to resume", "RESUME_ERROR", e2?.message || String(e2));
@@ -43089,13 +43208,15 @@ var init_resume_command = __esm({
43089
43208
  const t2 = new Date(c.timestamp).toISOString().replace("T", " ").replace("Z", "Z");
43090
43209
  return `${idx + 1}) [${t2}] ${c.taskId} \u2014 ${head2(c.summary)}`;
43091
43210
  };
43092
- console.log("\n\u5019\u88DC\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044 (15s \u3067 1 \u3092\u63A1\u7528):");
43211
+ console.log("\nSelect a candidate (defaults to 1 after 15s):");
43093
43212
  for (let i2 = 0; i2 < cands.length; i2++) {
43094
43213
  console.log(" " + fmt(cands[i2], i2));
43095
43214
  }
43096
43215
  const ans = await promptLine(15e3);
43097
43216
  if (!ans.ok) return null;
43098
- const n = parseInt((ans.line || "1").trim(), 10);
43217
+ const raw = (ans.line || "1").trim();
43218
+ const m2 = raw.match(/\d+/);
43219
+ const n = m2 ? parseInt(m2[0], 10) : 1;
43099
43220
  if (!Number.isFinite(n) || n < 1 || n > cands.length) return cands[0];
43100
43221
  return cands[n - 1];
43101
43222
  }
@@ -55622,6 +55743,7 @@ var init_ResearchCommand = __esm({
55622
55743
  init_logger();
55623
55744
  init_api_client();
55624
55745
  init_animations();
55746
+ init_session();
55625
55747
  ResearchCommand = class extends BaseCommand {
55626
55748
  name = "research";
55627
55749
  category = "analysis";
@@ -55705,6 +55827,13 @@ var init_ResearchCommand = __esm({
55705
55827
  });
55706
55828
  }
55707
55829
  const message = lines.filter(Boolean).join("\n");
55830
+ try {
55831
+ const root = context2.environment?.cwd || process.cwd();
55832
+ const summary = "Research completed";
55833
+ new SessionMemory(root).save({ taskId: "llm.research", resumeAt: (/* @__PURE__ */ new Date()).toISOString(), context: { summary, decisions: [], artifacts: [], refs: [] } });
55834
+ await callApiJson("/api/v1/snapshots", { method: "POST", body: JSON.stringify({ projectId: "default", taskId: "llm.research", summary, decisions: [], artifacts: [], refs: [], resumePrompt: (_args.raw || []).join(" ") }), headers: { "Content-Type": "application/json" } });
55835
+ } catch {
55836
+ }
55708
55837
  const result = this.success(message);
55709
55838
  result.metadata = { executionTime: Date.now() - startedAt };
55710
55839
  this.logExecution(_args, context2, result);
@@ -59989,9 +60118,10 @@ var init_evaluate_command = __esm({
59989
60118
  init_base_command();
59990
60119
  init_logger();
59991
60120
  init_EvaluationOrchestrator();
59992
- init_api_caller();
59993
60121
  init_animations();
59994
60122
  init_ArgumentInference2();
60123
+ init_session();
60124
+ init_api_caller();
59995
60125
  EvaluateCommand = class extends BaseCommand {
59996
60126
  name = "evaluate";
59997
60127
  category = "evaluation";
@@ -60259,6 +60389,13 @@ ${options["code"] || inferred.code}` : void 0
60259
60389
  const finalText = uploadNote ? `${uploadNote}
60260
60390
 
60261
60391
  ${content}` : content;
60392
+ try {
60393
+ const summary = `Evaluation assess completed: total=${Math.round(result.totalScore * 100)}/100`;
60394
+ const rel = path11__namespace.default.relative(root, criteriaPath);
60395
+ new SessionMemory(root).save({ taskId: "llm.evaluate", resumeAt: (/* @__PURE__ */ new Date()).toISOString(), context: { summary, decisions: [], artifacts: [rel], refs: [rel] } });
60396
+ await callAPI("/api/v1/snapshots", { method: "POST", body: { projectId: "default", taskId: "llm.evaluate", summary, decisions: [], artifacts: [rel], refs: [rel], resumePrompt: rawCmd } });
60397
+ } catch {
60398
+ }
60262
60399
  return this.success(finalText, {
60263
60400
  type: "evaluation-assess",
60264
60401
  total: result.totalScore,