@pencil-agent/nano-pencil 1.10.5 → 1.10.6

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.
Files changed (275) hide show
  1. package/dist/core/agent-session.js +12 -10
  2. package/dist/core/soul-integration.d.ts +17 -0
  3. package/dist/core/soul-integration.js +72 -0
  4. package/dist/core/system-prompt.js +14 -7
  5. package/dist/main.js +28 -6
  6. package/dist/packages/nano-mem/cli.js +1 -1
  7. package/dist/packages/nano-mem/config.d.ts +16 -0
  8. package/dist/packages/nano-mem/config.js +10 -1
  9. package/dist/packages/nano-mem/consolidation.js +25 -8
  10. package/dist/packages/nano-mem/engine.d.ts +7 -1
  11. package/dist/packages/nano-mem/engine.js +181 -65
  12. package/dist/packages/nano-mem/extension.js +70 -1
  13. package/dist/packages/nano-mem/extraction.js +19 -2
  14. package/dist/packages/nano-mem/full-insights.js +6 -5
  15. package/dist/packages/nano-mem/i18n.d.ts +3 -0
  16. package/dist/packages/nano-mem/i18n.js +56 -24
  17. package/dist/packages/nano-mem/index.d.ts +3 -3
  18. package/dist/packages/nano-mem/index.js +1 -1
  19. package/dist/packages/nano-mem/insights-html.js +1 -1
  20. package/dist/packages/nano-mem/linking.js +1 -1
  21. package/dist/packages/nano-mem/scoring.d.ts +10 -1
  22. package/dist/packages/nano-mem/scoring.js +33 -0
  23. package/dist/packages/nano-mem/store.d.ts +5 -0
  24. package/dist/packages/nano-mem/store.js +40 -2
  25. package/dist/packages/nano-mem/types.d.ts +22 -2
  26. package/dist/packages/nano-mem/update.js +22 -10
  27. package/dist/packages/nanosoul/src/config.js +11 -0
  28. package/dist/packages/nanosoul/src/evolution.d.ts +10 -1
  29. package/dist/packages/nanosoul/src/evolution.js +89 -0
  30. package/dist/packages/nanosoul/src/index.d.ts +2 -2
  31. package/dist/packages/nanosoul/src/index.js +1 -1
  32. package/dist/packages/nanosoul/src/injection.d.ts +23 -30
  33. package/dist/packages/nanosoul/src/injection.js +368 -259
  34. package/dist/packages/nanosoul/src/manager.d.ts +4 -0
  35. package/dist/packages/nanosoul/src/manager.js +30 -2
  36. package/dist/packages/nanosoul/src/store.js +21 -0
  37. package/dist/packages/nanosoul/src/types.d.ts +52 -0
  38. package/node_modules/@aws-sdk/client-bedrock-runtime/package.json +50 -46
  39. package/node_modules/@aws-sdk/core/dist-cjs/index.js +7 -15
  40. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +7 -15
  41. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeDeserializer.js +2 -8
  42. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeDeserializer.js +5 -7
  43. package/node_modules/@aws-sdk/core/package.json +13 -13
  44. package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
  45. package/node_modules/@aws-sdk/credential-provider-http/package.json +10 -10
  46. package/node_modules/@aws-sdk/credential-provider-ini/package.json +14 -14
  47. package/node_modules/@aws-sdk/credential-provider-login/package.json +8 -8
  48. package/node_modules/@aws-sdk/credential-provider-node/package.json +12 -12
  49. package/node_modules/@aws-sdk/credential-provider-process/package.json +6 -6
  50. package/node_modules/@aws-sdk/credential-provider-sso/package.json +8 -8
  51. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -7
  52. package/node_modules/@aws-sdk/eventstream-handler-node/package.json +5 -5
  53. package/node_modules/@aws-sdk/middleware-eventstream/package.json +4 -4
  54. package/node_modules/@aws-sdk/middleware-host-header/package.json +4 -4
  55. package/node_modules/@aws-sdk/middleware-logger/package.json +3 -3
  56. package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +4 -4
  57. package/node_modules/@aws-sdk/middleware-user-agent/dist-cjs/index.js +9 -9
  58. package/node_modules/@aws-sdk/middleware-user-agent/dist-es/check-features.js +9 -9
  59. package/node_modules/@aws-sdk/middleware-user-agent/dist-types/check-features.d.ts +4 -2
  60. package/node_modules/@aws-sdk/middleware-user-agent/dist-types/ts3.4/check-features.d.ts +3 -3
  61. package/node_modules/@aws-sdk/middleware-user-agent/package.json +8 -7
  62. package/node_modules/@aws-sdk/middleware-websocket/package.json +12 -12
  63. package/node_modules/@aws-sdk/nested-clients/package.json +38 -36
  64. package/node_modules/@aws-sdk/region-config-resolver/package.json +5 -5
  65. package/node_modules/@aws-sdk/token-providers/package.json +7 -7
  66. package/node_modules/@aws-sdk/types/package.json +2 -2
  67. package/node_modules/@aws-sdk/util-endpoints/package.json +5 -5
  68. package/node_modules/@aws-sdk/util-format-url/package.json +4 -4
  69. package/node_modules/@aws-sdk/util-locate-window/package.json +2 -2
  70. package/node_modules/@aws-sdk/util-user-agent-browser/package.json +3 -3
  71. package/node_modules/@aws-sdk/util-user-agent-node/package.json +5 -5
  72. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  73. package/node_modules/@google/genai/dist/genai.d.ts +643 -221
  74. package/node_modules/@google/genai/dist/index.cjs +482 -343
  75. package/node_modules/@google/genai/dist/index.mjs +482 -344
  76. package/node_modules/@google/genai/dist/index.mjs.map +1 -1
  77. package/node_modules/@google/genai/dist/node/index.cjs +483 -344
  78. package/node_modules/@google/genai/dist/node/index.mjs +483 -345
  79. package/node_modules/@google/genai/dist/node/index.mjs.map +1 -1
  80. package/node_modules/@google/genai/dist/node/node.d.ts +643 -221
  81. package/node_modules/@google/genai/dist/tokenizer/node.cjs +171 -67
  82. package/node_modules/@google/genai/dist/tokenizer/node.d.ts +96 -83
  83. package/node_modules/@google/genai/dist/tokenizer/node.mjs +171 -67
  84. package/node_modules/@google/genai/dist/tokenizer/node.mjs.map +1 -1
  85. package/node_modules/@google/genai/dist/web/index.mjs +482 -344
  86. package/node_modules/@google/genai/dist/web/index.mjs.map +1 -1
  87. package/node_modules/@google/genai/dist/web/web.d.ts +643 -221
  88. package/node_modules/@google/genai/package.json +5 -1
  89. package/node_modules/@pencil-agent/ai/dist/models.generated.d.ts +0 -51
  90. package/node_modules/@pencil-agent/ai/dist/models.generated.d.ts.map +1 -1
  91. package/node_modules/@pencil-agent/ai/dist/models.generated.js +25 -76
  92. package/node_modules/@pencil-agent/ai/dist/models.generated.js.map +1 -1
  93. package/node_modules/@pencil-agent/ai/package.json +1 -1
  94. package/node_modules/@smithy/abort-controller/package.json +2 -2
  95. package/node_modules/@smithy/config-resolver/package.json +6 -6
  96. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +1 -1
  97. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +1 -1
  98. package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +1 -1
  99. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +1 -1
  100. package/node_modules/@smithy/core/package.json +11 -11
  101. package/node_modules/@smithy/credential-provider-imds/package.json +5 -5
  102. package/node_modules/@smithy/eventstream-codec/package.json +4 -4
  103. package/node_modules/@smithy/eventstream-serde-browser/package.json +3 -3
  104. package/node_modules/@smithy/eventstream-serde-config-resolver/package.json +2 -2
  105. package/node_modules/@smithy/eventstream-serde-node/package.json +3 -3
  106. package/node_modules/@smithy/eventstream-serde-universal/package.json +4 -4
  107. package/node_modules/@smithy/fetch-http-handler/package.json +6 -6
  108. package/node_modules/@smithy/hash-node/package.json +4 -4
  109. package/node_modules/@smithy/invalid-dependency/package.json +2 -2
  110. package/node_modules/@smithy/is-array-buffer/package.json +2 -2
  111. package/node_modules/@smithy/middleware-content-length/package.json +3 -3
  112. package/node_modules/@smithy/middleware-endpoint/package.json +8 -8
  113. package/node_modules/@smithy/middleware-retry/package.json +9 -9
  114. package/node_modules/@smithy/middleware-serde/package.json +3 -3
  115. package/node_modules/@smithy/middleware-stack/package.json +2 -2
  116. package/node_modules/@smithy/node-config-provider/package.json +4 -4
  117. package/node_modules/@smithy/node-http-handler/package.json +5 -5
  118. package/node_modules/@smithy/property-provider/package.json +2 -2
  119. package/node_modules/@smithy/protocol-http/package.json +2 -2
  120. package/node_modules/@smithy/querystring-builder/package.json +3 -3
  121. package/node_modules/@smithy/querystring-parser/package.json +2 -2
  122. package/node_modules/@smithy/service-error-classification/package.json +2 -2
  123. package/node_modules/@smithy/shared-ini-file-loader/package.json +2 -2
  124. package/node_modules/@smithy/signature-v4/package.json +8 -8
  125. package/node_modules/@smithy/smithy-client/package.json +7 -7
  126. package/node_modules/@smithy/url-parser/package.json +3 -3
  127. package/node_modules/@smithy/util-base64/package.json +4 -4
  128. package/node_modules/@smithy/util-body-length-browser/package.json +2 -2
  129. package/node_modules/@smithy/util-body-length-node/package.json +2 -2
  130. package/node_modules/@smithy/util-buffer-from/package.json +3 -3
  131. package/node_modules/@smithy/util-config-provider/package.json +2 -2
  132. package/node_modules/@smithy/util-defaults-mode-browser/package.json +4 -4
  133. package/node_modules/@smithy/util-defaults-mode-node/package.json +7 -7
  134. package/node_modules/@smithy/util-endpoints/package.json +3 -3
  135. package/node_modules/@smithy/util-hex-encoding/package.json +2 -2
  136. package/node_modules/@smithy/util-middleware/package.json +2 -2
  137. package/node_modules/@smithy/util-retry/package.json +3 -3
  138. package/node_modules/@smithy/util-stream/package.json +8 -8
  139. package/node_modules/@smithy/util-uri-escape/package.json +2 -2
  140. package/node_modules/@smithy/util-utf8/package.json +3 -3
  141. package/node_modules/@smithy/uuid/package.json +2 -2
  142. package/node_modules/@types/node/README.md +2 -2
  143. package/node_modules/@types/node/assert/strict.d.ts +11 -5
  144. package/node_modules/@types/node/assert.d.ts +171 -48
  145. package/node_modules/@types/node/async_hooks.d.ts +8 -28
  146. package/node_modules/@types/node/buffer.buffer.d.ts +7 -1
  147. package/node_modules/@types/node/buffer.d.ts +168 -44
  148. package/node_modules/@types/node/child_process.d.ts +70 -22
  149. package/node_modules/@types/node/cluster.d.ts +332 -240
  150. package/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
  151. package/node_modules/@types/node/compatibility/index.d.ts +9 -0
  152. package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
  153. package/node_modules/@types/node/compatibility/iterators.d.ts +0 -1
  154. package/node_modules/@types/node/console.d.ts +350 -49
  155. package/node_modules/@types/node/constants.d.ts +4 -3
  156. package/node_modules/@types/node/crypto.d.ts +1110 -630
  157. package/node_modules/@types/node/dgram.d.ts +51 -15
  158. package/node_modules/@types/node/diagnostics_channel.d.ts +6 -4
  159. package/node_modules/@types/node/dns/promises.d.ts +4 -4
  160. package/node_modules/@types/node/dns.d.ts +133 -132
  161. package/node_modules/@types/node/domain.d.ts +17 -13
  162. package/node_modules/@types/node/events.d.ts +724 -802
  163. package/node_modules/@types/node/fs/promises.d.ts +9 -43
  164. package/node_modules/@types/node/fs.d.ts +411 -626
  165. package/node_modules/@types/node/globals.d.ts +30 -8
  166. package/node_modules/@types/node/globals.typedarray.d.ts +0 -63
  167. package/node_modules/@types/node/http.d.ts +265 -343
  168. package/node_modules/@types/node/http2.d.ts +715 -551
  169. package/node_modules/@types/node/https.d.ts +239 -65
  170. package/node_modules/@types/node/index.d.ts +6 -24
  171. package/node_modules/@types/node/inspector.d.ts +62 -33
  172. package/node_modules/@types/node/inspector.generated.d.ts +10 -184
  173. package/node_modules/@types/node/module.d.ts +124 -52
  174. package/node_modules/@types/node/net.d.ts +190 -66
  175. package/node_modules/@types/node/os.d.ts +11 -12
  176. package/node_modules/@types/node/package.json +3 -13
  177. package/node_modules/@types/node/path.d.ts +133 -120
  178. package/node_modules/@types/node/perf_hooks.d.ts +643 -318
  179. package/node_modules/@types/node/process.d.ts +131 -203
  180. package/node_modules/@types/node/punycode.d.ts +5 -5
  181. package/node_modules/@types/node/querystring.d.ts +4 -4
  182. package/node_modules/@types/node/readline/promises.d.ts +3 -3
  183. package/node_modules/@types/node/readline.d.ts +120 -67
  184. package/node_modules/@types/node/repl.d.ts +100 -87
  185. package/node_modules/@types/node/sea.d.ts +1 -10
  186. package/node_modules/@types/node/sqlite.d.ts +18 -252
  187. package/node_modules/@types/node/stream/consumers.d.ts +10 -10
  188. package/node_modules/@types/node/stream/promises.d.ts +15 -136
  189. package/node_modules/@types/node/stream/web.d.ts +502 -176
  190. package/node_modules/@types/node/stream.d.ts +475 -571
  191. package/node_modules/@types/node/string_decoder.d.ts +4 -4
  192. package/node_modules/@types/node/test.d.ts +178 -255
  193. package/node_modules/@types/node/timers/promises.d.ts +4 -4
  194. package/node_modules/@types/node/timers.d.ts +132 -4
  195. package/node_modules/@types/node/tls.d.ts +224 -103
  196. package/node_modules/@types/node/trace_events.d.ts +9 -9
  197. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +7 -1
  198. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -2
  199. package/node_modules/@types/node/ts5.6/index.d.ts +6 -26
  200. package/node_modules/@types/node/tty.d.ts +16 -58
  201. package/node_modules/@types/node/url.d.ts +573 -108
  202. package/node_modules/@types/node/util.d.ts +1086 -142
  203. package/node_modules/@types/node/v8.d.ts +6 -69
  204. package/node_modules/@types/node/vm.d.ts +72 -280
  205. package/node_modules/@types/node/wasi.d.ts +4 -25
  206. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +2 -27
  207. package/node_modules/@types/node/web-globals/events.d.ts +0 -9
  208. package/node_modules/@types/node/web-globals/fetch.d.ts +0 -14
  209. package/node_modules/@types/node/web-globals/navigator.d.ts +0 -3
  210. package/node_modules/@types/node/worker_threads.d.ts +333 -266
  211. package/node_modules/@types/node/zlib.d.ts +74 -9
  212. package/node_modules/undici-types/agent.d.ts +12 -13
  213. package/node_modules/undici-types/api.d.ts +26 -26
  214. package/node_modules/undici-types/balanced-pool.d.ts +12 -13
  215. package/node_modules/undici-types/client.d.ts +19 -19
  216. package/node_modules/undici-types/connector.d.ts +2 -2
  217. package/node_modules/undici-types/cookies.d.ts +0 -2
  218. package/node_modules/undici-types/diagnostics-channel.d.ts +10 -18
  219. package/node_modules/undici-types/dispatcher.d.ts +103 -123
  220. package/node_modules/undici-types/env-http-proxy-agent.d.ts +3 -4
  221. package/node_modules/undici-types/errors.d.ts +54 -66
  222. package/node_modules/undici-types/eventsource.d.ts +4 -9
  223. package/node_modules/undici-types/fetch.d.ts +20 -22
  224. package/node_modules/undici-types/file.d.ts +39 -0
  225. package/node_modules/undici-types/filereader.d.ts +54 -0
  226. package/node_modules/undici-types/formdata.d.ts +7 -7
  227. package/node_modules/undici-types/global-dispatcher.d.ts +4 -4
  228. package/node_modules/undici-types/global-origin.d.ts +5 -5
  229. package/node_modules/undici-types/handlers.d.ts +8 -8
  230. package/node_modules/undici-types/header.d.ts +1 -157
  231. package/node_modules/undici-types/index.d.ts +47 -64
  232. package/node_modules/undici-types/interceptors.d.ts +8 -64
  233. package/node_modules/undici-types/mock-agent.d.ts +18 -36
  234. package/node_modules/undici-types/mock-client.d.ts +4 -6
  235. package/node_modules/undici-types/mock-errors.d.ts +3 -3
  236. package/node_modules/undici-types/mock-interceptor.d.ts +20 -21
  237. package/node_modules/undici-types/mock-pool.d.ts +4 -6
  238. package/node_modules/undici-types/package.json +1 -1
  239. package/node_modules/undici-types/patch.d.ts +4 -0
  240. package/node_modules/undici-types/pool-stats.d.ts +8 -8
  241. package/node_modules/undici-types/pool.d.ts +13 -15
  242. package/node_modules/undici-types/proxy-agent.d.ts +4 -5
  243. package/node_modules/undici-types/readable.d.ts +16 -19
  244. package/node_modules/undici-types/retry-agent.d.ts +1 -1
  245. package/node_modules/undici-types/retry-handler.d.ts +10 -19
  246. package/node_modules/undici-types/util.d.ts +3 -3
  247. package/node_modules/undici-types/webidl.d.ts +29 -142
  248. package/node_modules/undici-types/websocket.d.ts +10 -46
  249. package/package.json +2 -7
  250. package/node_modules/@types/node/inspector/promises.d.ts +0 -41
  251. package/node_modules/@types/node/path/posix.d.ts +0 -8
  252. package/node_modules/@types/node/path/win32.d.ts +0 -8
  253. package/node_modules/@types/node/quic.d.ts +0 -910
  254. package/node_modules/@types/node/test/reporters.d.ts +0 -96
  255. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +0 -71
  256. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +0 -72
  257. package/node_modules/@types/node/ts5.7/index.d.ts +0 -117
  258. package/node_modules/@types/node/util/types.d.ts +0 -558
  259. package/node_modules/@types/node/web-globals/blob.d.ts +0 -23
  260. package/node_modules/@types/node/web-globals/console.d.ts +0 -9
  261. package/node_modules/@types/node/web-globals/crypto.d.ts +0 -39
  262. package/node_modules/@types/node/web-globals/encoding.d.ts +0 -11
  263. package/node_modules/@types/node/web-globals/importmeta.d.ts +0 -13
  264. package/node_modules/@types/node/web-globals/messaging.d.ts +0 -23
  265. package/node_modules/@types/node/web-globals/performance.d.ts +0 -45
  266. package/node_modules/@types/node/web-globals/streams.d.ts +0 -115
  267. package/node_modules/@types/node/web-globals/timers.d.ts +0 -44
  268. package/node_modules/@types/node/web-globals/url.d.ts +0 -24
  269. package/node_modules/undici-types/cache-interceptor.d.ts +0 -173
  270. package/node_modules/undici-types/client-stats.d.ts +0 -15
  271. package/node_modules/undici-types/h2c-client.d.ts +0 -73
  272. package/node_modules/undici-types/mock-call-history.d.ts +0 -111
  273. package/node_modules/undici-types/round-robin-pool.d.ts +0 -41
  274. package/node_modules/undici-types/snapshot-agent.d.ts +0 -109
  275. package/node_modules/undici-types/utility.d.ts +0 -7
