@pencil-agent/nano-pencil 1.4.2 → 1.4.3

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/core/sdk.js CHANGED
@@ -252,9 +252,15 @@ export async function createAgentSession(options = {}) {
252
252
  let soulManager;
253
253
  if (isSoulEnabled(options)) {
254
254
  try {
255
- soulManager = createSoulManager();
256
- await soulManager.initialize();
257
- time("soul.initialize");
255
+ const soulMgr = await createSoulManager();
256
+ if (soulMgr) {
257
+ soulManager = soulMgr;
258
+ await soulManager.initialize();
259
+ time("soul.initialize");
260
+ }
261
+ else {
262
+ console.warn("Soul not available (nanosoul package not installed). Skipping...");
263
+ }
258
264
  }
259
265
  catch (error) {
260
266
  console.warn(`Failed to initialize Soul: ${error}`);
@@ -4,8 +4,7 @@
4
4
  * [POS]: Integration layer - bridges Soul and NanoPencil
5
5
  */
6
6
  import type { CreateAgentSessionOptions } from "../core/sdk.js";
7
- import type { InteractionContext } from "nanosoul";
8
- import { SoulManager } from "nanosoul";
7
+ import type { InteractionContext, SoulManager } from "nanosoul";
9
8
  /**
10
9
  * Default Soul configuration for NanoPencil
11
10
  */
@@ -36,8 +35,13 @@ export declare function getSoulConfig(): {
36
35
  };
37
36
  /**
38
37
  * Create a SoulManager instance for NanoPencil
38
+ * Returns null if nanosoul is not installed
39
39
  */
40
- export declare function createSoulManager(): SoulManager;
40
+ export declare function createSoulManager(): Promise<SoulManager | null>;
41
+ /**
42
+ * Check if Soul is available
43
+ */
44
+ export declare function isSoulAvailable(): boolean;
41
45
  /**
42
46
  * Convert NanoPencil context to Soul InteractionContext
43
47
  */
@@ -3,9 +3,10 @@
3
3
  * [OUTPUT]: Configured SoulManager with NanoPencil defaults
4
4
  * [POS]: Integration layer - bridges Soul and NanoPencil
5
5
  */
6
- import { SoulManager } from "nanosoul";
7
6
  import { join } from "node:path";
8
7
  import { getAgentDir } from "../config.js";
8
+ // Dynamic import to make nanosoul optional
9
+ let SoulManagerModule = null;
9
10
  /**
10
11
  * Default Soul configuration for NanoPencil
11
12
  */
@@ -38,11 +39,34 @@ export function getSoulConfig() {
38
39
  }
39
40
  /**
40
41
  * Create a SoulManager instance for NanoPencil
42
+ * Returns null if nanosoul is not installed
41
43
  */
42
- export function createSoulManager() {
43
- return new SoulManager({
44
- config: getSoulConfig(),
45
- });
44
+ export async function createSoulManager() {
45
+ try {
46
+ if (!SoulManagerModule) {
47
+ SoulManagerModule = await import("nanosoul");
48
+ }
49
+ const { SoulManager: SM } = SoulManagerModule;
50
+ return new SM({
51
+ config: getSoulConfig(),
52
+ });
53
+ }
54
+ catch {
55
+ // nanosoul not installed or failed to load
56
+ return null;
57
+ }
58
+ }
59
+ /**
60
+ * Check if Soul is available
61
+ */
62
+ export function isSoulAvailable() {
63
+ try {
64
+ require.resolve("nanosoul");
65
+ return true;
66
+ }
67
+ catch {
68
+ return false;
69
+ }
46
70
  }
47
71
  /**
48
72
  * Convert NanoPencil context to Soul InteractionContext
@@ -53,10 +77,12 @@ export function toSoulContext(project, tags, complexity, toolUsage, userFeedback
53
77
  tags,
54
78
  complexity,
55
79
  toolUsage,
56
- userFeedback: userFeedback ? {
57
- rating: userFeedback.rating || 5,
58
- comment: userFeedback.comment,
59
- } : undefined,
80
+ userFeedback: userFeedback
81
+ ? {
82
+ rating: userFeedback.rating || 5,
83
+ comment: userFeedback.comment,
84
+ }
85
+ : undefined,
60
86
  timestamp: new Date(),
61
87
  };
62
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pencil-agent/nano-pencil",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "CLI writing agent with read, bash, edit, write tools and session management. Based on pi; supports DashScope Coding Plan. Soul enabled by default for AI personality evolution.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -58,8 +58,6 @@
58
58
  "ignore": "^7.0.5",
59
59
  "marked": "^15.0.12",
60
60
  "minimatch": "^10.1.1",
61
- "nanomem": "file:./packages/nanomem",
62
- "nanosoul": "file:./packages/nanosoul",
63
61
  "proper-lockfile": "^4.1.2",
64
62
  "yaml": "^2.8.2"
65
63
  },