@themoltnet/pi-extension 0.32.1 → 0.33.0

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 (2) hide show
  1. package/dist/index.js +94 -16
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -18037,7 +18037,7 @@ function createMoltNetTools(config) {
18037
18037
  const searchEntries = defineTool({
18038
18038
  name: "moltnet_search_entries",
18039
18039
  label: "Search MoltNet Diary Entries",
18040
- description: "Hybrid (semantic + lexical) search over diary entries. Optional tags / excludeTags / entryTypes filters AND with the query; the taskFilter shorthand expands into task:* provenance tags so `taskFilter: { taskType: \"fulfill_brief\" }` returns only entries from fulfill_brief attempts. Filters apply server-side before ranking.",
18040
+ description: "Hybrid (semantic + lexical) search over diary entries. Use proactively before non-trivial investigation, code changes, review, or episodic incident capture so prior decisions and recurring failures surface before you act. Do not search randomly: pass taskFilter for task/correlation-local searches and tags or entryTypes for broader prior-knowledge searches. Optional tags / excludeTags / entryTypes filters AND with the query; the taskFilter shorthand expands into task:* provenance tags so `taskFilter: { taskType: \"fulfill_brief\" }` returns only entries from fulfill_brief attempts. Filters apply server-side before ranking.",
18041
18041
  parameters: Type.Object({
18042
18042
  query: Type.String({ description: "Natural language search query" }),
18043
18043
  limit: Type.Optional(Type.Number({ description: "Max results (default 5)" })),
@@ -18096,12 +18096,18 @@ function createMoltNetTools(config) {
18096
18096
  const createEntry = defineTool({
18097
18097
  name: "moltnet_create_entry",
18098
18098
  label: "Create MoltNet Diary Entry",
18099
- description: "Create a new diary entry to record decisions, findings, incidents, or reflections. During an active task, the entry is forced into the task diary and tagged with the task:* provenance namespace (task:id:<id>, task:type:<type>, task:attempt:<n>, plus task:correlation:<id> when set); an explicit diaryId mismatching the task diary is rejected. Use this tool — NOT `moltnet entry create` / `moltnet entry create-signed` via bash. The CLI path bypasses task-tag auto-injection and leaves entries invisible to taskFilter queries.",
18099
+ description: "Create a new diary entry to record decisions, findings, incidents, or reflections. Before creating an episodic incident entry, first call moltnet_search_entries with the title/root-cause/error/watch-for terms plus taskFilter, tags, or entryTypes filters, then reference close matches instead of creating an isolated duplicate. During an active task, the entry is forced into the task diary and tagged with the task:* provenance namespace (task:id:<id>, task:type:<type>, task:attempt:<n>, plus task:correlation:<id> when set); an explicit diaryId mismatching the task diary is rejected. Use this tool — NOT `moltnet entry create` / `moltnet entry create-signed` via bash. The CLI path bypasses task-tag auto-injection and leaves entries invisible to taskFilter queries.",
18100
18100
  parameters: Type.Object({
18101
18101
  title: Type.String({ description: "Entry title (concise, descriptive)" }),
18102
18102
  content: Type.String({ description: "Entry content (markdown)" }),
18103
18103
  tags: Type.Optional(Type.Array(Type.String(), { description: "Tags for categorization" })),
18104
18104
  importance: Type.Optional(Type.Number({ description: "Importance 1-10 (default 5)" })),
18105
+ entryType: Type.Optional(Type.Union([
18106
+ Type.Literal("episodic"),
18107
+ Type.Literal("semantic"),
18108
+ Type.Literal("procedural"),
18109
+ Type.Literal("reflection")
18110
+ ], { description: "Entry type. Use episodic for incidents, workarounds, bugs, or recurrence evidence; defaults to semantic." })),
18105
18111
  diaryId: Type.Optional(Type.String({ description: "Explicit diary id. During an active task, must match the task diary or the call is rejected. Outside a task, overrides the env-derived diary." }))
18106
18112
  }),
18107
18113
  async execute(_id, params) {
@@ -18125,7 +18131,8 @@ function createMoltNetTools(config) {
18125
18131
  title: params.title,
18126
18132
  content: params.content,
18127
18133
  tags: mergedTags,
18128
- importance: params.importance ?? 5
18134
+ importance: params.importance ?? 5,
18135
+ ...params.entryType ? { entryType: params.entryType } : {}
18129
18136
  });
18130
18137
  return {
18131
18138
  content: [{
@@ -18135,6 +18142,8 @@ function createMoltNetTools(config) {
18135
18142
  title: entry.title,
18136
18143
  createdAt: entry.createdAt,
18137
18144
  diaryId: targetDiaryId,
18145
+ entryType: entry.entryType,
18146
+ importance: entry.importance,
18138
18147
  tags: mergedTags
18139
18148
  }, null, 2)
18140
18149
  }],
@@ -18514,6 +18523,29 @@ function buildRuntimeInstructor(ctx) {
18514
18523
  " requires human approval and is unavailable in headless task runs;",
18515
18524
  " never use it for routine git/gh.",
18516
18525
  "",
18526
+ "## Proactive memory use",
18527
+ "",
18528
+ "- Before non-trivial investigation, debugging, code changes, or review,",
18529
+ " check the task diary for relevant prior knowledge instead of waiting",
18530
+ " for a human to ask. Use `moltnet_diary_tags` for cheap reconnaissance,",
18531
+ " `moltnet_list_entries` when tags or task provenance are known, and",
18532
+ " `moltnet_search_entries` for semantic similarity. Do not search",
18533
+ " randomly: pass `taskFilter` for task-local or correlation-local",
18534
+ " queries, and pass `tags` / `entryTypes` for broader prior-knowledge",
18535
+ " queries using known tags such as `incident`, `decision`, or",
18536
+ " `scope:<area>`. Broaden only after constrained searches miss.",
18537
+ "- Before creating an `episodic` incident entry, you MUST search for",
18538
+ " similar incidents using the proposed title, root cause, error text,",
18539
+ " affected subsystem, and watch-for terms, filtered by `entryTypes:",
18540
+ " [\"episodic\", \"semantic\"]` and any known `scope:*` / task provenance",
18541
+ " tags. If a close prior match exists, do not create an isolated",
18542
+ " duplicate: reference the prior entry in your response or diary content,",
18543
+ " update/link it when the new occurrence adds material evidence, or",
18544
+ " create a new recurrence entry only when the recurrence itself is",
18545
+ " important signal.",
18546
+ "- When you create a recurrence entry, include the prior matching entry",
18547
+ " id(s) in the content and explain what is new about this occurrence.",
18548
+ "",
18517
18549
  "## Diary discipline",
18518
18550
  "",
18519
18551
  `- During this task, every diary entry MUST land in \`${ctx.diaryId}\``,
@@ -20114,6 +20146,22 @@ function buildFinalOutputBlock(opts) {
20114
20146
  return lines.join("\n");
20115
20147
  }
20116
20148
  //#endregion
20149
+ //#region ../agent-runtime/src/prompts/proactive-memory.ts
20150
+ function buildProactiveMemoryWorkflowBlock() {
20151
+ return [
20152
+ "Before material work, apply the runtime instructor's proactive memory",
20153
+ "rules instead of waiting for a human prompt. Start with constrained",
20154
+ "diary context: inspect tags/list entries when task provenance or scope",
20155
+ "tags are known, then use `moltnet_search_entries` with `taskFilter`,",
20156
+ "`entryTypes`, and tags. Do not run broad unfiltered searches before",
20157
+ "constrained searches miss.",
20158
+ "",
20159
+ "For incident capture, follow the runtime instructor exactly: search",
20160
+ "for similar episodic/semantic entries first, reference close matches,",
20161
+ "and create a recurrence entry only when the repeat is useful signal."
20162
+ ].join("\n");
20163
+ }
20164
+ //#endregion
20117
20165
  //#region ../agent-runtime/src/prompts/rubric-common.ts
20118
20166
  function renderRubricCriteriaList(rubric) {
20119
20167
  return rubric.criteria.map((c, i) => `${i + 1}. **${c.id}** (weight ${c.weight}, scoring: \`${c.scoring}\`) — ${c.description}`).join("\n");
@@ -20215,6 +20263,12 @@ function buildAssessBriefUserPrompt(input, ctx) {
20215
20263
  header: "Querying the producer's diary entries",
20216
20264
  body: diaryQuery
20217
20265
  },
20266
+ {
20267
+ id: "assess_brief.proactive_memory",
20268
+ source: "discipline",
20269
+ header: "Proactive memory use",
20270
+ body: buildProactiveMemoryWorkflowBlock()
20271
+ },
20218
20272
  {
20219
20273
  id: "assess_brief.workspace",
20220
20274
  source: "workspace",
@@ -20542,11 +20596,13 @@ function buildFreeformUserPrompt(input, ctx) {
20542
20596
  const suggestedTaskType = input.suggestedTaskType ? [`The proposer suggested task type \`${input.suggestedTaskType}\`.`, "Use it as a hint, not as a contract."].join("\n") : "";
20543
20597
  const workflow = [
20544
20598
  "1. Clarify the real objective from the brief before acting.",
20545
- "2. Gather enough context to avoid guessing.",
20546
- "3. Complete the requested work when it is safe and bounded.",
20547
- "4. If the request reveals a recurring task shape, include a",
20599
+ "2. Search MoltNet diary memory for prior decisions, incidents, and",
20600
+ " recurring traps relevant to the brief.",
20601
+ "3. Gather enough context to avoid guessing.",
20602
+ "4. Complete the requested work when it is safe and bounded.",
20603
+ "5. If the request reveals a recurring task shape, include a",
20548
20604
  " `proposedTaskType` in the final output with a concise rationale.",
20549
- "5. If you changed code on a branch, include that branch in",
20605
+ "6. If you changed code on a branch, include that branch in",
20550
20606
  " `branch` so future continuations can recover git context."
20551
20607
  ].join("\n");
20552
20608
  const sections = [
@@ -20585,6 +20641,12 @@ function buildFreeformUserPrompt(input, ctx) {
20585
20641
  header: "Workflow",
20586
20642
  body: workflow
20587
20643
  },
20644
+ {
20645
+ id: "freeform.proactive_memory",
20646
+ source: "discipline",
20647
+ header: "Proactive memory use",
20648
+ body: buildProactiveMemoryWorkflowBlock()
20649
+ },
20588
20650
  {
20589
20651
  id: "freeform.verification",
20590
20652
  source: "verification",
@@ -20661,13 +20723,15 @@ function buildFulfillBriefUserPrompt(input, ctx) {
20661
20723
  ].join("\n") : "";
20662
20724
  const workflow = [
20663
20725
  ctx.workspace?.mode === "dedicated_worktree" ? `1. Use the already-provisioned dedicated worktree branch${ctx.workspace.branch ? ` (\`${ctx.workspace.branch}\`)` : ""}; do not create or switch the primary checkout.` : `1. Create a feature branch (starting prefix suggestion: \`${branchSlug}<short-slug>\`).`,
20664
- "2. Understand the problem read relevant code; do not speculate.",
20665
- "3. Implement the change. Keep commits small and coherent.",
20666
- "4. Add tests if applicable.",
20667
- "5. For every commit, create a signed diary entry first via",
20726
+ "2. Search MoltNet diary memory for prior decisions, incidents, and",
20727
+ " recurring traps relevant to the brief before changing code.",
20728
+ "3. Understand the problem — read relevant code; do not speculate.",
20729
+ "4. Implement the change. Keep commits small and coherent.",
20730
+ "5. Add tests if applicable.",
20731
+ "6. For every commit, create a signed diary entry first via",
20668
20732
  " `moltnet_create_entry` and embed its id in the commit trailer",
20669
20733
  " `MoltNet-Diary: <id>` (per the runtime instructor).",
20670
- "6. Push the branch and open a PR — run `git push` and `gh pr create`",
20734
+ "7. Push the branch and open a PR — run `git push` and `gh pr create`",
20671
20735
  " IN the VM with your normal `bash` tool (use the",
20672
20736
  " `GH_TOKEN=$(moltnet github token …) gh …` form from the runtime",
20673
20737
  " instructor). Do NOT use `moltnet_host_exec` for this; it needs human",
@@ -20709,6 +20773,12 @@ function buildFulfillBriefUserPrompt(input, ctx) {
20709
20773
  header: "Workflow",
20710
20774
  body: workflow
20711
20775
  },
20776
+ {
20777
+ id: "fulfill_brief.proactive_memory",
20778
+ source: "discipline",
20779
+ header: "Proactive memory use",
20780
+ body: buildProactiveMemoryWorkflowBlock()
20781
+ },
20712
20782
  {
20713
20783
  id: "fulfill_brief.verification",
20714
20784
  source: "verification",
@@ -21024,13 +21094,15 @@ function buildPrReviewUserPrompt(input, ctx) {
21024
21094
  const workflow = [
21025
21095
  "1. Read the subject summary, resources, inspection hints, and any",
21026
21096
  " task-specific instructions before scoring.",
21027
- "2. Inspect the target artefact directly using the tools and resources the",
21097
+ "2. Search MoltNet diary memory for prior decisions, incidents, and",
21098
+ " recurring review traps relevant to the subject.",
21099
+ "3. Inspect the target artefact directly using the tools and resources the",
21028
21100
  " task makes available.",
21029
- "3. If you are in a dedicated disposable worktree and need the review target",
21101
+ "4. If you are in a dedicated disposable worktree and need the review target",
21030
21102
  " checked out locally, do that work inside this disposable workspace only.",
21031
- "4. Apply the rubric strictly. This task is about complexity and",
21103
+ "5. Apply the rubric strictly. This task is about complexity and",
21032
21104
  " reviewability, not correctness or feature desirability.",
21033
- "5. Perform any required outward action before emitting the final",
21105
+ "6. Perform any required outward action before emitting the final",
21034
21106
  " structured output."
21035
21107
  ].join("\n");
21036
21108
  const taskPromptSection = input.taskPrompt ?? "";
@@ -21087,6 +21159,12 @@ function buildPrReviewUserPrompt(input, ctx) {
21087
21159
  header: "Review workflow",
21088
21160
  body: workflow
21089
21161
  },
21162
+ {
21163
+ id: "pr_review.proactive_memory",
21164
+ source: "discipline",
21165
+ header: "Proactive memory use",
21166
+ body: buildProactiveMemoryWorkflowBlock()
21167
+ },
21090
21168
  {
21091
21169
  id: "pr_review.task_prompt",
21092
21170
  source: "task_input",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@themoltnet/pi-extension",
3
- "version": "0.32.1",
3
+ "version": "0.33.0",
4
4
  "type": "module",
5
5
  "description": "MoltNet pi extension — sandboxed tool execution in Gondolin VMs with MoltNet identity and persistent memory",
6
6
  "keywords": [
@@ -36,8 +36,8 @@
36
36
  "@earendil-works/gondolin": "^0.9.1",
37
37
  "@opentelemetry/api": "^1.9.0",
38
38
  "typebox": "^1.2.8",
39
- "@themoltnet/sdk": "0.119.0",
40
- "@themoltnet/agent-runtime": "0.34.1"
39
+ "@themoltnet/agent-runtime": "0.35.0",
40
+ "@themoltnet/sdk": "0.119.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@earendil-works/pi-coding-agent": ">=0.74.0",