@@ -28,7 +28,7 @@ import { ExtensionRunner, wrapRegisteredTools, wrapToolsWithExtensions, } from "
28
28
  import { expandPromptTemplate, } from "./prompt-templates.js";
29
29
  import { getLatestCompactionEntry } from "./session-manager.js";
30
30
  import { BUILTIN_SLASH_COMMANDS, } from "./slash-commands.js";
31
- import { toSoulContext } from "./soul-integration.js";
31
+ import { toSoulContext, extractSessionContext } from "./soul-integration.js";
32
32
  import { buildSystemPrompt } from "./system-prompt.js";
33
33
  import { createAllTools } from "./tools/index.js";
34
34
  /**
@@ -225,10 +225,11 @@ export class AgentSession {
225
225
  if (this._soulManager) {
226
226
  const outcome = msg.stopReason === "error" ? "failure" : "success";
227
227
  const project = this._cwd.split(/[/\\]/).pop() || "unknown";
228
- const context = toSoulContext(project, [], 0.5, {});
228
+ const { tags, complexity, toolUsage } = extractSessionContext(this.state.messages, this._cwd);
229
+ const context = toSoulContext(project, tags, complexity, toolUsage);
229
230
  void this._soulManager
230
231
  .recordInteraction(context, outcome, "turn")
231
- .then(() => this._soulManager.updateExpertise(project, [], outcome === "success"))
232
+ .then(() => this._soulManager.updateExpertise(project, tags, outcome === "success"))
232
233
  .catch(() => { });
233
234
  }
234
235
  }
@@ -512,13 +513,14 @@ export class AgentSession {
512
513
  let soulInjection;
513
514
  if (this._soulManager) {
514
515
  try {
515
- soulInjection = this._soulManager.generateInjection({
516
- project: this._cwd.split("/").pop() || "unknown",
517
- tags: [],
518
- complexity: 0.5,
519
- toolUsage: {},
520
- timestamp: new Date(),
521
- });
516
+ const project = this._cwd.split(/[/\\]/).pop() || "unknown";
517
+ const { tags, complexity, toolUsage } = extractSessionContext(this.state.messages, this._cwd);
518
+ soulInjection = this._soulManager.generateInjection(toSoulContext(project, tags, complexity, toolUsage));
519
+ // Bridge Soul memory expression style to NanoMem via env var
520
+ const memDirective = this._soulManager.generateMemoryExpressionDirective?.();
521
+ if (memDirective) {
522
+ process.env.NANOSOUL_MEMORY_STYLE = memDirective;
523
+ }
522
524
  }
523
525
  catch (error) {
524
526
  console.warn("Failed to generate Soul injection:", error);
@@ -26,6 +26,11 @@ export declare function getSoulConfig(): {
26
26
  min: number;
27
27
  max: number;
28
28
  };
29
+ speakingStyleLimits: {
30
+ maxDelta: number;
31
+ min: number;
32
+ max: number;
33
+ };
29
34
  memoryRetention: {
30
35
  successes: number;
31
36
  failures: number;
@@ -53,4 +58,16 @@ export declare function toSoulContext(project: string, tags: string[], complexit
53
58
  * Check if Soul should be enabled based on options
54
59
  */
