agentsmesh 0.21.0 → 0.22.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,62 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.22.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c2a13ad: Add `agentsmesh init --lessons` and a new `agentsmesh/lessons` public API for
8
+ the lessons recall + capture subsystem.
9
+
10
+ The subsystem keeps agents from repeating past mistakes via a procedural rule
11
+ that lives in every target's root file: before any edit or command, scan
12
+ `.agentsmesh/lessons/index.yaml` and read every matched
13
+ `.agentsmesh/lessons/topics/<topic>.md`; after any failure, append to
14
+ `.agentsmesh/lessons/journal.md`. The optional repo-local `pnpm distill` /
15
+ `pnpm distill:apply` scripts can help maintain AgentsMesh's own topic routing,
16
+ but the generated rule does not require package-manager-specific tooling.
17
+
18
+ **Using it:**
19
+ - **Fresh init:** `agentsmesh init --lessons` — creates the canonical scaffold
20
+ AND the lessons subsystem in one command.
21
+ - **Retroactive add (existing project):** the same `agentsmesh init --lessons`
22
+ — when `agentsmesh.yaml` already exists, init only scaffolds the lessons
23
+ artifacts and appends the procedural rule to `_root.md`. Idempotent.
24
+ - After either flow, run `agentsmesh generate` to project the procedural rule
25
+ to every target's root file.
26
+
27
+ **Public API** (importable from `agentsmesh/lessons`):
28
+ - `scaffoldLessons(projectRoot)` — idempotent scaffolder used internally by
29
+ `init --lessons`; reusable from custom tooling.
30
+ - `loadLessonsIndex(projectRoot)`, `readTriggeredLessons(projectRoot, event)`,
31
+ `appendLessonToJournal(projectRoot, input)`, and `formatLessonBullet(input)` —
32
+ one high-level, target-agnostic read/write layer for integrations that should
33
+ not hand-roll filesystem access.
34
+ - `lessonsPaths(projectRoot)`, `LESSONS_PROCEDURAL_RULE`,
35
+ `LESSONS_JOURNAL_TEMPLATE`, `LESSONS_INDEX_TEMPLATE` — paths and templates.
36
+ - `parseIndex`, `LessonsIndexSchema`, `matchTriggers`, `scoreBullet`,
37
+ `loadLedger`, `saveLedger`, `hashBullet`, `parseBullets` — building blocks
38
+ for downstream tooling (custom distillers, recall hooks, IDE plugins).
39
+
40
+ **Universal across every target.** The subsystem uses plain markdown files
41
+ read via standard file I/O — no `Skill` tool, no description-match, no
42
+ per-target projection. Works in Claude Code, Codex CLI, Cline, Roo Code,
43
+ Cursor, Gemini CLI, Aider, Goose, and every other supported harness.
44
+
45
+ **Linter integration:** `agentsmesh lint` now validates the lessons subsystem
46
+ when present — checks that `index.yaml` parses, topic files referenced in the
47
+ index exist, and the journal file is well-formed.
48
+
49
+ **Constraints:**
50
+ - `--lessons` is project-mode only. Combining with `--global` errors out.
51
+ - Removal: `rm -rf .agentsmesh/lessons/` and strip the `## Lessons` paragraph
52
+ from `.agentsmesh/rules/_root.md`.
53
+
54
+ ### Patch Changes
55
+
56
+ - c75a424: Surface marketplace sub-pack install failures instead of swallowing them silently, and route skill-pack sub-packs through the correct install path.
57
+ - c75a424: Fix qwen-code global-mode rule embedding. Rules were silently dropped when generating in global mode; they are now embedded inline using the same pattern as other global-mode targets.
58
+ - c75a424: Restructure the generation contract paragraph to lead with an explicit **NEVER edit generated files** prohibition naming the generated paths (`.claude/`, `.cursor/`, `AGENTS.md`, etc.), followed by **All changes MUST go through `.agentsmesh` first**. Agents were initially understanding the contract but forgetting it over multi-step conversations — front-loading the prohibition makes it stickier. All legacy contract body versions (v1-v10) remain detected for safe in-place upgrade.
59
+
3
60
  ## 0.21.0
