maskweaver 0.9.3 → 0.9.5

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 (246) hide show
  1. package/README.ko.md +279 -325
  2. package/README.md +109 -113
  3. package/assets/commands/meta/commands.json +34 -34
  4. package/assets/commands/weave-agents.md +12 -52
  5. package/assets/commands/weave-approve.md +12 -51
  6. package/assets/commands/weave-archive.md +21 -0
  7. package/assets/commands/weave-build.md +20 -89
  8. package/assets/commands/weave-craft.md +22 -43
  9. package/assets/commands/weave-help.md +37 -106
  10. package/assets/commands/weave-init.md +26 -108
  11. package/assets/commands/weave-interview.md +13 -111
  12. package/assets/commands/weave-map.md +13 -99
  13. package/assets/commands/weave-prepare.md +23 -69
  14. package/assets/commands/weave-refine-plan.md +26 -59
  15. package/assets/commands/weave-repair.md +22 -70
  16. package/assets/commands/weave-status.md +22 -155
  17. package/assets/commands/weave-troubleshoot.md +11 -47
  18. package/assets/commands/weave-verify.md +23 -44
  19. package/assets/commands/weave-worktree.md +27 -69
  20. package/dist/cli/doctor.js +5 -21
  21. package/dist/cli/install.d.ts +0 -8
  22. package/dist/cli/install.js +0 -39
  23. package/dist/context/config.d.ts +0 -22
  24. package/dist/context/config.js +0 -28
  25. package/dist/context/feature.d.ts +0 -39
  26. package/dist/context/feature.js +0 -77
  27. package/dist/context/files.d.ts +0 -13
  28. package/dist/context/files.js +1 -24
  29. package/dist/context/index.d.ts +0 -7
  30. package/dist/context/index.js +0 -12
  31. package/dist/context/project.d.ts +0 -21
  32. package/dist/context/project.js +0 -30
  33. package/dist/context/types.d.ts +0 -48
  34. package/dist/context/types.js +0 -12
  35. package/dist/context/utils.d.ts +0 -18
  36. package/dist/context/utils.js +0 -27
  37. package/dist/core/engine/promptBuilder.d.ts +0 -17
  38. package/dist/core/engine/promptBuilder.js +0 -28
  39. package/dist/core/index.d.ts +0 -6
  40. package/dist/core/index.js +0 -9
  41. package/dist/core/loader/MaskLoader.d.ts +0 -23
  42. package/dist/core/loader/MaskLoader.js +0 -29
  43. package/dist/core/schema/types.d.ts +0 -47
  44. package/dist/core/schema/types.js +0 -6
  45. package/dist/core/schema/validator.d.ts +0 -14
  46. package/dist/core/schema/validator.js +0 -18
  47. package/dist/i18n/index.d.ts +0 -18
  48. package/dist/i18n/index.js +4 -23
  49. package/dist/index.d.ts +0 -8
  50. package/dist/index.js +0 -8
  51. package/dist/lib.d.ts +0 -5
  52. package/dist/lib.js +0 -12
  53. package/dist/memory/chunking.d.ts +0 -22
  54. package/dist/memory/chunking.js +2 -37
  55. package/dist/memory/core.d.ts +0 -29
  56. package/dist/memory/core.js +1 -52
  57. package/dist/memory/index.d.ts +0 -5
  58. package/dist/memory/index.js +0 -10
  59. package/dist/memory/indexer.d.ts +0 -21
  60. package/dist/memory/indexer.js +0 -44
  61. package/dist/memory/providers/examples.d.ts +0 -5
  62. package/dist/memory/providers/examples.js +4 -64
  63. package/dist/memory/providers/factory.d.ts +0 -44
  64. package/dist/memory/providers/factory.js +0 -46
  65. package/dist/memory/providers/index.d.ts +0 -26
  66. package/dist/memory/providers/index.js +0 -28
  67. package/dist/memory/providers/ollama.d.ts +0 -6
  68. package/dist/memory/providers/ollama.js +1 -8
  69. package/dist/memory/providers/openai.d.ts +0 -6
  70. package/dist/memory/providers/openai.js +1 -8
  71. package/dist/memory/providers/openrouter.d.ts +0 -6
  72. package/dist/memory/providers/openrouter.js +0 -8
  73. package/dist/memory/providers/text-only.d.ts +0 -13
  74. package/dist/memory/providers/text-only.js +0 -17
  75. package/dist/memory/providers/types.d.ts +0 -39
  76. package/dist/memory/providers/types.js +0 -7
  77. package/dist/memory/providers/voyage.d.ts +0 -22
  78. package/dist/memory/providers/voyage.js +1 -24
  79. package/dist/memory/search/hybrid.d.ts +0 -12
  80. package/dist/memory/search/hybrid.js +1 -22
  81. package/dist/memory/store/sqlite.d.ts +0 -72
  82. package/dist/memory/store/sqlite.js +4 -127
  83. package/dist/plugin/config/index.d.ts +0 -112
  84. package/dist/plugin/config/index.js +0 -115
  85. package/dist/plugin/index.d.ts +0 -13
  86. package/dist/plugin/index.js +1 -124
  87. package/dist/plugin/tools/command-registry.d.ts +0 -6
  88. package/dist/plugin/tools/command-registry.js +0 -14
  89. package/dist/plugin/tools/context.d.ts +0 -12
  90. package/dist/plugin/tools/context.js +0 -58
  91. package/dist/plugin/tools/maskSave.d.ts +0 -3
  92. package/dist/plugin/tools/maskSave.js +0 -3
  93. package/dist/plugin/tools/memoryGet.d.ts +0 -3
  94. package/dist/plugin/tools/memoryGet.js +0 -3
  95. package/dist/plugin/tools/memoryIndexer.d.ts +0 -3
  96. package/dist/plugin/tools/memoryIndexer.js +0 -10
  97. package/dist/plugin/tools/memorySearch.d.ts +0 -31
  98. package/dist/plugin/tools/memorySearch.js +0 -79
  99. package/dist/plugin/tools/memoryWrite.d.ts +0 -8
  100. package/dist/plugin/tools/memoryWrite.js +0 -32
  101. package/dist/plugin/tools/retrospect.d.ts +0 -3
  102. package/dist/plugin/tools/retrospect.js +0 -3
  103. package/dist/plugin/tools/slashcommand.d.ts +0 -11
  104. package/dist/plugin/tools/slashcommand.js +0 -38
  105. package/dist/plugin/tools/squad.d.ts +0 -12
  106. package/dist/plugin/tools/squad.js +11 -83
  107. package/dist/plugin/tools/weave.d.ts +0 -6
  108. package/dist/plugin/tools/weave.js +0 -78
  109. package/dist/plugin/types.d.ts +0 -20
  110. package/dist/plugin/types.js +0 -7
  111. package/dist/retrospect/index.d.ts +0 -7
  112. package/dist/retrospect/index.js +0 -9
  113. package/dist/retrospect/mask-save.d.ts +0 -12
  114. package/dist/retrospect/mask-save.js +1 -80
  115. package/dist/retrospect/retrospect.d.ts +0 -18
  116. package/dist/retrospect/retrospect.js +0 -63
  117. package/dist/retrospect/strategies/base.d.ts +0 -15
  118. package/dist/retrospect/strategies/base.js +0 -7
  119. package/dist/retrospect/strategies/deep.d.ts +0 -12
  120. package/dist/retrospect/strategies/deep.js +0 -24
  121. package/dist/retrospect/strategies/index.d.ts +0 -12
  122. package/dist/retrospect/strategies/index.js +0 -12
  123. package/dist/retrospect/strategies/quick.d.ts +0 -12
  124. package/dist/retrospect/strategies/quick.js +0 -19
  125. package/dist/retrospect/strategies/standard.d.ts +0 -12
  126. package/dist/retrospect/strategies/standard.js +0 -15
  127. package/dist/retrospect/types.d.ts +0 -7
  128. package/dist/retrospect/types.js +0 -7
  129. package/dist/shared/config.d.ts +0 -105
  130. package/dist/shared/config.js +0 -33
  131. package/dist/shared/errors.d.ts +0 -18
  132. package/dist/shared/errors.js +0 -19
  133. package/dist/shared/generate-agents.d.ts +0 -69
  134. package/dist/shared/generate-agents.js +2 -86
  135. package/dist/shared/image.d.ts +0 -67
  136. package/dist/shared/image.js +6 -104
  137. package/dist/shared/index.d.ts +0 -5
  138. package/dist/shared/index.js +0 -7
  139. package/dist/shared/model-registry.d.ts +0 -72
  140. package/dist/shared/model-registry.js +5 -95
  141. package/dist/shared/types.d.ts +0 -15
  142. package/dist/shared/types.js +0 -3
  143. package/dist/shared-context/dag.d.ts +0 -105
  144. package/dist/shared-context/dag.js +3 -114
  145. package/dist/shared-context/index.d.ts +0 -5
  146. package/dist/shared-context/index.js +0 -15
  147. package/dist/shared-context/logger.d.ts +0 -37
  148. package/dist/shared-context/logger.js +0 -41
  149. package/dist/shared-context/parallel-executor.d.ts +0 -54
  150. package/dist/shared-context/parallel-executor.js +4 -56
  151. package/dist/shared-context/session.d.ts +0 -56
  152. package/dist/shared-context/session.js +0 -47
  153. package/dist/shared-context/squad.d.ts +0 -68
  154. package/dist/shared-context/squad.js +0 -63
  155. package/dist/shared-context/storage.d.ts +0 -132
  156. package/dist/shared-context/storage.js +0 -116
  157. package/dist/shared-context/task.d.ts +0 -120
  158. package/dist/shared-context/task.js +0 -152
  159. package/dist/shared-context/test/dag.test.js +9 -14
  160. package/dist/shared-context/test/logger.test.d.ts +0 -8
  161. package/dist/shared-context/test/logger.test.js +0 -52
  162. package/dist/shared-context/test/session.test.d.ts +0 -7
  163. package/dist/shared-context/test/session.test.js +0 -63
  164. package/dist/shared-context/test/squad.test.d.ts +0 -10
  165. package/dist/shared-context/test/squad.test.js +2 -68
  166. package/dist/shared-context/test/storage.test.d.ts +0 -8
  167. package/dist/shared-context/test/storage.test.js +0 -68
  168. package/dist/shared-context/test/task.test.d.ts +0 -7
  169. package/dist/shared-context/test/task.test.js +0 -54
  170. package/dist/shared-context/test/watchdog.test.d.ts +0 -7
  171. package/dist/shared-context/test/watchdog.test.js +3 -58
  172. package/dist/shared-context/types.d.ts +0 -215
  173. package/dist/shared-context/types.js +0 -125
  174. package/dist/shared-context/watchdog.d.ts +0 -127
  175. package/dist/shared-context/watchdog.js +0 -148
  176. package/dist/shared-context/worktree.d.ts +0 -68
  177. package/dist/shared-context/worktree.js +2 -34
  178. package/dist/verify/budget.d.ts +0 -29
  179. package/dist/verify/budget.js +0 -34
  180. package/dist/verify/critical-files.d.ts +0 -17
  181. package/dist/verify/critical-files.js +0 -37
  182. package/dist/verify/escalation.d.ts +0 -20
  183. package/dist/verify/escalation.js +0 -22
  184. package/dist/verify/index.d.ts +0 -5
  185. package/dist/verify/index.js +0 -11
  186. package/dist/verify/prompts.d.ts +0 -20
  187. package/dist/verify/prompts.js +0 -20
  188. package/dist/verify/types.d.ts +0 -26
  189. package/dist/verify/types.js +1 -12
  190. package/dist/verify/verifier.d.ts +0 -29
  191. package/dist/verify/verifier.js +0 -54
  192. package/dist/version.d.ts +1 -16
  193. package/dist/version.js +1 -16
  194. package/dist/weave/bridge.d.ts +0 -35
  195. package/dist/weave/bridge.js +0 -51
  196. package/dist/weave/environment/detector.d.ts +0 -6
  197. package/dist/weave/environment/detector.js +4 -45
  198. package/dist/weave/environment/index.d.ts +0 -19
  199. package/dist/weave/environment/index.js +1 -39
  200. package/dist/weave/environment/issues.d.ts +0 -35
  201. package/dist/weave/environment/issues.js +0 -59
  202. package/dist/weave/git.d.ts +0 -8
  203. package/dist/weave/git.js +0 -8
  204. package/dist/weave/index.d.ts +0 -13
  205. package/dist/weave/index.js +2 -28
  206. package/dist/weave/knowledge/global.d.ts +0 -39
  207. package/dist/weave/knowledge/global.js +2 -78
  208. package/dist/weave/loop.js +0 -3
  209. package/dist/weave/orchestrator.d.ts +0 -69
  210. package/dist/weave/orchestrator.js +1 -101
  211. package/dist/weave/phase-manager.d.ts +0 -64
  212. package/dist/weave/phase-manager.js +0 -89
  213. package/dist/weave/security/secret-scan.d.ts +0 -14
  214. package/dist/weave/security/secret-scan.js +0 -19
  215. package/dist/weave/stages/build.js +0 -15
  216. package/dist/weave/stages/execute.d.ts +0 -42
  217. package/dist/weave/stages/execute.js +4 -86
  218. package/dist/weave/stages/handoff.d.ts +0 -7
  219. package/dist/weave/stages/handoff.js +0 -43
  220. package/dist/weave/stages/index.d.ts +0 -3
  221. package/dist/weave/stages/index.js +0 -3
  222. package/dist/weave/stages/intake.d.ts +0 -8
  223. package/dist/weave/stages/intake.js +5 -65
  224. package/dist/weave/stages/map.d.ts +0 -1
  225. package/dist/weave/stages/openspec.d.ts +0 -1
  226. package/dist/weave/stages/plan.d.ts +0 -11
  227. package/dist/weave/stages/plan.js +1 -53
  228. package/dist/weave/stages/refine.d.ts +0 -7
  229. package/dist/weave/stages/refine.js +0 -7
  230. package/dist/weave/stages/research.d.ts +0 -6
  231. package/dist/weave/stages/research.js +0 -6
  232. package/dist/weave/stages/spec.d.ts +0 -12
  233. package/dist/weave/stages/spec.js +0 -17
  234. package/dist/weave/types.d.ts +0 -20
  235. package/dist/weave/types.js +0 -5
  236. package/dist/weave/verification/commands.d.ts +0 -12
  237. package/dist/weave/verification/commands.js +0 -19
  238. package/dist/weave/verification/index.d.ts +0 -6
  239. package/dist/weave/verification/index.js +1 -19
  240. package/dist/weave/verification/playwright.d.ts +0 -47
  241. package/dist/weave/verification/playwright.js +1 -90
  242. package/dist/weave/worktree.d.ts +0 -16
  243. package/dist/weave/worktree.js +0 -23
  244. package/dist/weave/yaml-repair.d.ts +0 -39
  245. package/dist/weave/yaml-repair.js +13 -116
  246. package/package.json +1 -1