55
60
  export declare function isSoulEnabled(options: CreateAgentSessionOptions): boolean;
61
+ /**
62
+ * Extract rich context from recent session messages for Soul injection.
63
+ * Scans tool calls for tool usage counts and infers tags from file extensions and tool names.
64
+ */
65
+ export declare function extractSessionContext(messages: Array<{
66
+ role: string;
67
+ content: any;
68
+ }>, cwd: string): {
69
+ tags: string[];
70
+ complexity: number;
71
+ toolUsage: Record<string, number>;
72
+ };
56
73
  //# sourceMappingURL=soul-integration.d.ts.map
@@ -51,6 +51,11 @@ export function getSoulConfig() {
51
51
  min: 0.05,
52
52
  max: 0.5,
53
53
  },
54
+ speakingStyleLimits: {
55
+ maxDelta: 0.05,
56
+ min: 0.1,
57
+ max: 0.9,
58
+ },
54
59
  memoryRetention: {
55
60
  successes: 500,
56
61
  failures: 500,
@@ -133,4 +138,71 @@ export function isSoulEnabled(options) {
133
138
  // Can be disabled with --disable-soul flag
134
139
  return options.enableSoul !== false;
135
140
  }
141
+ /**
142
+ * Extract rich context from recent session messages for Soul injection.
143
+ * Scans tool calls for tool usage counts and infers tags from file extensions and tool names.
144
+ */
145
+ export function extractSessionContext(messages, cwd) {
146
+ const toolUsage = {};
147
+ const fileExtensions = new Set();
148
+ let totalToolCalls = 0;
149
+ let userMessageCount = 0;
150
+ // Scan recent messages (last 30 to keep it fast)
151
+ const recent = messages.slice(-30);
152
+ for (const msg of recent) {
153
+ if (msg.role === "user") {
154
+ userMessageCount++;
155
+ }
156
+ if (msg.role === "assistant" && Array.isArray(msg.content)) {
157
+ for (const block of msg.content) {
158
+ if (block.type === "toolCall") {
159
+ const name = block.toolName || block.name || "unknown";
160
+ toolUsage[name] = (toolUsage[name] || 0) + 1;
161
+ totalToolCalls++;
162
+ // Extract file extensions from tool arguments
163
+ const args = block.args || block.input;
164
+ if (args) {
165
+ const filePath = args.file_path || args.filePath || args.path || args.pattern;
166
+ if (typeof filePath === "string") {
167
+ const extMatch = filePath.match(/\.([a-zA-Z0-9]+)$/);
168
+ if (extMatch)
169
+ fileExtensions.add(extMatch[1].toLowerCase());
170
+ }
171
+ }
172
+ }
173
+ }
174
+ }
175
+ }
176
+ // Derive tags from file extensions
177
+ const extTagMap = {
178
+ ts: "typescript", tsx: "typescript", js: "javascript", jsx: "javascript",
179
+ py: "python", rs: "rust", go: "golang", java: "java",
180
+ css: "styling", scss: "styling", html: "web",
181
+ json: "config", yaml: "config", yml: "config", toml: "config",
182
+ md: "documentation", sql: "database", prisma: "database",
183
+ test: "testing", spec: "testing",
184
+ sh: "scripting", bash: "scripting",
185
+ };
186
+ const tags = new Set();
187
+ for (const ext of fileExtensions) {
188
+ if (extTagMap[ext])
189
+ tags.add(extTagMap[ext]);
190
+ }
191
+ // Infer tags from tool usage patterns
192
+ if (toolUsage["bash"] && toolUsage["bash"] > 2)
193
+ tags.add("shell-heavy");
194
+ if (toolUsage["edit"] && toolUsage["edit"] > 3)
195
+ tags.add("refactor");
196
+ if (toolUsage["write"])
197
+ tags.add("feature");
198
+ if (toolUsage["grep"] || toolUsage["find"])
199
+ tags.add("exploration");
200
+ // Estimate complexity: 0-1 based on message count + tool calls + file diversity
201
+ const complexity = Math.min(1, (userMessageCount * 0.1 + totalToolCalls * 0.03 + fileExtensions.size * 0.08));
202
+ return {
203
+ tags: Array.from(tags),
204
+ complexity: Math.round(complexity * 100) / 100,
205
+ toolUsage,
206
+ };
207
+ }
136
208
  //# sourceMappingURL=soul-integration.js.map
@@ -32,7 +32,13 @@ export function buildSystemPrompt(options = {}) {
32
32
  const contextFiles = providedContextFiles ?? [];
33
33
  const skills = providedSkills ?? [];
34
34
  if (customPrompt) {
35
- let prompt = customPrompt;
35
+ let prompt = "";
36
+ // Soul 注入在 customPrompt 场景下也放最顶部
37
+ if (soulInjection) {
38
+ prompt += soulInjection;
39
+ prompt += "\n\n---\n\n";
40
+ }
41
+ prompt += customPrompt;
36
42
  if (appendSection) {
37
43
  prompt += appendSection;
38
44
  }
@@ -99,7 +105,13 @@ export function buildSystemPrompt(options = {}) {
99
105
  guidelinesList.push("回复请简洁");
100
106
  guidelinesList.push("操作文件时请清晰标注文件路径");
101
107
  const guidelines = guidelinesList.map((g) => `- ${g}`).join("\n");
102
- let prompt = `You are the writing assistant in nanopencil. You help users by reading files, running commands, editing and writing text.
108
+ let prompt = "";
109
+ // Soul 注入放在最顶部 - 作为 AI 的身份框架,优先级最高
110
+ if (soulInjection) {
111
+ prompt += soulInjection;
112
+ prompt += "\n\n---\n\n";
113
+ }
114
+ prompt += `You are the writing assistant in nanopencil. You help users by reading files, running commands, editing and writing text.
103
115
 
104
116
  可用工具:
105
117
  ${toolsList}
@@ -119,11 +131,6 @@ ${guidelines}
119
131
  if (appendSection) {
120
132
  prompt += appendSection;
121
133
  }
122
- // 追加 Soul 注入(AI 性格)
123
- if (soulInjection) {
124
- prompt += "\n\n";
125
- prompt += soulInjection;
126
- }
127
134
  // 追加项目上下文文件
128
135
  if (contextFiles.length > 0) {
129
136
  prompt += "\n\n# 项目上下文\n\n";
package/dist/main.js CHANGED
@@ -32,6 +32,25 @@ import { InteractiveMode, runPrintMode, runRpcMode } from "./modes/index.js";
32
32
  import { initTheme, stopThemeWatcher } from "./modes/interactive/theme/theme.js";
33
33
  import { ensureNanopencilCodingPlanAuth, ensureNanopencilDefaultConfig, NANOPENCIL_DEFAULT_PROVIDER, } from "./nanopencil-defaults.js";
34
34
  import { getNanopencilDefaultExtensionPaths } from "./pencil-mem-integration.js";
35
+ // Check if running in development mode (not production)
36
+ const isDevelopment = process.env.NODE_ENV !== "production";
37
+ // In production mode, suppress Node.js DEP0190 warning (shell option in child_process)
38
+ // In development mode, all warnings are shown by default
39
+ if (!isDevelopment) {
40
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
41
+ const originalEmitWarning = process.emitWarning;
42
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
43
+ process.emitWarning = (message, options) => {
44
+ // Filter out DEP0190 warning in production
45
+ const warningType = typeof options === "object" ? options?.type : options;
46
+ const warningCode = typeof options === "object" ? options?.code : undefined;
47
+ if (warningType === "DeprecationWarning" && warningCode === "DEP0190") {
48
+ return;
49
+ }
50
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
51
+ return originalEmitWarning(message, options);
52
+ };
53
+ }
35
54
  /**
36
55
  * Read all content from piped stdin.
37
56
  * Returns undefined if stdin is a TTY (interactive terminal).
@@ -515,12 +534,15 @@ export async function main(args) {
515
534
  if (APP_NAME === "nanopencil") {
516
535
  const nanomemLoaded = extensionsResult.extensions.some((e) => e.path.includes("nano-mem"));
517
536
  const nanomemFailed = extensionsResult.errors.some((e) => e.path.includes("nano-mem"));
518
- if (!nanomemLoaded && (defaultExtPaths.length === 0 || nanomemFailed)) {
519
- console.error(chalk.dim("NanoMem (persistent memory) not loaded. Reinstall: npm install -g @pencil-agent/nano-pencil"));
520
- }
521
- else if (nanomemLoaded) {
522
- const nanomemExt = extensionsResult.extensions.find((e) => e.path.includes("nano-mem"));
523
- console.error(chalk.dim(`NanoMem extension loaded: ${nanomemExt?.path ?? "nano-mem"}`));
537
+ // Only show NanoMem status in development mode (not production)
538
+ if (isDevelopment) {
539
+ if (!nanomemLoaded && (defaultExtPaths.length === 0 || nanomemFailed)) {
540
+ console.error(chalk.dim("NanoMem (persistent memory) not loaded. Reinstall: npm install -g @pencil-agent/nano-pencil"));
541
+ }
542
+ else if (nanomemLoaded) {
543
+ const nanomemExt = extensionsResult.extensions.find((e) => e.path.includes("nano-mem"));
544
+ console.error(chalk.dim(`NanoMem extension loaded: ${nanomemExt?.path ?? "nano-mem"}`));
545
+ }
524
546
  }
525
547
  }
526
548
  // Apply pending provider registrations from extensions immediately
@@ -44,7 +44,7 @@ Usage:
44
44
  return;
45
45
  }
46
46
  for (const e of results) {
47
- console.log(`[${e.type}] ${e.id} — ${e.content.slice(0, 100)}`);
47
+ console.log(`[${e.type}] ${e.id} — ${(e.summary || e.detail || e.content || "").slice(0, 100)}`);
48
48
  }
49
49
  return;
50
50
  }
@@ -4,6 +4,20 @@
4
4
  * [POS]: Shared by engine and adapters; host products configure via this
5
5
  */
6
6
  import type { MemoryScope } from "./types.js";
7
+ export interface ProgressiveRecallConfig {
8
+ /** Score threshold for Active tier — inject full detail */
9
+ thresholdActive: number;
10
+ /** Score threshold for Cue tier — inject name + summary + id */
11
+ thresholdCue: number;
12
+ /** Budget ratio for Active tier (default 0.15 = 15%) */
13
+ budgetActive: number;
14
+ /** Budget ratio for Cue tier (default 0.70 = 70%) */
15
+ budgetCue: number;
16
+ /** Force entries created within this many hours to Active tier */
17
+ forceRecentHours: number;
18
+ /** Force entries with importance >= this value to Active tier */
19
+ forceImportanceMin: number;
20
+ }
7
21
  export interface NanomemConfig {
8
22
  memoryDir: string;
9
23
  tokenBudget: number;
@@ -41,6 +55,8 @@ export interface NanomemConfig {
41
55
  locale: "en" | "zh";
42
56
  /** Strength growth factor on each successful recall (spaced repetition) */
43
57
  strengthGrowthFactor: number;
58
+ /** Progressive recall injection configuration */
59
+ progressiveRecall: ProgressiveRecallConfig;
44
60
  }
45
61
  export declare function getConfig(overrides?: Partial<NanomemConfig>): NanomemConfig;
46
62
  //# sourceMappingURL=config.d.ts.map
@@ -24,9 +24,17 @@ const DEFAULT_HALF_LIFE = {
24
24
  pattern: 180,
25
25
  struggle: 120,
26
26
  };
27
- const DEFAULT_MAX_ENTRIES = { knowledge: 200, lessons: 100, preferences: 50, work: 80, facets: 80 };
27
+ const DEFAULT_MAX_ENTRIES = { knowledge: 1000, lessons: 500, preferences: 200, work: 400, facets: 400 };
28
28
  const DEFAULT_SCORE_WEIGHTS = { recency: 1, importance: 1, relevance: 1 };
29
29
  const DEFAULT_EVICTION_WEIGHTS = { accessFrequency: 0.4, baseImpact: 0.6 };
30
+ const DEFAULT_PROGRESSIVE_RECALL = {
31
+ thresholdActive: 0.7,
32
+ thresholdCue: 0.35,
33
+ budgetActive: 0.15,
34
+ budgetCue: 0.70,
35
+ forceRecentHours: 24,
36
+ forceImportanceMin: 9,
37
+ };
30
38
  export function getConfig(overrides) {
31
39
  const tokenBudget = Number(process.env.NANOMEM_TOKEN_BUDGET) || 6000;
32
40
  const memoryDir = process.env.NANOMEM_MEMORY_DIR || overrides?.memoryDir || join(homedir(), ".nanomem", "memory");
@@ -43,6 +51,7 @@ export function getConfig(overrides) {
43
51
  defaultScope: overrides?.defaultScope,
44
52
  locale,
45
53
  strengthGrowthFactor: overrides?.strengthGrowthFactor ?? 1.5,
54
+ progressiveRecall: overrides?.progressiveRecall ?? { ...DEFAULT_PROGRESSIVE_RECALL },
46
55
  };
47
56
  }
48
57
  //# sourceMappingURL=config.js.map
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import { PROMPTS } from "./i18n.js";
11
11
  import { extractTags } from "./scoring.js";
12
+ import { deriveNameFromContent, deriveSummaryFromContent } from "./store.js";
12
13
  function makeId() {
13
14
  return `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
14
15
  }
@@ -38,11 +39,17 @@ async function llmConsolidation(episodes, cfg, llmFn) {
38
39
  const now = new Date().toISOString();
39
40
  return items.map((item) => {
40
41
  const type = item.type === "lesson" ? "lesson" : "fact";
42
+ const detail = item.detail || item.content || "";
43
+ const name = item.name || deriveNameFromContent(detail);
44
+ const summary = item.summary || deriveSummaryFromContent(detail);
41
45
  return {
42
46
  id: makeId(),
43
47
  type,
44
- content: item.content,
45
- tags: extractTags(item.content),
48
+ name,
49
+ summary,
50
+ detail,
51
+ content: detail,
52
+ tags: extractTags(`${name} ${summary} ${detail}`),
46
53
  project: episodes[0]?.project ?? "unknown",
47
54
  importance: item.importance ?? 6,
48
55
  strength: cfg.halfLife[type] ?? 30,
@@ -71,12 +78,17 @@ function heuristicConsolidation(episodes, cfg) {
71
78
  .sort((a, b) => b[1] - a[1])
72
79
  .slice(0, 5);
73
80
  if (hotFiles.length) {
74
- const content = `Frequently modified files: ${hotFiles.map(([f, c]) => `${f} (${c}x)`).join(", ")}`;
81
+ const detail = `Frequently modified files: ${hotFiles.map(([f, c]) => `${f} (${c}x)`).join(", ")}`;
82
+ const name = deriveNameFromContent(detail);
83
+ const summary = deriveSummaryFromContent(detail);
75
84
  result.push({
76
85
  id: makeId(),
77
86
  type: "fact",
78
- content,
79
- tags: extractTags(content),
87
+ name,
88
+ summary,
89
+ detail,
90
+ content: detail,
91
+ tags: extractTags(detail),
80
92
  project: episodes[0]?.project ?? "unknown",
81
93
  importance: 5,
82
94
  strength: cfg.halfLife.fact ?? 60,
@@ -90,12 +102,17 @@ function heuristicConsolidation(episodes, cfg) {
90
102
  const allErrors = episodes.flatMap((ep) => ep.errors).filter(Boolean);
91
103
  if (allErrors.length) {
92
104
  const errorSet = [...new Set(allErrors)].slice(0, 5);
93
- const content = `Recurring issues: ${errorSet.join("; ")}`;
105
+ const detail = `Recurring issues: ${errorSet.join("; ")}`;
106
+ const name = deriveNameFromContent(detail);
107
+ const summary = deriveSummaryFromContent(detail);
94
108
  result.push({
95
109
  id: makeId(),
96
110
  type: "lesson",
97
- content,
98
- tags: extractTags(content),
111
+ name,
112
+ summary,
113
+ detail,
114
+ content: detail,
115
+ tags: extractTags(detail),
99
116
  project: episodes[0]?.project ?? "unknown",
100
117
  importance: 7,
101
118
  strength: cfg.halfLife.lesson ?? 90,
@@ -25,6 +25,12 @@ export declare class NanoMemEngine {
25
25
  saveEpisode(ep: Episode): Promise<void>;
26
26
  consolidate(): Promise<MemoryEntry[]>;
27
27
  getMemoryInjection(project: string, contextTags: string[], scope?: MemoryScope): Promise<string>;
28
+ /** Retrieve a single entry by ID (for recall_memory tool) */
29
+ getEntryById(id: string): Promise<MemoryEntry | null>;
30
+ /** Reinforce a single entry by ID (bump accessCount, lastAccessed, strength) */
31
+ reinforceEntryById(id: string): Promise<boolean>;
32
+ /** Full-text search across ALL entries including dormant (for search_all_memories tool) */
33
+ searchAllEntries(query: string, limit?: number): Promise<MemoryEntry[]>;
28
34
  getStats(): Promise<{
29
35
  knowledge: number;
30
36
  lessons: number;
@@ -62,6 +68,6 @@ export declare class NanoMemEngine {
62
68
  private reinforceEntries;
63
69
  private reinforceWork;
64
70
  private reconsolidateIfNeeded;
65
- private buildInjectionText;
71
+ private buildProgressiveInjectionText;
66
72
  }
67
73
  //# sourceMappingURL=engine.d.ts.map