@geminilight/mindos 0.5.22 → 0.5.23

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 (46) hide show
  1. package/app/app/api/ask/route.ts +7 -14
  2. package/app/app/api/bootstrap/route.ts +1 -0
  3. package/app/app/globals.css +14 -0
  4. package/app/app/setup/page.tsx +3 -2
  5. package/app/components/ActivityBar.tsx +183 -0
  6. package/app/components/AskFab.tsx +39 -97
  7. package/app/components/AskModal.tsx +13 -371
  8. package/app/components/Breadcrumb.tsx +4 -4
  9. package/app/components/FileTree.tsx +21 -4
  10. package/app/components/Logo.tsx +39 -0
  11. package/app/components/Panel.tsx +152 -0
  12. package/app/components/RightAskPanel.tsx +72 -0
  13. package/app/components/SettingsModal.tsx +9 -241
  14. package/app/components/SidebarLayout.tsx +426 -12
  15. package/app/components/SyncStatusBar.tsx +74 -53
  16. package/app/components/TableOfContents.tsx +4 -2
  17. package/app/components/ask/AskContent.tsx +418 -0
  18. package/app/components/ask/MessageList.tsx +2 -2
  19. package/app/components/panels/AgentsPanel.tsx +231 -0
  20. package/app/components/panels/PanelHeader.tsx +35 -0
  21. package/app/components/panels/PluginsPanel.tsx +106 -0
  22. package/app/components/panels/SearchPanel.tsx +178 -0
  23. package/app/components/panels/SyncPopover.tsx +105 -0
  24. package/app/components/renderers/csv/TableView.tsx +4 -4
  25. package/app/components/settings/AiTab.tsx +39 -1
  26. package/app/components/settings/KnowledgeTab.tsx +116 -2
  27. package/app/components/settings/McpTab.tsx +6 -6
  28. package/app/components/settings/SettingsContent.tsx +343 -0
  29. package/app/components/settings/types.ts +1 -1
  30. package/app/components/setup/index.tsx +2 -23
  31. package/app/hooks/useResizeDrag.ts +78 -0
  32. package/app/lib/agent/index.ts +0 -1
  33. package/app/lib/agent/model.ts +33 -10
  34. package/app/lib/format.ts +19 -0
  35. package/app/lib/i18n-en.ts +6 -6
  36. package/app/lib/i18n-zh.ts +5 -5
  37. package/app/next-env.d.ts +1 -1
  38. package/app/next.config.ts +1 -1
  39. package/app/package.json +2 -2
  40. package/bin/cli.js +27 -97
  41. package/package.json +4 -2
  42. package/scripts/setup.js +2 -12
  43. package/skills/mindos/SKILL.md +226 -8
  44. package/skills/mindos-zh/SKILL.md +226 -8
  45. package/app/lib/agent/skill-rules.ts +0 -70
  46. package/app/package-lock.json +0 -15736
package/app/next-env.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="next" />
2
2
  /// <reference types="next/image-types/global" />
3
- import "./.next/types/routes.d.ts";
3
+ import "./.next/dev/types/routes.d.ts";
4
4
 
5
5
  // NOTE: This file should not be edited
6
6
  // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
@@ -3,7 +3,7 @@ import path from "path";
3
3
 