@@ -1,15 +1,8 @@
1
- /**
2
- * Memory Indexer Tool - Index memory files for semantic search
3
- */
4
1
  import { z } from "zod";
5
2
  import { indexFile, reindexFile, indexAllMemoryFiles } from "../../memory/index.js";
6
3
  import { createProvider, selectBestProvider } from "../../memory/index.js";
7
4
  import { getMemoryProviderConfig } from "../../shared/config.js";
8
- /**
9
- * Get embedding provider based on configuration
10
- */
11
5
  async function getConfiguredProvider(worktree) {
12
- // Try to load config from maskweaver.config.json
13
6
  const memoryConfig = getMemoryProviderConfig(worktree);
14
7
  if (memoryConfig && memoryConfig.provider) {
15
8
  const providerConfig = {
@@ -30,7 +23,6 @@ async function getConfiguredProvider(worktree) {
30
23
  console.warn(`Failed to create provider: ${error}`);
31
24
  }
32
25
  }
33
- // Fallback
34
26
  const fallbackConfigs = [
35
27
  { type: "ollama", model: "bge-m3", dimensions: 1024 },
36
28
  { type: "ollama", model: "nomic-embed-text", dimensions: 768 },
@@ -53,13 +45,11 @@ Actions:
53
45
  async execute(args, context) {
54
46
  try {
55
47
  const basePath = context.worktree;
56
- // Create embedding provider from config
57
48
  const provider = await getConfiguredProvider(basePath);
58
49
  const getEmbedding = async (text) => {
59
50
  const embeddings = await provider.embed([text]);
60
51
  return embeddings[0];
61
52
  };
62
- // Execute action
63
53
  switch (args.action) {
64
54
  case "index":
65
55
  await indexFile(args.path, getEmbedding, basePath);
@@ -1,27 +1,4 @@
1
- /**
2
- * Memory Search Tool
3
- *
4
- * Hybrid search: Vector similarity + Text matching
5
- *
6
- * "Clear is better than clever." - Rob Pike
7
- *
8
- * Architecture:
9
- * - Lazy provider initialization (only on first call)
10
- * - Graceful degradation (auto-fallback to working providers)
11
- * - Result caching at provider level
12
- * - JSON response format for consistent parsing
13
- */
14
1
  import { z } from "zod";
15
- /**
16
- * Memory search arguments schema
17
- *
18
- * Sources:
19
- * - memory: Long-term knowledge (MEMORY.md)
20
- * - masks: Mask usage history and effectiveness
21
- * - retrospect: Daily retrospectives and lessons
22
- * - daily: Today's work log
23
- * - user: User preferences and information (USER.md)
24
- */
25
2
  declare const memorySearchArgsSchema: z.ZodObject<{
26
3
  query: z.ZodString;
27
4
  maxResults: z.ZodOptional<z.ZodNumber>;
@@ -38,14 +15,6 @@ type MemorySearchArgs = z.infer<typeof memorySearchArgsSchema>;
38
15
  export interface MemorySearchToolContext {
39
16
  worktree: string;
40
17
  }
41
- /**
42
- * Create memory search tool
43
- *
44
- * Factory pattern allows:
45
- * - Dependency injection (context)
46
- * - Testing with mock providers
47
- * - Configuration per instance
48
- */
49
18
  export declare function createMemorySearchTool(): {
50
19
  description: string;
51
20
  args: z.ZodObject<{
@@ -1,33 +1,7 @@
1
- /**
2
- * Memory Search Tool
3
- *
4
- * Hybrid search: Vector similarity + Text matching
5
- *
6
- * "Clear is better than clever." - Rob Pike
7
- *
8
- * Architecture:
9
- * - Lazy provider initialization (only on first call)
10
- * - Graceful degradation (auto-fallback to working providers)
11
- * - Result caching at provider level
12
- * - JSON response format for consistent parsing
13
- */
14
1
  import { z } from "zod";
15
2
  import { hybridSearch, initDatabase, getDbPath, selectBestProvider, createProvider, CONFIG, } from "../../memory/index.js";
16
3
  import { getMemoryProviderConfig } from "../../shared/config.js";
17
4
  import path from "node:path";
18
- // ============================================================================
19
- // Schema Definition
20
- // ============================================================================
21
- /**
22
- * Memory search arguments schema
23
- *
24
- * Sources:
25
- * - memory: Long-term knowledge (MEMORY.md)
26
- * - masks: Mask usage history and effectiveness
27
- * - retrospect: Daily retrospectives and lessons
28
- * - daily: Today's work log
29
- * - user: User preferences and information (USER.md)
30
- */
31
5
  const memorySearchArgsSchema = z.object({
32
6
  query: z.string().describe("Natural language search query"),
33
7
  maxResults: z.number().optional().describe("Maximum results to return (default: 6)"),
@@ -37,37 +11,14 @@ const memorySearchArgsSchema = z.object({
37
11
  .optional()
38
12
  .describe("Filter by source types (default: all)"),
39
13
  });
40
- // ============================================================================
41
- // Provider State (Singleton Pattern)
42
- // ============================================================================
43
- /**
44
- * Lazy-initialized embedding provider
45
- *
46
- * Benefits:
47
- * - No initialization cost if tool is never used
48
- * - Automatic provider selection on first use
49
- * - Shared across all search calls
50
- */
51
14
  let providerInstance = null;
52
15
  let providerWorktree = null;
53
- /**
54
- * Get or initialize the embedding provider
55
- *
56
- * Reads configuration from maskweaver.config.json if available.
57
- * Falls back to default provider chain if no config found.
58
- *
59
- * @param worktree - Project root path for config lookup
60
- * @returns Initialized provider (may be text-only fallback)
61
- */
62
16
  async function getProvider(worktree) {
63
- // Return cached provider if same worktree
64
17
  if (providerInstance && providerWorktree === worktree) {
65
18
  return providerInstance;
66
19
  }
67
- // Try to load config from maskweaver.config.json
68
20
  const memoryConfig = getMemoryProviderConfig(worktree);
69
21
  if (memoryConfig && memoryConfig.provider) {
70
- // Use configured provider
71
22
  const providerConfig = {
72
23
  type: memoryConfig.provider,
73
24
  model: memoryConfig.model,
@@ -90,7 +41,6 @@ async function getProvider(worktree) {
90
41
  console.warn(`Failed to create provider: ${error}`);
91
42
  }
92
43
  }
93
- // Fallback: Try Ollama with bge-m3 (common default)
94
44
  const fallbackConfigs = [
95
45
  { type: "ollama", model: "bge-m3", dimensions: 1024 },
96
46
  { type: "ollama", model: "nomic-embed-text", dimensions: 768 },
@@ -100,14 +50,6 @@ async function getProvider(worktree) {
100
50
  providerWorktree = worktree;
101
51
  return providerInstance;
102
52
  }
103
- /**
104
- * Create memory search tool
105
- *
106
- * Factory pattern allows:
107
- * - Dependency injection (context)
108
- * - Testing with mock providers
109
- * - Configuration per instance
110
- */
111
53
  export function createMemorySearchTool() {
112
54
  return {
113
55
  description: `Search memories using semantic similarity and keyword matching.
@@ -122,32 +64,18 @@ Keywords: "remember", "before", "last time", "previous"`,
122
64
  args: memorySearchArgsSchema,
123
65
  async execute(args, context) {
124
66
  try {
125
- // Configuration with defaults
126
67
  const maxResults = args.maxResults ?? CONFIG.search.defaultMaxResults;
127
68
  const minScore = args.minScore ?? CONFIG.search.defaultMinScore;
128
- // ====================================================================
129
- // 1. Initialize Database
130
- // ====================================================================
131
69
  const dbPath = getDbPath(context.worktree);
132
70
  await initDatabase(dbPath);
133
- // ====================================================================
134
- // 2. Get Embedding Provider (lazy initialization)
135
- // ====================================================================
136
71
  const provider = await getProvider(context.worktree);
137
- // Generate query embedding (embed takes array, returns array)
138
72
  const embeddingResults = await provider.embed([args.query]);
139
73
  const embedding = embeddingResults[0];
140
- // ====================================================================
141
- // 3. Hybrid Search
142
- // ====================================================================
143
74
  const results = hybridSearch(args.query, embedding, {
144
75
  limit: maxResults,
145
76
  minScore: minScore,
146
77
  sourceFilter: args.sources,
147
78
  });
148
- // ====================================================================
149
- // 4. Format Results
150
- // ====================================================================
151
79
  if (results.length === 0) {
152
80
  return JSON.stringify({
153
81
  results: [],
@@ -156,7 +84,6 @@ Keywords: "remember", "before", "last time", "previous"`,
156
84
  message: "No relevant memories found.",
157
85
  }, null, 2);
158
86
  }
159
- // Convert to relative paths and truncate snippets
160
87
  const formattedResults = results.map((r) => {
161
88
  const relativePath = path.relative(context.worktree, r.chunk.path);
162
89
  const snippet = r.chunk.text.length > 200
@@ -179,11 +106,7 @@ Keywords: "remember", "before", "last time", "previous"`,
179
106
  }, null, 2);
180
107
  }
181
108
  catch (error) {
182
- // ====================================================================
183
- // 5. Error Handling
184
- // ====================================================================
185
109
  const message = error instanceof Error ? error.message : String(error);
186
- // Embedding service connection failure
187
110
  if (message.includes("fetch") || message.includes("ECONNREFUSED")) {
188
111
  return JSON.stringify({
189
112
  error: true,
@@ -191,7 +114,6 @@ Keywords: "remember", "before", "last time", "previous"`,
191
114
  query: args.query,
192
115
  }, null, 2);
193
116
  }
194
- // Database initialization failure
195
117
  if (message.includes("Database") || message.includes("SQLite")) {
196
118
  return JSON.stringify({
197
119
  error: true,
@@ -199,7 +121,6 @@ Keywords: "remember", "before", "last time", "previous"`,
199
121
  query: args.query,
200
122
  }, null, 2);
201
123
  }
202
- // Generic error
203
124
  return JSON.stringify({
204
125
  error: true,
205
126
  message: message,
@@ -1,10 +1,2 @@
1
- /**
2
- * Memory Write Tool
3
- *
4
- * Saves content to memory files with automatic indexing.
5
- * Each function does one thing well.
6
- *
7
- * @author Kent Beck's Dummy Human
8
- */
9
1
  import type { ToolFactory } from "../types.js";
10
2
  export declare function createMemoryWriteTool(): ToolFactory;
@@ -1,26 +1,12 @@
1
- /**
2
- * Memory Write Tool
3
- *
4
- * Saves content to memory files with automatic indexing.
5
- * Each function does one thing well.
6
- *
7
- * @author Kent Beck's Dummy Human
8
- */
9
1
  import { z } from "zod";
10
2
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
11
3
  import { dirname, join, relative } from "path";
12
4
  import { getMemoryPath, getTodayFileName, } from "../../memory/index.js";
13
- // ============================================================================
14
- // Schema Definition
15
- // ============================================================================
16
5
  const memoryWriteArgsSchema = z.object({
17
6
  content: z.string().describe("Content to save (markdown format)"),
18
7
  target: z.enum(["daily", "memory", "user"]).describe("Target location"),
19
8
  section: z.string().optional().describe("Section title (e.g., 'User Preferences')"),
20
9
  });
21
- // ============================================================================
22
- // Tool Factory
23
- // ============================================================================
24
10
  export function createMemoryWriteTool() {
25
11
  return {
26
12
  description: `Saves content to memory files.
@@ -44,9 +30,6 @@ export function createMemoryWriteTool() {
44
30
  },
45
31
  };
46
32
  }
47
- // ============================================================================
48
- // Path Resolution
49
- // ============================================================================
50
33
  function determineFilePath(target, worktree) {
51
34
  if (target === "daily") {
52
35
  const dailyDir = getMemoryPath("daily", worktree);
@@ -54,9 +37,6 @@ function determineFilePath(target, worktree) {
54
37
  }
55
38
  return getMemoryPath(target, worktree);
56
39
  }
57
- // ============================================================================
58
- // File System Operations
59
- // ============================================================================
60
40
  function ensureDirectoryExists(filePath) {
61
41
  const dir = dirname(filePath);
62
42
  if (!existsSync(dir)) {
@@ -73,9 +53,6 @@ function saveContent(filePath, content) {
73
53
  const normalized = content.trim() + "\n";
74
54
  writeFileSync(filePath, normalized, "utf-8");
75
55
  }
76
- // ============================================================================
77
- // Content Building
78
- // ============================================================================
79
56
  function buildNewContent(existing, newText, section) {
80
57
  if (section) {
81
58
  return updateSection(existing, section, newText);
@@ -127,21 +104,12 @@ function buildEntry(timestamp, text) {
127
104
  function isEmpty(content) {
128
105
  return content.trim().length === 0;
129
106
  }
130
- // ============================================================================
131
- // Indexing
132
- // ============================================================================
133
107
  async function tryReindexing(_filePath) {
134
- // NOTE: Reindexing requires embedding provider setup
135
- // For now, skip auto-reindex on write. Use memory_indexer tool instead.
136
- // To enable: instantiate provider and call reindexFile(filePath, getEmbedding)
137
108
  }
138
109
  function logIndexingWarning(error) {
139
110
  const message = error instanceof Error ? error.message : String(error);
140
111
  console.warn("[memoryWrite] Indexing skipped:", message);
141
112
  }
142
- // ============================================================================
143
- // Response Formatting
144
- // ============================================================================
145
113
  function formatSuccessResponse(filePath, target, worktree) {
146
114
  const relativePath = relative(worktree, filePath);
147
115
  return JSON.stringify({
@@ -1,5 +1,2 @@
1
- /**
2
- * Retrospect Tool - Session retrospective
3
- */
4
1
  import type { ToolFactory } from "../types.js";
5
2
  export declare function createRetrospectTool(): ToolFactory;
@@ -1,6 +1,3 @@
1
- /**
2
- * Retrospect Tool - Session retrospective
3
- */
4
1
  import { z } from "zod";
5
2
  import { performRetrospect } from "../../retrospect/index.js";
6
3
  export function createRetrospectTool() {
@@ -1,14 +1,3 @@
1
- /**
2
- * Slashcommand Tool for OpenCode Plugin
3
- *
4
- * Handles slash commands directly as a tool, inspired by oh-my-opencode.
5
- * This ensures commands work on first run without requiring restart.
6
- *
7
- * Pattern: Commands are discovered from:
8
- * 1. Built-in embedded commands (always available)
9
- * 2. Package assets/commands/ folder
10
- * 3. Project .opencode/commands/ folder (overrides)
11
- */
12
1
  import { z } from 'zod';
13
2
  export declare function createSlashcommandTool(assetsDir?: string): {
14
3
  description: string;
@@ -1,24 +1,9 @@
1
- /**
2
- * Slashcommand Tool for OpenCode Plugin
3
- *
4
- * Handles slash commands directly as a tool, inspired by oh-my-opencode.
5
- * This ensures commands work on first run without requiring restart.
6
- *
7
- * Pattern: Commands are discovered from:
8
- * 1. Built-in embedded commands (always available)
9
- * 2. Package assets/commands/ folder
10
- * 3. Project .opencode/commands/ folder (overrides)
11
- */
12
1
  import { z } from 'zod';
13
- // Inline shim: tool() is just an identity function in @opencode-ai/plugin
14
2
  const tool = (input) => input;
15
3
  import * as fs from 'node:fs';
16
4
  import * as path from 'node:path';
17
5
  import { parse as parseYaml } from 'yaml';
18
6
  import { loadCommandsJson } from './command-registry.js';
19
- // ============================================================================
20
- // Built-in Commands from Registry (commands.json)
21
- // ============================================================================
22
7
  function getBuiltinCommandsFromRegistry() {
23
8
  const registry = loadCommandsJson();
24
9
  const builtins = {};
@@ -40,9 +25,6 @@ function getBuiltinCommandsFromRegistry() {
40
25
  }
41
26
  return builtins;
42
27
  }
43
- // ============================================================================
44
- // Command Discovery
45
- // ============================================================================
46
28
  function parseFrontmatter(content) {
47
29
  const parts = content.split('---');
48
30
  if (parts.length < 3) {
@@ -93,17 +75,14 @@ function discoverCommandsFromDir(commandsDir, scope) {
93
75
  }
94
76
  function getAllCommands(assetsDir, projectDir) {
95
77
  const BUILTIN_COMMANDS = getBuiltinCommandsFromRegistry();
96
- // Start with builtin commands
97
78
  const commands = Object.entries(BUILTIN_COMMANDS).map(([name, cmd]) => ({
98
79
  name,
99
80
  metadata: cmd.metadata,
100
81
  content: cmd.content,
101
82
  scope: 'builtin',
102
83
  }));
103
- // Load from package assets
104
84
  if (assetsDir) {
105
85
  const packageCommands = discoverCommandsFromDir(path.join(assetsDir, 'commands'), 'package');
106
- // Package commands override builtins
107
86
  for (const cmd of packageCommands) {
108
87
  const existingIndex = commands.findIndex(c => c.name === cmd.name);
109
88
  if (existingIndex >= 0) {
@@ -114,7 +93,6 @@ function getAllCommands(assetsDir, projectDir) {
114
93
  }
115
94
  }
116
95
  }
117
- // Load from project .opencode/commands (highest priority)
118
96
  const projectCommands = discoverCommandsFromDir(path.join(projectDir, '.opencode', 'commands'), 'project');
119
97
  for (const cmd of projectCommands) {
120
98
  const existingIndex = commands.findIndex(c => c.name === cmd.name);
@@ -127,9 +105,6 @@ function getAllCommands(assetsDir, projectDir) {
127
105
  }
128
106
  return commands;
129
107
  }
130
- // ============================================================================
131
- // Tool Factory
132
- // ============================================================================
133
108
  export function createSlashcommandTool(assetsDir) {
134
109
  const registry = loadCommandsJson();
135
110
  const descLines = ['Execute a slash command. Available commands include:'];
@@ -138,7 +113,6 @@ export function createSlashcommandTool(assetsDir) {
138
113
  }
139
114
  descLines.push('');
140
115
  descLines.push('Use command="list" to see all available commands.');
141
- // Build dynamic shorthand list from registry
142
116
  const shorthandSet = new Set();
143
117
  for (const cmd of registry.commands) {
144
118
  shorthandSet.add(cmd.name);
@@ -156,9 +130,7 @@ export function createSlashcommandTool(assetsDir) {
156
130
  },
157
131
  execute: async (args, context) => {
158
132
  const projectDir = context.worktree;
159
- // Discover all commands (builtin + package + project)
160
133
  const commands = getAllCommands(assetsDir, projectDir);
161
- // Handle "list" command
162
134
  if (args.command === 'list' || !args.command) {
163
135
  const lines = ['# Available Slash Commands\n'];
164
136
  for (const cmd of commands) {
@@ -168,41 +140,31 @@ export function createSlashcommandTool(assetsDir) {
168
140
  lines.push(`\n**Total**: ${commands.length} commands`);
169
141
  return lines.join('\n');
170
142
  }
171
- // Normalize command name (remove leading /)
172
143
  let cmdName = args.command.replace(/^\//, '').toLowerCase();
173
- // Handle "weave" command with optional subcommand
174
- // e.g., "weave status" -> "weave-status"
175
- // e.g., "status" (alone) -> might mean "weave-status"
176
144
  if (cmdName.startsWith('weave ')) {
177
- // "weave design" -> "weave-design"
178
145
  cmdName = cmdName.replace(' ', '-');
179
146
  }
180
147
  else if (cmdName === 'weave') {
181
- // Just "weave" -> "weave-help"
182
148
  const helpCmd = commands.find(c => c.name === 'weave-help');
183
149
  if (helpCmd) {
184
150
  return helpCmd.content || 'Weave help content not available.';
185
151
  }
186
152
  }
187
153
  else if (shorthandList.includes(cmdName)) {
188
- // Shorthand: "status" -> "weave-status"
189
154
  const weaveCmd = commands.find(c => c.name === `weave-${cmdName}`);
190
155
  if (weaveCmd) {
191
156
  return weaveCmd.content || `weave-${cmdName} content not available.`;
192
157
  }
193
158
  }
194
- // Find exact match
195
159
  const exactMatch = commands.find(c => c.name.toLowerCase() === cmdName);
196
160
  if (exactMatch) {
197
161
  return exactMatch.content || `/${exactMatch.name} has no content.`;
198
162
  }
199
- // Find partial matches
200
163
  const partialMatches = commands.filter(c => c.name.toLowerCase().includes(cmdName));
201
164
  if (partialMatches.length > 0) {
202
165
  const matchList = partialMatches.map(c => `/${c.name}`).join(', ');
203
166
  return `No exact match for "/${cmdName}". Did you mean: ${matchList}?`;
204
167
  }
205
- // No match found
206
168
  const available = commands.slice(0, 10).map(c => `/${c.name}`).join(', ');
207
169
  return `Command "/${cmdName}" not found. Available: ${available}...`;
208
170
  },
@@ -1,15 +1,3 @@
1
- /**
2
- * Squad Management Tool
3
- *
4
- * Multi-agent collaboration session and squad management
5
- *
6
- * Design Principles:
7
- * - Intention-Revealing Code
8
- * - Clear error messages
9
- * - Consistent JSON response format (following context.ts pattern)
10
- *
11
- * @author Martin Fowler's Dummy Human
12
- */
13
1
  import { z } from "zod";
14
2
  import type { ToolFactory } from '../types.js';
15
3
  export declare const squadSchema: z.ZodObject<{