4
61
 
5
62
  ### Minor Changes
package/README.md CHANGED
@@ -87,6 +87,10 @@ AGENTS.md
87
87
  hooks.yaml
88
88
  permissions.yaml
89
89
  ignore
90
+ lessons/
91
+ index.yaml
92
+ journal.md
93
+ topics/
90
94
  ```
91
95
 
92
96
  ```bash
@@ -111,6 +115,12 @@ agentsmesh check # CI-friendly drift gate against .agentsmesh/.lock
111
115
  - **`generate`** — writes `CLAUDE.md`, `AGENTS.md`, `.cursor/`, `.github/copilot-instructions.md`, etc. from canonical sources.
112
116
  - **`check`** — exits non-zero if generated files have drifted from `.agentsmesh/.lock`. Drop into CI.
113
117
 
118
+ Use `agentsmesh init --lessons` when you want the optional lessons recall +
119
+ capture subsystem. Agents read `.agentsmesh/lessons/index.yaml`, load only
120
+ matching topic files before edits/commands, and append failures to
121
+ `.agentsmesh/lessons/journal.md`; the procedural rule is projected through the
122
+ normal root rule, so it stays tool-agnostic.
123
+
114
124
  If you installed via `npm install -D agentsmesh` (also `pnpm add -D` / `yarn add -D`), prefix each command with `npx`. The CLI ships as both `agentsmesh` and the shorter alias `amsh`.
115
125
 
116
126
  ---
@@ -208,6 +218,7 @@ AgentsMesh canonicalizes all of these — rules, commands, agents, skills, MCP s
208
218
  - `hooks.yaml` — pre/post tool hooks.
209
219
  - `permissions.yaml` — allow/deny rules where the target supports them.
210
220
  - `ignore` — paths the assistant should not read or modify.
221
+ - `lessons/` — optional recall/capture memory: trigger index, append-only journal, and small topic rule files read directly by agents.
211
222
 
212
223
  Configuration:
213
224
 