4
4
  const nextConfig: NextConfig = {
5
5
  transpilePackages: ['github-slugger'],
6
- serverExternalPackages: ['pdfjs-dist', 'pdf-parse', 'chokidar', '@mariozechner/pi-ai', '@mariozechner/pi-agent-core'],
6
+ serverExternalPackages: ['pdfjs-dist', 'pdf-parse', 'chokidar', 'openai', '@mariozechner/pi-ai', '@mariozechner/pi-agent-core'],
7
7
  outputFileTracingRoot: path.join(__dirname),
8
8
  turbopack: {
9
9
  root: path.join(__dirname),
package/app/package.json CHANGED
@@ -16,8 +16,8 @@
16
16
  "@codemirror/state": "^6.5.4",
17
17
  "@codemirror/theme-one-dark": "^6.1.3",
18
18
  "@codemirror/view": "^6.39.16",
19
- "@mariozechner/pi-agent-core": "^0.60.0",
20
- "@mariozechner/pi-ai": "^0.60.0",
19
+ "@mariozechner/pi-agent-core": "^0.61.0",
20
+ "@mariozechner/pi-ai": "^0.61.0",
21
21
  "@sinclair/typebox": "^0.34.33",
22
22
  "@tiptap/extension-image": "^3.20.1",
23
23
  "@tiptap/extension-link": "^3.20.1",
package/bin/cli.js CHANGED
@@ -245,7 +245,7 @@ const commands = {
245
245
  // Do NOT call start() here — kickstart -k would kill the just-started process,
246
246
  // causing a port-conflict race condition with KeepAlive restart loops.
247
247
  console.log(dim(' (First run may take a few minutes to install dependencies and build the app.)'));
248
- const ready = await waitForHttp(Number(webPort), { retries: 60, intervalMs: 2000, label: 'Web UI', logFile: LOG_PATH });
248
+ const ready = await waitForHttp(Number(webPort), { retries: 120, intervalMs: 2000, label: 'Web UI', logFile: LOG_PATH });
249
249
  if (!ready) {
250
250
  console.error(red('\n✘ Service started but Web UI did not become ready in time.'));
251
251
  console.error(dim(' Check logs with: mindos logs\n'));
@@ -271,36 +271,22 @@ const commands = {
271
271
  const webPort = process.env.MINDOS_WEB_PORT || '3456';
272
272
  const mcpPort = process.env.MINDOS_MCP_PORT || '8781';
273
273
 
274
- // ── Auto-migrate skill rules (v3 split v4 merged) ──────────────────
274
+ // ── Auto-migrate user-rules.md to root user-skill-rules.md ─────────────
275
275
  try {
276
276
  const cfg = JSON.parse(readFileSync(CONFIG_PATH, 'utf-8'));
277
277
  const mr = cfg.mindRoot;
278
278
  if (mr && existsSync(mr)) {
279
279
  const isZh = cfg.disabledSkills?.includes('mindos');
280
280
  const sName = isZh ? 'mindos-zh' : 'mindos';
281
- const lang = isZh ? 'zh' : 'en';
282
281
  const sDir = resolve(mr, '.agents', 'skills', sName);
283
- const merged = resolve(sDir, 'skill-rules.md');
284
- const legacyRules = resolve(sDir, 'rules.md');
285
- // Migrate if legacy exists but merged doesn't
286
- if (existsSync(legacyRules) && !existsSync(merged)) {
287
- const tpl = resolve(ROOT, 'templates', 'skill-rules', lang, 'skill-rules.md');
288
- if (existsSync(tpl)) {
289
- cpSync(tpl, merged);
290
- for (const f of ['rules.md', 'patterns.md', 'proactive.md']) {
291
- const p = resolve(sDir, f);
292
- if (existsSync(p)) rmSync(p);
293
- }
294
- console.log(` ${green('✓')} ${dim('Skill rules migrated to skill-rules.md')}`);
295
- }
296
- }
297
- // Init if .agents/skills/ doesn't exist at all
298
- if (!existsSync(sDir)) {
299
- const srcDir = resolve(ROOT, 'templates', 'skill-rules', lang);
300
- if (existsSync(srcDir)) {
301
- mkdirSync(sDir, { recursive: true });
302
- cpSync(srcDir, sDir, { recursive: true });
303
- console.log(` ${green('✓')} ${dim('Skill rules initialized')}`);
282
+ const rootUserRules = resolve(mr, 'user-skill-rules.md');
283
+
284
+ // Migrate: .agents/skills/{name}/user-rules.md {mindRoot}/user-skill-rules.md
285
+ if (!existsSync(rootUserRules)) {
286
+ const oldUserRules = resolve(sDir, 'user-rules.md');
287
+ if (existsSync(oldUserRules)) {
288
+ cpSync(oldUserRules, rootUserRules);
289
+ console.log(` ${green('')} ${dim('Migrated user-rules.md → user-skill-rules.md')}`);
304
290
  }
305
291
  }
306
292
  }
@@ -440,7 +426,6 @@ ${dim('Shortcut: mindos start --daemon → install + start in one step')}
440
426
 
441
427
  // ── init-skills ──────────────────────────────────────────────────────────
442
428
  'init-skills': async () => {
443
- const force = process.argv.includes('--force');
444
429
  console.log(`\n${bold('📦 Initialize Skill Rules')}\n`);
445
430
 
446
431
  if (!existsSync(CONFIG_PATH)) {
@@ -460,56 +445,23 @@ ${dim('Shortcut: mindos start --daemon → install + start in one step')}
460
445
  process.exit(1);
461
446
  }
462
447
 
463
- const isZh = config.disabledSkills?.includes('mindos');
464
- const skillName = isZh ? 'mindos-zh' : 'mindos';
465
- const lang = isZh ? 'zh' : 'en';
466
- const skillDir = resolve(mindRoot, '.agents', 'skills', skillName);
467
- const sourceDir = resolve(ROOT, 'templates', 'skill-rules', lang);
468
-
469
- if (!existsSync(sourceDir)) {
470
- console.log(` ${red('✘')} Template not found: ${dim(sourceDir)}\n`);
471
- process.exit(1);
472
- }
473
-
474
- const files = ['skill-rules.md', 'user-rules.md'];
475
- mkdirSync(skillDir, { recursive: true });
476
-
477
- let count = 0;
478
- for (const file of files) {
479
- const dest = resolve(skillDir, file);
480
- const src = resolve(sourceDir, file);
481
- if (!existsSync(src)) continue;
482
-
483
- // Never overwrite user-rules.md even with --force
484
- if (file === 'user-rules.md' && existsSync(dest)) {
485
- console.log(` ${dim('skip')} ${file} (user rules preserved)`);
486
- continue;
487
- }
488
-
489
- if (existsSync(dest) && !force) {
490
- console.log(` ${dim('skip')} ${file} (already exists)`);
491
- continue;
492
- }
493
-
494
- cpSync(src, dest);
495
- console.log(` ${green('✓')} ${file}${force ? ' (reset)' : ''}`);
496
- count++;
497
- }
498
-
499
- // Clean up legacy split files from v3
500
- for (const legacy of ['rules.md', 'patterns.md', 'proactive.md']) {
501
- const legacyPath = resolve(skillDir, legacy);
502
- if (existsSync(legacyPath)) {
503
- rmSync(legacyPath);
504
- console.log(` ${dim('cleanup')} ${legacy} (merged into skill-rules.md)`);
505
- }
506
- }
507
-
508
- if (count === 0) {
509
- console.log(`\n ${dim('All files already exist. Use --force to reset defaults (user-rules.md is always preserved).')}\n`);
448
+ // Skill operating rules are now built into SKILL.md (shipped with the app).
449
+ // This command only initializes user-skill-rules.md for personalization.
450
+ const dest = resolve(mindRoot, 'user-skill-rules.md');
451
+ if (existsSync(dest)) {
452
+ console.log(` ${dim('skip')} user-skill-rules.md (already exists)\n`);
510
453
  } else {
511
- console.log(`\n ${green('')} Skill rules initialized at ${dim(skillDir)}\n`);
454
+ const isZh = config.disabledSkills?.includes('mindos');
455
+ const lang = isZh ? 'zh' : 'en';
456
+ const src = resolve(ROOT, 'templates', 'skill-rules', lang, 'user-rules.md');
457
+ if (existsSync(src)) {
458
+ cpSync(src, dest);
459
+ console.log(` ${green('✓')} user-skill-rules.md created at ${dim(mindRoot)}\n`);
460
+ } else {
461
+ console.log(` ${dim('skip')} Template not found, create user-skill-rules.md manually if needed.\n`);
462
+ }
512
463
  }
464
+ console.log(` ${dim('Note: Operating rules are now built into the app. No install needed.')}\n`);
513
465
  },
514
466
 
515
467
  // ── doctor ─────────────────────────────────────────────────────────────────
@@ -727,7 +679,7 @@ ${dim('Shortcut: mindos start --daemon → install + start in one step')}
727
679
  const webPort = updateConfig.port ?? 3456;
728
680
  const mcpPort = updateConfig.mcpPort ?? 8781;
729
681
  console.log(dim(' (Waiting for Web UI to come back up — first run after update includes a rebuild...)'));
730
- const ready = await waitForHttp(Number(webPort), { retries: 60, intervalMs: 2000, label: 'Web UI', logFile: LOG_PATH });
682
+ const ready = await waitForHttp(Number(webPort), { retries: 120, intervalMs: 2000, label: 'Web UI', logFile: LOG_PATH });
731
683
  if (ready) {
732
684
  const localIP = getLocalIP();
733
685
  console.log(`\n${'─'.repeat(53)}`);
@@ -746,28 +698,6 @@ ${dim('Shortcut: mindos start --daemon → install + start in one step')}
746
698
  console.log(dim(' Run `mindos start` — it will rebuild automatically.'));
747
699
  console.log(` ${dim('View changelog:')} ${cyan('https://github.com/GeminiLight/MindOS/releases')}\n`);
748
700
  }
749
-
750
- // ── Check if skill rules need updating ──────────────────────────────────
751
- try {
752
- const updateCfg = JSON.parse(readFileSync(CONFIG_PATH, 'utf-8'));
753
- const mindRoot = updateCfg.mindRoot;
754
- if (mindRoot && existsSync(mindRoot)) {
755
- const isZh = updateCfg.disabledSkills?.includes('mindos');
756
- const sName = isZh ? 'mindos-zh' : 'mindos';
757
- const lang = isZh ? 'zh' : 'en';
758
- const installedRules = resolve(mindRoot, '.agents', 'skills', sName, 'skill-rules.md');
759
- const tplRules = resolve(ROOT, 'templates', 'skill-rules', lang, 'skill-rules.md');
760
- if (existsSync(installedRules) && existsSync(tplRules)) {
761
- const uVer = readFileSync(installedRules, 'utf-8').match(/<!--\s*version:\s*(\S+)\s*-->/)?.[1];
762
- const tVer = readFileSync(tplRules, 'utf-8').match(/<!--\s*version:\s*(\S+)\s*-->/)?.[1];
763
- if (uVer && tVer && uVer !== tVer) {
764
- console.log(` ${yellow('!')} Skill rules ${dim(uVer)} → ${bold(tVer)} available. Run ${cyan('mindos init-skills --force')} to update ${dim('(user-rules.md preserved)')}\n`);
765
- }
766
- } else if (!existsSync(resolve(mindRoot, '.agents', 'skills', sName))) {
767
- console.log(` ${dim('Tip:')} Run ${cyan('mindos init-skills')} to enable skill rules in your knowledge base.\n`);
768
- }
769
- }
770
- } catch {}
771
701
  },
772
702
 
773
703
  // ── uninstall ──────────────────────────────────────────────────────────────
@@ -1212,7 +1142,7 @@ ${row('mindos gateway <subcommand>', 'Manage background service (install/u
1212
1142
  ${bold('Config & Diagnostics:')}
1213
1143
  ${row('mindos config <subcommand>', 'View/update config (show/validate/set/unset)')}
1214
1144
  ${row('mindos doctor', 'Health check (config, ports, build, daemon)')}
1215
- ${row('mindos init-skills [--force]', 'Initialize skill rules in knowledge base')}
1145
+ ${row('mindos init-skills', 'Create user-skill-rules.md for personalization')}
1216
1146
  ${row('mindos update', 'Update MindOS to the latest version')}
1217
1147
  ${row('mindos uninstall', 'Fully uninstall MindOS (stop, remove daemon, npm uninstall)')}
1218
1148
  ${row('mindos logs', 'Tail service logs (~/.mindos/mindos.log)')}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geminilight/mindos",
3
- "version": "0.5.22",
3
+ "version": "0.5.23",
4
4
  "description": "MindOS — Human-Agent Collaborative Mind System. Local-first knowledge base that syncs your mind to all AI Agents via MCP.",
5
5
  "keywords": [
6
6
  "mindos",
@@ -57,7 +57,9 @@
57
57
  "!assets/images",
58
58
  "!mcp/node_modules",
59
59
  "!mcp/dist",
60
- "!mcp/package-lock.json"
60
+ "!mcp/package-lock.json",
61
+ "!mcp/*.tgz",
62
+ "!app/package-lock.json"
61
63
  ],
62
64
  "scripts": {
63
65
  "setup": "node scripts/setup.js",
package/scripts/setup.js CHANGED
@@ -1205,18 +1205,8 @@ async function main() {
1205
1205
  writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2) + '\n');
1206
1206
  console.log(`\n${c.green(t('cfgSaved'))}: ${c.dim(CONFIG_PATH)}`);
1207
1207
 
1208
- // ── Init skill rules in knowledge base ────────────────────────────────────
1209
- const skillName = selectedTemplate === 'zh' ? 'mindos-zh' : 'mindos';
1210
- const skillRulesDir = resolve(mindDir, '.agents', 'skills', skillName);
1211
- if (!existsSync(skillRulesDir)) {
1212
- const skillRulesLang = selectedTemplate === 'zh' ? 'zh' : 'en';
1213
- const skillRulesSource = resolve(ROOT, 'templates', 'skill-rules', skillRulesLang);
1214
- if (existsSync(skillRulesSource)) {
1215
- mkdirSync(skillRulesDir, { recursive: true });
1216
- cpSync(skillRulesSource, skillRulesDir, { recursive: true });
1217
- console.log(`${c.green('✓')} ${c.dim(`Skill rules initialized: ${skillRulesDir}`)}`);
1218
- }
1219
- }
1208
+ // ── Skill rules are now built into SKILL.md — no install needed ──────────
1209
+ // user-skill-rules.md will be created on first preference capture or via `mindos init-skills`.
1220
1210
 
1221
1211
  // ── Step 7: MCP Agent Install ──────────────────────────────────────────────
1222
1212
  write('\n');
@@ -14,13 +14,231 @@ description: >
14
14
 
15
15
  # MindOS Skill
16
16
 
17
- Load operating rules from the knowledge base, then execute the user's task.
17
+ Execute the user's task following the rules below.
18
+ User personalization rules (`user-skill-rules.md`) are included in bootstrap
19
+ context automatically when present. User rules override default rules on conflict.
18
20
 
19
- ## Protocol
21
+ ---
22
+
23
+ <!-- version: 1.0.0 -->
24
+ # MindOS Operating Rules
25
+
26
+ ## Core Principles
27
+
28
+ - Treat repository state as source of truth.
29
+ - **The directory tree loaded at bootstrap is a first-class semantic asset.** Directory names, file names, and their hierarchy encode what the user has stored and how they organize their thinking. Always reason from this structure before resorting to search — it often tells you where content lives without any tool call.
30
+ - Read before write.
31
+ - Prefer minimal, precise edits.
32
+ - Keep changes auditable and easy to review.
33
+
34
+ ## Startup Protocol
35
+
36
+ Run this sequence before substantive edits:
37
+
38
+ 1. Load root guidance.
39
+ - Prefer `mindos_bootstrap`.
40
+ - If unavailable, read root `INSTRUCTION.md` and root `README.md` directly.
41
+
42
+ 2. Discover current structure dynamically.
43
+ - Use `mindos_list_files` and targeted `mindos_search_notes`.
44
+ - Do not assume fixed top-level directory names.
45
+
46
+ 3. Load local guidance around target paths.
47
+ - Read nearby `README.md` / `INSTRUCTION.md` when present.
48
+ - Follow local conventions over global assumptions.
49
+
50
+ 4. Execute edits.
51
+
52
+ If required context is missing, continue with best effort and state assumptions explicitly.
53
+
54
+ ## Dynamic Structure Rules
55
+
56
+ - Do not hardcode a canonical directory tree.
57
+ - Infer conventions from neighboring files before creating or rewriting content.
58
+ - Mirror existing local patterns for naming, heading structure, CSV schema, and references.
59
+ - For new files, follow sibling style rather than inventing a new standard.
60
+ - **Never create files or directories in the root directory unless the user explicitly requests it.** The root is reserved for top-level governance files (README, INSTRUCTION, CONFIG). New content should be placed under the most semantically appropriate existing subdirectory. Reason from the directory tree in context to find the right home.
61
+ - When creating a new file or directory, always determine the best parent directory first by reviewing the existing structure. If no existing directory is a clear fit, propose 1-2 candidate locations and ask the user before creating.
62
+ - **After any file create/delete/move/rename, always sync affected README files.** READMEs serve as directory indexes and navigation entry points. Any operation that changes a directory's contents must trigger an automatic check and update of the README in that directory and its parent directory.
63
+
64
+ ## Pre-Write Checklist
65
+
66
+ Before any non-trivial write, confirm all checks:
67
+
68
+ 1. Target file/path is confirmed and exists or should be created.
69
+ 2. **Target location is under an appropriate subdirectory, not the root.** If unsure which directory fits best, propose candidates and ask the user.
70
+ 3. Current content has been read, or absence is explicitly confirmed.
71
+ 4. Local governance docs near the target path are considered.
72
+ 5. Edit scope is minimal and aligned with user intent.
73
+ 6. Reference/backlink impact is evaluated for path changes.
74
+
75
+ ## Tool Selection Guide
76
+
77
+ ### Discovery
78
+
79
+ - `mindos_bootstrap`: Load startup context.
80
+ - `mindos_list_files`: Inspect file tree.
81
+ - `mindos_search_notes`: Locate relevant files by keyword/scope/type/date. **When searching, always issue multiple parallel searches with different keywords upfront** — synonyms, abbreviations, English/Chinese variants, and broader/narrower terms. A single keyword is fragile; casting a wider net on the first try avoids wasted rounds.
82
+ - `mindos_get_recent`: Inspect latest activity.
83
+ - `mindos_get_backlinks`: Assess impact before rename/move/delete.
84
+
85
+ ### Read and write
86
+
87
+ - `mindos_read_file`: Read file content.
88
+ - `mindos_write_file`: Use only for true full replacement.
89
+ - `mindos_create_file`: Create `.md`/`.csv` files.
90
+ - `mindos_delete_file`: Delete only with explicit user intent.
91
+ - `mindos_rename_file`, `mindos_move_file`: Structural edits with follow-up reference checks.
92
+
93
+ ### Precise editing
94
+
95
+ - `mindos_read_lines`: Locate exact lines.
96
+ - `mindos_insert_lines`: Insert at index.
97
+ - `mindos_update_lines`: Replace specific range.
98
+ - `mindos_append_to_file`: Append to end.
99
+ - `mindos_insert_after_heading`: Insert under heading.
100
+ - `mindos_update_section`: Replace one markdown section.
101
+
102
+ ### History and tables
103
+
104
+ - `mindos_get_history`, `mindos_get_file_at_version`: Investigate/recover history.
105
+ - `mindos_append_csv`: Append validated row after header check.
106
+
107
+ ## Fallback Rules
108
+
109
+ - If some `mindos_*` tools are unavailable, use equivalent available tools while preserving the same safety discipline.
110
+ - If `mindos_bootstrap` is unavailable, do manual startup reads.
111
+ - If line/section edit tools are unavailable, emulate minimal edits through read plus constrained rewrite.
112
+ - If `mindos_search_notes` returns no results, do not give up. The directory tree loaded at bootstrap is already in your context. Escalate progressively:
113
+ 1. Review the directory structure already in context. Reason about which directories and files are likely relevant based on naming, hierarchy, and topic proximity.
114
+ 2. Read the most promising candidate files directly to confirm relevance.
115
+ 3. If candidates are unclear, use `mindos_list_files` on a specific subdirectory for finer-grained structure.
116
+ 4. Try alternative search terms (synonyms, broader/narrower keywords, English/Chinese variants) as a parallel strategy.
117
+
118
+ ## Safety Rules
119
+
120
+ - By default, treat root `INSTRUCTION.md`, root `README.md`, and any directory-level `INSTRUCTION.md` governance docs as high-sensitivity; ask for confirmation before modifying them.
121
+ - Ask before high-impact actions (bulk deletion, large-scale rename/move, broad directory restructuring, cross-file mass rewrites).
122
+ - **When an operation will touch multiple files, always present the full change plan to the user first.** List each target file, what will change, and why. Wait for approval before executing.
123
+ - Never store secrets, tokens, or passwords.
124
+ - Never delete or rewrite outside user intent.
125
+
126
+ ## Quality Gates
127
+
128
+ Before finishing any operation, verify:
129
+
130
+ 1. Result directly answers user intent.
131
+ 2. Updated content matches local style and structure.
132
+ 3. References/links remain valid after structural edits.
133
+ 4. No sensitive information was introduced.
134
+ 5. Summary to user is specific enough for quick audit.
135
+
136
+ ## Preference Capture
137
+
138
+ When the user expresses a preference correction during operations (e.g., "don't do X in the future", "next time remember to...", "this should go in... not in..."), append it as a structured rule to `user-skill-rules.md` in the knowledge base root under the appropriate section. Confirm to the user: "Preference recorded."
139
+
140
+ ---
141
+
142
+ # Execution Patterns
143
+
144
+ Select the matching pattern below. All patterns share a common discipline: search -> read -> minimal edit -> verify -> summarize.
145
+
146
+ ## Core Patterns (high-frequency)
147
+
148
+ ### Capture or update notes
149
+ Search -> read target + local rules -> apply minimal edit -> keep references consistent.
150
+
151
+ ### Context-aware question answering
152
+ Reason from directory tree -> read relevant files -> answer grounded in stored content with file citations -> if info is missing, say so explicitly.
153
+
154
+ ### Structure-aware multi-file routing
155
+ For unstructured inputs (meeting notes, braindumps, chat exports) that belong in multiple places:
156
+ 1. Parse input into semantic units (facts, decisions, action items, ideas).
157
+ 2. For each unit, search + read candidate destination files.
158
+ 3. **Present routing plan to user for approval** (table: what -> which file -> where).
159
+ 4. Apply minimal edits. Create new files only when no existing file fits.
160
+ 5. Summarize all changes for audit.
161
+
162
+ ### Conversation retrospective
163
+ 1. Confirm scope with user.
164
+ 2. Extract reusable artifacts: decisions, rationale, pitfalls, next actions.
165
+ 3. Route each to the best existing file (or create near related docs).
166
+ 4. Add trace note of what changed and why. Ask user when routing confidence is low.
167
+
168
+ ## Structural Change Patterns (always apply after file create/delete/move/rename)
169
+
170
+ - **Rename/move**: `get_backlinks` -> report impact -> confirm -> execute -> update all references -> verify no orphans.
171
+ - **Auto-sync READMEs**: After any structural change, update README in affected directories + parent directories to reflect current contents. This is automatic.
172
+
173
+ ## Reference Patterns (use when task matches)
174
+
175
+ | Pattern | Key steps |
176
+ |---------|-----------|
177
+ | CSV operations | Read header -> validate fields -> append row |
178
+ | TODO/task management | Locate list -> read format -> minimal edit preserving conventions |
179
+ | SOP/workflow execution | Read doc fully -> execute stepwise -> update only affected section |
180
+ | Cross-agent handoff | Read task state + decisions -> continue without re-discovery -> write back progress |
181
+ | Knowledge conflict resolution | Multi-term search for old info -> list all affected files -> present change plan -> update after approval |
182
+ | Distill experience into SOP | Extract procedure -> generalize -> create under Workflows/ with prerequisites, steps, pitfalls |
183
+ | Periodic review/summary | `get_recent`/`get_history` -> read changed files -> categorize -> structured summary |
184
+ | Handoff document synthesis | Identify sources -> read -> synthesize (background, decisions, status, open items) -> place in project dir |
185
+ | Relationship management | Extract updates from notes -> update contact records -> generate next-step strategy |
186
+ | Information collection | Locate sources -> read outreach docs -> personalize per target -> write back outcomes |
187
+ | Project bootstrap | Read preference/stack docs -> scaffold aligned with standards -> record decisions |
188
+ | Code review | Read review standards -> check naming/security/performance -> output actionable findings |
189
+ | Distill cross-agent discussion | Confirm decisions with user -> structure as problem/decision/rationale/next-actions -> minimal write-back |
190
+
191
+ ## Interaction Rules
192
+
193
+ - **When a request is ambiguous or too broad (e.g., "help me organize things"), always ask for clarification before acting.** Propose specific options based on what you see in the knowledge base (recent changes, directory structure), but do not start reorganizing or rewriting without understanding the user's intent and scope.
194
+ - When presenting search results or options, prioritize brevity and relevance. Show the most likely match first.
195
+ - When answering questions from stored knowledge, always cite the source file path so the user can verify.
196
+
197
+ ---
198
+
199
+ # Post-Task Hooks
200
+
201
+ After completing a task, check the conditions below. If one matches, make a one-line proposal to the user. If none match, end quietly.
202
+
203
+ ## Discipline
204
+
205
+ 1. Do not propose after simple operations (rename, append one line, read-only queries).
206
+ 2. At most 1 proposal per task — pick the highest priority match.
207
+ 3. One sentence + specific target file/path. Only expand if the user says yes.
208
+ 4. Check user-skill-rules.md suppression section first — skip any suppressed hook.
209
+
210
+ ## Default Hooks
211
+
212
+ ### Experience capture (priority: high)
213
+ - Condition: task involved debugging, troubleshooting, or took multiple rounds to resolve.
214
+ - Propose: "Record this experience to {related experience file}?"
215
+ - Format: problem -> cause -> solution -> rule
216
+
217
+ ### Consistency sync (priority: high)
218
+ - Condition: edited file A, and A is referenced by other files (check via `get_backlinks`).
219
+ - Propose: "{B} references what you just changed — sync it?"
220
+
221
+ ### Linked update (priority: medium)
222
+ - Condition: changed a CSV/TODO item status, and related docs exist.
223
+ - Propose: "Sync the corresponding info in {related doc}?"
224
+
225
+ ### Structure classification (priority: medium)
226
+ - Condition: created a new file in a temporary location or inbox.
227
+ - Propose: "Move this to {recommended directory}?"
228
+
229
+ ### Pattern extraction (priority: low)
230
+ - Condition: 3+ structurally similar operations in the current session.
231
+ - Propose: "This operation repeated multiple times — create an SOP?"
232
+
233
+ ### Conversation retrospective (priority: low)
234
+ - Condition: session >10 turns and involved decisions, trade-offs, or lessons.
235
+ - Propose: "This conversation had some decisions worth capturing — do a retrospective?"
236
+
237
+ ## User-defined Hooks
20
238
 
21
- 1. Read `.agents/skills/mindos/skill-rules.md` operating rules.
22
- - If not found: fall back to `mindos_bootstrap` (or read root INSTRUCTION.md
23
- + README.md). Inform user: "Run `mindos init-skills` for full skill rules."
24
- 2. If `.agents/skills/mindos/user-rules.md` exists and is non-empty:
25
- read it. User rules override default rules on conflict.
26
- 3. Execute task following loaded rules. After completion, evaluate proactive hooks.
239
+ <!-- Add your own hooks below, following the same format. -->
240
+ <!-- Example:
241
+ ### Weekly report material (priority: medium)
242
+ - Condition: updated a Project-related file.
243
+ - Propose: "Record this change in the weekly report?"
244
+ -->