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.
- package/README.ko.md +279 -325
- package/README.md +109 -113
- package/assets/commands/meta/commands.json +34 -34
- package/assets/commands/weave-agents.md +12 -52
- package/assets/commands/weave-approve.md +12 -51
- package/assets/commands/weave-archive.md +21 -0
- package/assets/commands/weave-build.md +20 -89
- package/assets/commands/weave-craft.md +22 -43
- package/assets/commands/weave-help.md +37 -106
- package/assets/commands/weave-init.md +26 -108
- package/assets/commands/weave-interview.md +13 -111
- package/assets/commands/weave-map.md +13 -99
- package/assets/commands/weave-prepare.md +23 -69
- package/assets/commands/weave-refine-plan.md +26 -59
- package/assets/commands/weave-repair.md +22 -70
- package/assets/commands/weave-status.md +22 -155
- package/assets/commands/weave-troubleshoot.md +11 -47
- package/assets/commands/weave-verify.md +23 -44
- package/assets/commands/weave-worktree.md +27 -69
- package/dist/cli/doctor.js +5 -21
- package/dist/cli/install.d.ts +0 -8
- package/dist/cli/install.js +0 -39
- package/dist/context/config.d.ts +0 -22
- package/dist/context/config.js +0 -28
- package/dist/context/feature.d.ts +0 -39
- package/dist/context/feature.js +0 -77
- package/dist/context/files.d.ts +0 -13
- package/dist/context/files.js +1 -24
- package/dist/context/index.d.ts +0 -7
- package/dist/context/index.js +0 -12
- package/dist/context/project.d.ts +0 -21
- package/dist/context/project.js +0 -30
- package/dist/context/types.d.ts +0 -48
- package/dist/context/types.js +0 -12
- package/dist/context/utils.d.ts +0 -18
- package/dist/context/utils.js +0 -27
- package/dist/core/engine/promptBuilder.d.ts +0 -17
- package/dist/core/engine/promptBuilder.js +0 -28
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.js +0 -9
- package/dist/core/loader/MaskLoader.d.ts +0 -23
- package/dist/core/loader/MaskLoader.js +0 -29
- package/dist/core/schema/types.d.ts +0 -47
- package/dist/core/schema/types.js +0 -6
- package/dist/core/schema/validator.d.ts +0 -14
- package/dist/core/schema/validator.js +0 -18
- package/dist/i18n/index.d.ts +0 -18
- package/dist/i18n/index.js +4 -23
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/lib.d.ts +0 -5
- package/dist/lib.js +0 -12
- package/dist/memory/chunking.d.ts +0 -22
- package/dist/memory/chunking.js +2 -37
- package/dist/memory/core.d.ts +0 -29
- package/dist/memory/core.js +1 -52
- package/dist/memory/index.d.ts +0 -5
- package/dist/memory/index.js +0 -10
- package/dist/memory/indexer.d.ts +0 -21
- package/dist/memory/indexer.js +0 -44
- package/dist/memory/providers/examples.d.ts +0 -5
- package/dist/memory/providers/examples.js +4 -64
- package/dist/memory/providers/factory.d.ts +0 -44
- package/dist/memory/providers/factory.js +0 -46
- package/dist/memory/providers/index.d.ts +0 -26
- package/dist/memory/providers/index.js +0 -28
- package/dist/memory/providers/ollama.d.ts +0 -6
- package/dist/memory/providers/ollama.js +1 -8
- package/dist/memory/providers/openai.d.ts +0 -6
- package/dist/memory/providers/openai.js +1 -8
- package/dist/memory/providers/openrouter.d.ts +0 -6
- package/dist/memory/providers/openrouter.js +0 -8
- package/dist/memory/providers/text-only.d.ts +0 -13
- package/dist/memory/providers/text-only.js +0 -17
- package/dist/memory/providers/types.d.ts +0 -39
- package/dist/memory/providers/types.js +0 -7
- package/dist/memory/providers/voyage.d.ts +0 -22
- package/dist/memory/providers/voyage.js +1 -24
- package/dist/memory/search/hybrid.d.ts +0 -12
- package/dist/memory/search/hybrid.js +1 -22
- package/dist/memory/store/sqlite.d.ts +0 -72
- package/dist/memory/store/sqlite.js +4 -127
- package/dist/plugin/config/index.d.ts +0 -112
- package/dist/plugin/config/index.js +0 -115
- package/dist/plugin/index.d.ts +0 -13
- package/dist/plugin/index.js +1 -124
- package/dist/plugin/tools/command-registry.d.ts +0 -6
- package/dist/plugin/tools/command-registry.js +0 -14
- package/dist/plugin/tools/context.d.ts +0 -12
- package/dist/plugin/tools/context.js +0 -58
- package/dist/plugin/tools/maskSave.d.ts +0 -3
- package/dist/plugin/tools/maskSave.js +0 -3
- package/dist/plugin/tools/memoryGet.d.ts +0 -3
- package/dist/plugin/tools/memoryGet.js +0 -3
- package/dist/plugin/tools/memoryIndexer.d.ts +0 -3
- package/dist/plugin/tools/memoryIndexer.js +0 -10
- package/dist/plugin/tools/memorySearch.d.ts +0 -31
- package/dist/plugin/tools/memorySearch.js +0 -79
- package/dist/plugin/tools/memoryWrite.d.ts +0 -8
- package/dist/plugin/tools/memoryWrite.js +0 -32
- package/dist/plugin/tools/retrospect.d.ts +0 -3
- package/dist/plugin/tools/retrospect.js +0 -3
- package/dist/plugin/tools/slashcommand.d.ts +0 -11
- package/dist/plugin/tools/slashcommand.js +0 -38
- package/dist/plugin/tools/squad.d.ts +0 -12
- package/dist/plugin/tools/squad.js +11 -83
- package/dist/plugin/tools/weave.d.ts +0 -6
- package/dist/plugin/tools/weave.js +0 -78
- package/dist/plugin/types.d.ts +0 -20
- package/dist/plugin/types.js +0 -7
- package/dist/retrospect/index.d.ts +0 -7
- package/dist/retrospect/index.js +0 -9
- package/dist/retrospect/mask-save.d.ts +0 -12
- package/dist/retrospect/mask-save.js +1 -80
- package/dist/retrospect/retrospect.d.ts +0 -18
- package/dist/retrospect/retrospect.js +0 -63
- package/dist/retrospect/strategies/base.d.ts +0 -15
- package/dist/retrospect/strategies/base.js +0 -7
- package/dist/retrospect/strategies/deep.d.ts +0 -12
- package/dist/retrospect/strategies/deep.js +0 -24
- package/dist/retrospect/strategies/index.d.ts +0 -12
- package/dist/retrospect/strategies/index.js +0 -12
- package/dist/retrospect/strategies/quick.d.ts +0 -12
- package/dist/retrospect/strategies/quick.js +0 -19
- package/dist/retrospect/strategies/standard.d.ts +0 -12
- package/dist/retrospect/strategies/standard.js +0 -15
- package/dist/retrospect/types.d.ts +0 -7
- package/dist/retrospect/types.js +0 -7
- package/dist/shared/config.d.ts +0 -105
- package/dist/shared/config.js +0 -33
- package/dist/shared/errors.d.ts +0 -18
- package/dist/shared/errors.js +0 -19
- package/dist/shared/generate-agents.d.ts +0 -69
- package/dist/shared/generate-agents.js +2 -86
- package/dist/shared/image.d.ts +0 -67
- package/dist/shared/image.js +6 -104
- package/dist/shared/index.d.ts +0 -5
- package/dist/shared/index.js +0 -7
- package/dist/shared/model-registry.d.ts +0 -72
- package/dist/shared/model-registry.js +5 -95
- package/dist/shared/types.d.ts +0 -15
- package/dist/shared/types.js +0 -3
- package/dist/shared-context/dag.d.ts +0 -105
- package/dist/shared-context/dag.js +3 -114
- package/dist/shared-context/index.d.ts +0 -5
- package/dist/shared-context/index.js +0 -15
- package/dist/shared-context/logger.d.ts +0 -37
- package/dist/shared-context/logger.js +0 -41
- package/dist/shared-context/parallel-executor.d.ts +0 -54
- package/dist/shared-context/parallel-executor.js +4 -56
- package/dist/shared-context/session.d.ts +0 -56
- package/dist/shared-context/session.js +0 -47
- package/dist/shared-context/squad.d.ts +0 -68
- package/dist/shared-context/squad.js +0 -63
- package/dist/shared-context/storage.d.ts +0 -132
- package/dist/shared-context/storage.js +0 -116
- package/dist/shared-context/task.d.ts +0 -120
- package/dist/shared-context/task.js +0 -152
- package/dist/shared-context/test/dag.test.js +9 -14
- package/dist/shared-context/test/logger.test.d.ts +0 -8
- package/dist/shared-context/test/logger.test.js +0 -52
- package/dist/shared-context/test/session.test.d.ts +0 -7
- package/dist/shared-context/test/session.test.js +0 -63
- package/dist/shared-context/test/squad.test.d.ts +0 -10
- package/dist/shared-context/test/squad.test.js +2 -68
- package/dist/shared-context/test/storage.test.d.ts +0 -8
- package/dist/shared-context/test/storage.test.js +0 -68
- package/dist/shared-context/test/task.test.d.ts +0 -7
- package/dist/shared-context/test/task.test.js +0 -54
- package/dist/shared-context/test/watchdog.test.d.ts +0 -7
- package/dist/shared-context/test/watchdog.test.js +3 -58
- package/dist/shared-context/types.d.ts +0 -215
- package/dist/shared-context/types.js +0 -125
- package/dist/shared-context/watchdog.d.ts +0 -127
- package/dist/shared-context/watchdog.js +0 -148
- package/dist/shared-context/worktree.d.ts +0 -68
- package/dist/shared-context/worktree.js +2 -34
- package/dist/verify/budget.d.ts +0 -29
- package/dist/verify/budget.js +0 -34
- package/dist/verify/critical-files.d.ts +0 -17
- package/dist/verify/critical-files.js +0 -37
- package/dist/verify/escalation.d.ts +0 -20
- package/dist/verify/escalation.js +0 -22
- package/dist/verify/index.d.ts +0 -5
- package/dist/verify/index.js +0 -11
- package/dist/verify/prompts.d.ts +0 -20
- package/dist/verify/prompts.js +0 -20
- package/dist/verify/types.d.ts +0 -26
- package/dist/verify/types.js +1 -12
- package/dist/verify/verifier.d.ts +0 -29
- package/dist/verify/verifier.js +0 -54
- package/dist/version.d.ts +1 -16
- package/dist/version.js +1 -16
- package/dist/weave/bridge.d.ts +0 -35
- package/dist/weave/bridge.js +0 -51
- package/dist/weave/environment/detector.d.ts +0 -6
- package/dist/weave/environment/detector.js +4 -45
- package/dist/weave/environment/index.d.ts +0 -19
- package/dist/weave/environment/index.js +1 -39
- package/dist/weave/environment/issues.d.ts +0 -35
- package/dist/weave/environment/issues.js +0 -59
- package/dist/weave/git.d.ts +0 -8
- package/dist/weave/git.js +0 -8
- package/dist/weave/index.d.ts +0 -13
- package/dist/weave/index.js +2 -28
- package/dist/weave/knowledge/global.d.ts +0 -39
- package/dist/weave/knowledge/global.js +2 -78
- package/dist/weave/loop.js +0 -3
- package/dist/weave/orchestrator.d.ts +0 -69
- package/dist/weave/orchestrator.js +1 -101
- package/dist/weave/phase-manager.d.ts +0 -64
- package/dist/weave/phase-manager.js +0 -89
- package/dist/weave/security/secret-scan.d.ts +0 -14
- package/dist/weave/security/secret-scan.js +0 -19
- package/dist/weave/stages/build.js +0 -15
- package/dist/weave/stages/execute.d.ts +0 -42
- package/dist/weave/stages/execute.js +4 -86
- package/dist/weave/stages/handoff.d.ts +0 -7
- package/dist/weave/stages/handoff.js +0 -43
- package/dist/weave/stages/index.d.ts +0 -3
- package/dist/weave/stages/index.js +0 -3
- package/dist/weave/stages/intake.d.ts +0 -8
- package/dist/weave/stages/intake.js +5 -65
- package/dist/weave/stages/map.d.ts +0 -1
- package/dist/weave/stages/openspec.d.ts +0 -1
- package/dist/weave/stages/plan.d.ts +0 -11
- package/dist/weave/stages/plan.js +1 -53
- package/dist/weave/stages/refine.d.ts +0 -7
- package/dist/weave/stages/refine.js +0 -7
- package/dist/weave/stages/research.d.ts +0 -6
- package/dist/weave/stages/research.js +0 -6
- package/dist/weave/stages/spec.d.ts +0 -12
- package/dist/weave/stages/spec.js +0 -17
- package/dist/weave/types.d.ts +0 -20
- package/dist/weave/types.js +0 -5
- package/dist/weave/verification/commands.d.ts +0 -12
- package/dist/weave/verification/commands.js +0 -19
- package/dist/weave/verification/index.d.ts +0 -6
- package/dist/weave/verification/index.js +1 -19
- package/dist/weave/verification/playwright.d.ts +0 -47
- package/dist/weave/verification/playwright.js +1 -90
- package/dist/weave/worktree.d.ts +0 -16
- package/dist/weave/worktree.js +0 -23
- package/dist/weave/yaml-repair.d.ts +0 -39
- package/dist/weave/yaml-repair.js +13 -116
- 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,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<{
|