@@ -222,7 +233,7 @@ Detailed contracts: [Canonical Config](https://samplexbro.github.io/agentsmesh/c
222
233
  ## CLI usage
223
234
 
224
235
  ```bash
225
- agentsmesh init [--global] [--yes]
236
+ agentsmesh init [--global] [--yes] [--lessons]
226
237
  agentsmesh generate [--global] [--targets <csv>] [--check] [--dry-run] [--force] [--refresh-cache]
227
238
  agentsmesh import --from <target> [--global]
228
239
  agentsmesh convert --from <target> --to <target> [--global] [--dry-run]
@@ -384,6 +395,7 @@ Every config file ships with a generated JSON Schema, so VS Code, JetBrains, and
384
395
  | `AGENTSMESH_CACHE` | `~/.agentsmeshcache` | Override the remote-extends / tarball cache directory. |
385
396
  | `AGENTSMESH_MAX_TARBALL_MB` | `500` | Maximum GitHub tarball size in MiB the install command will accept. Allowed range: `1`–`4096`. Increase this when installing from large monorepos. |
386
397
  | `AGENTSMESH_STRICT_PLUGINS` | `0` | When set to `1`, a failed plugin descriptor import fails the build instead of warning-and-skip. Useful in CI where a missing plugin target is a regression. |
398
+ | `AGENTSMESH_ALLOW_LOCAL_GIT` | `0` | When set to `1`, enables `git+file://` sources in `extends` and `install`. Disabled by default because on shared hosts a world-writable repo could be planted by another user and combined with elevated-artifact emission for local privilege escalation. |
387
399
 
388
400
  ---
389
401
 
package/dist/canonical.js CHANGED
@@ -1050,7 +1050,7 @@ ${legacy}`, "");
1050
1050
  }
1051
1051
  return result.trim();
1052
1052
  }
1053
- var ROOT_INSTRUCTION_BODY_V1, ROOT_INSTRUCTION_BODY_V2, ROOT_INSTRUCTION_BODY_V3, ROOT_INSTRUCTION_BODY_V4, ROOT_INSTRUCTION_BODY_V5, ROOT_INSTRUCTION_BODY_V6, ROOT_INSTRUCTION_BODY_V7, ROOT_INSTRUCTION_BODY_V8, ROOT_INSTRUCTION_BODY, LEGACY_AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH, LEGACY_AGENTSMESH_ROOT_INSTRUCTION_SECTION, AGENTSMESH_CONTRACT_WITH_V1_BODY, AGENTSMESH_CONTRACT_WITH_V2_BODY, AGENTSMESH_CONTRACT_WITH_V3_BODY, AGENTSMESH_CONTRACT_WITH_V4_BODY, AGENTSMESH_CONTRACT_WITH_V5_BODY, AGENTSMESH_CONTRACT_WITH_V6_BODY, AGENTSMESH_CONTRACT_WITH_V7_BODY, AGENTSMESH_CONTRACT_WITH_V8_BODY, AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH, LEGACY_FORMS;
1053
+ var ROOT_INSTRUCTION_BODY_V1, ROOT_INSTRUCTION_BODY_V2, ROOT_INSTRUCTION_BODY_V3, ROOT_INSTRUCTION_BODY_V4, ROOT_INSTRUCTION_BODY_V5, ROOT_INSTRUCTION_BODY_V6, ROOT_INSTRUCTION_BODY_V7, ROOT_INSTRUCTION_BODY_V8, ROOT_INSTRUCTION_BODY_V9, ROOT_INSTRUCTION_BODY_V10, ROOT_INSTRUCTION_BODY, LEGACY_AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH, LEGACY_AGENTSMESH_ROOT_INSTRUCTION_SECTION, AGENTSMESH_CONTRACT_WITH_V1_BODY, AGENTSMESH_CONTRACT_WITH_V2_BODY, AGENTSMESH_CONTRACT_WITH_V3_BODY, AGENTSMESH_CONTRACT_WITH_V4_BODY, AGENTSMESH_CONTRACT_WITH_V5_BODY, AGENTSMESH_CONTRACT_WITH_V6_BODY, AGENTSMESH_CONTRACT_WITH_V7_BODY, AGENTSMESH_CONTRACT_WITH_V8_BODY, AGENTSMESH_CONTRACT_WITH_V9_BODY, AGENTSMESH_CONTRACT_WITH_V10_BODY, AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH, LEGACY_FORMS;
1054
1054
  var init_root_instruction_paragraph = __esm({
1055
1055
  "src/targets/projection/root-instruction-paragraph.ts"() {
1056
1056
  init_managed_blocks();
@@ -1062,7 +1062,9 @@ var init_root_instruction_paragraph = __esm({
1062
1062
  ROOT_INSTRUCTION_BODY_V6 = "Create canonical files in `.agentsmesh`: `rules/_root.md` and `rules/*.md` are Markdown rules; `commands/*.md`, `agents/*.md`, and `skills/*/SKILL.md` plus supporting files use Claude-style frontmatter Markdown; `mcp.json` is MCP JSON; `hooks.yaml` and `permissions.yaml` are YAML; `ignore` is gitignore-style text. Then run `agentsmesh generate`.";
1063
1063
  ROOT_INSTRUCTION_BODY_V7 = "`.agentsmesh` is the only folder you edit or add these files in: `rules/_root.md` and `rules/*.md` are Markdown rules; `commands/*.md`, `agents/*.md`, and `skills/*/SKILL.md` plus supporting files use Claude-style frontmatter Markdown; `mcp.json` is MCP JSON; `hooks.yaml` and `permissions.yaml` are YAML; `ignore` is gitignore-style text. Do not edit generated tool files; run `agentsmesh generate`.";
1064
1064
  ROOT_INSTRUCTION_BODY_V8 = "`agentsmesh.yaml` selects targets/features (`agentsmesh.local.yaml` overrides locally), and `.agentsmesh` is the only place to add or edit canonical items: `rules/_root.md`, `rules/*.md`, `commands/*.md`, `agents/*.md`, `skills/*/SKILL.md` plus supporting files, `mcp.json`, `hooks.yaml`, `permissions.yaml`, and `ignore`; if missing run `agentsmesh init`, use `agentsmesh import --from <tool>` for native configs, `agentsmesh install <source>` or `install --sync` for reusable packs, then run `agentsmesh generate`. Use `diff`, `lint`, `check`, `watch`, `matrix`, and `merge` as needed; never edit generated tool files.";
1065
- ROOT_INSTRUCTION_BODY = "`agentsmesh.yaml` selects targets/features (`agentsmesh.local.yaml` overrides locally), and `.agentsmesh` is the only place to add or edit canonical items: `rules/_root.md`, `rules/*.md`, `commands/*.md`, `agents/*.md`, `skills/*/SKILL.md` plus supporting files, `mcp.json`, `hooks.yaml`, `permissions.yaml`, and `ignore`; if missing run `agentsmesh init`, use `agentsmesh import --from <tool>` for native configs, `agentsmesh install <source>` or `install --sync` for reusable packs, then run `agentsmesh generate`. Use `diff`, `lint`, `check`, `watch`, `matrix`, `merge`, and `refresh` as needed; never edit generated tool files.";
1065
+ ROOT_INSTRUCTION_BODY_V9 = "`agentsmesh.yaml` selects targets/features (`agentsmesh.local.yaml` overrides locally), and `.agentsmesh` is the only place to add or edit canonical items: `rules/_root.md`, `rules/*.md`, `commands/*.md`, `agents/*.md`, `skills/*/SKILL.md` plus supporting files, `mcp.json`, `hooks.yaml`, `permissions.yaml`, and `ignore`; if missing run `agentsmesh init`, use `agentsmesh import --from <tool>` for native configs, `agentsmesh install <source>` or `install --sync` for reusable packs, then run `agentsmesh generate`. Use `diff`, `lint`, `check`, `watch`, `matrix`, `merge`, and `refresh` as needed; never edit generated tool files.";
1066
+ ROOT_INSTRUCTION_BODY_V10 = "**MUST follow when changing any rule, agent, command, skill, hook, MCP server, permission, or ignore pattern.** `agentsmesh.yaml` selects targets/features (`agentsmesh.local.yaml` overrides locally), and `.agentsmesh` is the only place to add or edit canonical items: `rules/_root.md`, `rules/*.md`, `commands/*.md`, `agents/*.md`, `skills/*/SKILL.md` plus supporting files, `mcp.json`, `hooks.yaml`, `permissions.yaml`, and `ignore`; if missing run `agentsmesh init`, use `agentsmesh import --from <tool>` for native configs, `agentsmesh install <source>` or `install --sync` for reusable packs, then run `agentsmesh generate`. Use `diff`, `lint`, `check`, `watch`, `matrix`, `merge`, and `refresh` as needed; never edit generated tool files.";
1067
+ ROOT_INSTRUCTION_BODY = "**NEVER edit generated files** (`.claude/`, `.cursor/`, `AGENTS.md`, `.github/copilot-instructions.md`, and similar target outputs) \u2014 `agentsmesh generate` overwrites them. **All changes MUST go through `.agentsmesh` first**: edit `rules/_root.md`, `rules/*.md`, `commands/*.md`, `agents/*.md`, `skills/*/SKILL.md` plus supporting files, `mcp.json`, `hooks.yaml`, `permissions.yaml`, and `ignore`; `agentsmesh.yaml` selects targets/features (`agentsmesh.local.yaml` overrides locally); if missing run `agentsmesh init`, use `agentsmesh import --from <tool>` for native configs, `agentsmesh install <source>` or `install --sync` for reusable packs, then run `agentsmesh generate`. Use `diff`, `lint`, `check`, `watch`, `matrix`, `merge`, and `refresh` as needed.";
1066
1068
  LEGACY_AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH = ROOT_INSTRUCTION_BODY_V1;
1067
1069
  LEGACY_AGENTSMESH_ROOT_INSTRUCTION_SECTION = `## Project-Specific Rules
1068
1070
 
@@ -1091,12 +1093,20 @@ ${ROOT_INSTRUCTION_BODY_V7}`;
1091
1093
  AGENTSMESH_CONTRACT_WITH_V8_BODY = `## AgentsMesh Generation Contract
1092
1094
 
1093
1095
  ${ROOT_INSTRUCTION_BODY_V8}`;
1096
+ AGENTSMESH_CONTRACT_WITH_V9_BODY = `## AgentsMesh Generation Contract
1097
+
1098
+ ${ROOT_INSTRUCTION_BODY_V9}`;
1099
+ AGENTSMESH_CONTRACT_WITH_V10_BODY = `## AgentsMesh Generation Contract
1100
+
1101
+ ${ROOT_INSTRUCTION_BODY_V10}`;
1094
1102
  AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH = `${ROOT_CONTRACT_START}
1095
1103
  ## AgentsMesh Generation Contract
1096
1104
 
1097
1105
  ${ROOT_INSTRUCTION_BODY}
1098
1106
  ${ROOT_CONTRACT_END}`;
1099
1107
  LEGACY_FORMS = [
1108
+ AGENTSMESH_CONTRACT_WITH_V10_BODY,
1109
+ AGENTSMESH_CONTRACT_WITH_V9_BODY,
1100
1110
  AGENTSMESH_CONTRACT_WITH_V8_BODY,
1101
1111
  AGENTSMESH_CONTRACT_WITH_V7_BODY,
1102
1112
  AGENTSMESH_CONTRACT_WITH_V6_BODY,
@@ -15783,9 +15793,18 @@ function generateIgnore12(canonical) {
15783
15793
  if (!canonical.ignore || canonical.ignore.length === 0) return [];
15784
15794
  return [{ path: QWEN_IGNORE, content: canonical.ignore.join("\n") }];
15785
15795
  }
15796
+ function renderQwenGlobalInstructions(canonical) {
15797
+ const root = canonical.rules.find((rule) => rule.root);
15798
+ const nonRootRules = canonical.rules.filter((rule) => {
15799
+ if (rule.root) return false;
15800
+ return rule.targets.length === 0 || rule.targets.includes(QWEN_CODE_TARGET);
15801
+ });
15802
+ return appendEmbeddedRulesBlock(root?.body.trim() ?? "", nonRootRules);
15803
+ }
15786
15804
  var init_generator26 = __esm({
15787
15805
  "src/targets/qwen-code/generator.ts"() {
15788
15806
  init_markdown();
15807
+ init_managed_blocks();
15789
15808
  init_constants21();
15790
15809
  }
15791
15810
  });
@@ -15868,6 +15887,7 @@ var init_qwen_code2 = __esm({
15868
15887
  };
15869
15888
  globalLayout22 = {
15870
15889
  rootInstructionPath: QWEN_GLOBAL_ROOT,
15890
+ renderPrimaryRootInstruction: renderQwenGlobalInstructions,
15871
15891
  skillDir: QWEN_GLOBAL_SKILLS_DIR,
15872
15892
  managedOutputs: {
15873
15893
  dirs: [QWEN_GLOBAL_COMMANDS_DIR, QWEN_GLOBAL_AGENTS_DIR, QWEN_GLOBAL_SKILLS_DIR],