maskweaver 0.8.10 → 0.8.12

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 (40) hide show
  1. package/assets/agents/squad-operator.md +4 -0
  2. package/dist/core/schema/validator.d.ts +1 -1
  3. package/dist/plugin/tools/weave.d.ts +13 -1
  4. package/dist/plugin/tools/weave.d.ts.map +1 -1
  5. package/dist/plugin/tools/weave.js +198 -1
  6. package/dist/plugin/tools/weave.js.map +1 -1
  7. package/dist/shared/generate-agents.d.ts +28 -12
  8. package/dist/shared/generate-agents.d.ts.map +1 -1
  9. package/dist/shared/generate-agents.js +30 -12
  10. package/dist/shared/generate-agents.js.map +1 -1
  11. package/dist/weave/change-artifacts.d.ts +9 -0
  12. package/dist/weave/change-artifacts.d.ts.map +1 -1
  13. package/dist/weave/change-artifacts.js +27 -0
  14. package/dist/weave/change-artifacts.js.map +1 -1
  15. package/dist/weave/phase-manager.d.ts.map +1 -1
  16. package/dist/weave/phase-manager.js +42 -1
  17. package/dist/weave/phase-manager.js.map +1 -1
  18. package/dist/weave/stages/build.d.ts +14 -0
  19. package/dist/weave/stages/build.d.ts.map +1 -0
  20. package/dist/weave/stages/build.js +495 -0
  21. package/dist/weave/stages/build.js.map +1 -0
  22. package/dist/weave/stages/intake.d.ts +21 -1
  23. package/dist/weave/stages/intake.d.ts.map +1 -1
  24. package/dist/weave/stages/intake.js +111 -0
  25. package/dist/weave/stages/intake.js.map +1 -1
  26. package/dist/weave/stages/map.d.ts +13 -0
  27. package/dist/weave/stages/map.d.ts.map +1 -0
  28. package/dist/weave/stages/map.js +512 -0
  29. package/dist/weave/stages/map.js.map +1 -0
  30. package/dist/weave/stages/openspec.d.ts +17 -0
  31. package/dist/weave/stages/openspec.d.ts.map +1 -0
  32. package/dist/weave/stages/openspec.js +215 -0
  33. package/dist/weave/stages/openspec.js.map +1 -0
  34. package/dist/weave/stages/plan.d.ts.map +1 -1
  35. package/dist/weave/stages/plan.js +53 -1
  36. package/dist/weave/stages/plan.js.map +1 -1
  37. package/dist/weave/types.d.ts +145 -0
  38. package/dist/weave/types.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/postinstall.mjs +30 -12
@@ -177,8 +177,12 @@ squad({ action: "models" })
177
177
  - 단순 작업 (파일 정리, 포매팅) → flash 티어 모델
178
178
  - 일반 코딩 → human 티어 모델
179
179
  - 복잡한 설계/디버깅 → premium 티어 모델
180
+ - **비전 필요 (이미지 분석, 스크린샷) → `vision` capability 보유 모델 선택**
181
+ - `qwen-vision` (human 티어) 또는 `kimi-vision` (premium 티어)
182
+ - `squad({ action: "models" })` 결과에서 `capabilities`에 `"vision"`이 포함된 모델 확인
180
183
  3. **동시실행 고려**: 해당 모델의 `remainingSlots`이 0이면 다른 모델 사용
181
184
  4. **fallback**: 원하는 티어가 꽉 찼으면 비슷한 능력의 다른 모델 사용
185
+ 5. **비전 fallback**: vision 모델이 모두 사용 중이면 일반 모델로 작업을 분리하여 처리 (이미지 설명 생성 → 일반 코딩 모델에 전달)
182
186
 
183
187
  ### assignee 지정 방식
184
188
  `assignee` 필드에 **에이전트 이름**을 사용합니다:
@@ -10,8 +10,8 @@ export declare const MaskSchemaValidator: z.ZodObject<{
10
10
  id: z.ZodString;
11
11
  version: z.ZodLiteral<"1.0">;
12
12
  language: z.ZodEnum<{
13
- en: "en";
14
13
  ko: "ko";
14
+ en: "en";
15
15
  zh: "zh";
16
16
  ja: "ja";
17
17
  }>;
@@ -9,12 +9,15 @@ export declare function createWeaveTool(): {
9
9
  description: string;
10
10
  args: {
11
11
  command: z.ZodEnum<{
12
+ map: "map";
12
13
  record: "record";
13
14
  status: "status";
14
15
  spec: "spec";
15
16
  worktree: "worktree";
17
+ build: "build";
16
18
  verify: "verify";
17
19
  init: "init";
20
+ interview: "interview";
18
21
  research: "research";
19
22
  design: "design";
20
23
  prepare: "prepare";
@@ -22,6 +25,7 @@ export declare function createWeaveTool(): {
22
25
  "approve-plan": "approve-plan";
23
26
  flow: "flow";
24
27
  craft: "craft";
28
+ "build-resume": "build-resume";
25
29
  archive: "archive";
26
30
  "loop-run": "loop-run";
27
31
  "loop-start": "loop-start";
@@ -79,9 +83,13 @@ export declare function createWeaveTool(): {
79
83
  maxNoProgress: z.ZodOptional<z.ZodNumber>;
80
84
  pollIntervalMs: z.ZodOptional<z.ZodNumber>;
81
85
  pollCycles: z.ZodOptional<z.ZodNumber>;
86
+ deep: z.ZodOptional<z.ZodBoolean>;
87
+ maxRetries: z.ZodOptional<z.ZodNumber>;
88
+ buildId: z.ZodOptional<z.ZodString>;
89
+ phaseIds: z.ZodOptional<z.ZodString>;
82
90
  };
83
91
  execute: (args: {
84
- command: "init" | "research" | "spec" | "design" | "prepare" | "refine-plan" | "approve-plan" | "flow" | "craft" | "status" | "worktree" | "verify" | "archive" | "loop-run" | "loop-start" | "loop-step" | "loop-status" | "loop-stop" | "loop-list" | "loop-sync" | "loop-watchdog" | "loop-poll" | "loop-operator" | "troubleshoot" | "record" | "help" | "repair" | "sync-agents" | "init-config";
92
+ command: "init" | "map" | "interview" | "research" | "spec" | "design" | "prepare" | "refine-plan" | "approve-plan" | "flow" | "craft" | "build" | "build-resume" | "status" | "worktree" | "verify" | "archive" | "loop-run" | "loop-start" | "loop-step" | "loop-status" | "loop-stop" | "loop-list" | "loop-sync" | "loop-watchdog" | "loop-poll" | "loop-operator" | "troubleshoot" | "record" | "help" | "repair" | "sync-agents" | "init-config";
85
93
  docsPath?: string;
86
94
  phaseId?: string;
87
95
  projectName?: string;
@@ -113,6 +121,10 @@ export declare function createWeaveTool(): {
113
121
  maxNoProgress?: number;
114
122
  pollIntervalMs?: number;
115
123
  pollCycles?: number;
124
+ deep?: boolean;
125
+ maxRetries?: number;
126
+ buildId?: string;
127
+ phaseIds?: string;
116
128
  }, context: {
117
129
  worktree: string;
118
130
  }) => Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"weave.d.ts","sourceRoot":"","sources":["../../../src/plugin/tools/weave.ts"],"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U,CAAC,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACrB,WACQ;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,KAC9B,OAAO,CAAC,MAAM,CAAC;EAkHzB"}
@@ -23,6 +23,10 @@ import { plan } from '../../weave/stages/plan.js';
23
23
  import { preparePhaseExecution, formatExecutionPlan, runAIVerification, generateVerificationReport } from '../../weave/stages/execute.js';
24
24
  import { archiveChange } from '../../weave/stages/archive.js';
25
25
  import { generateStatusReport, handleUserResponse } from '../../weave/stages/handoff.js';
26
+ import { analyzeCodebase, runGraphifyAnalysis, readMapResult } from '../../weave/stages/map.js';
27
+ import { interview as interviewStage } from '../../weave/stages/intake.js';
28
+ import { executeBuildLoop, generateBuildState, generateBuildId, loadBuildState } from '../../weave/stages/build.js';
29
+ import { WeaveOrchestrator } from '../../weave/orchestrator.js';
26
30
  import { getPhaseManager } from '../../weave/phase-manager.js';
27
31
  import { recommendVerificationCommands, formatRecommendedCommandsAsBash } from '../../weave/verification/index.js';
28
32
  import { createWeaveWorktree, listWeaveWorktrees, resolveWeaveWorktree, removeWeaveWorktree, ensureIgnoreOverride, ensureWeaveState, } from '../../weave/worktree.js';
@@ -43,6 +47,8 @@ export function createWeaveTool() {
43
47
 
44
48
  Commands:
45
49
  - init: Initialize weave workspace files and probe GDC integration
50
+ - map [deep]: Analyze codebase structure via GDC + Graphify (knowledge graph)
51
+ - interview [docsPath]: Multi-step question asking until clarity, with structural change detection
46
52
  - research [docsPath]: Deep-read docs + workspace context and write persistent research.md
47
53
  - spec [docsPath]: Generate baseline spec (requirements + AC)
48
54
  - design [docsPath]: Analyze requirements and create phase-based plan (auto-splits oversized plans)
@@ -51,6 +57,8 @@ Commands:
51
57
  - approve-plan: Approve the plan, or finalize a crafted phase when phaseId is provided
52
58
  - flow [docsPath]: One-command path (prepare -> auto-approve -> craft -> verify -> finalize)
53
59
  - craft [phaseId]: Prepare execution context for a phase (phase auto-select if omitted)
60
+ - build [phaseIds]: Ralph-loop autonomous execution — runs approved plan until all tasks complete (no user intervention)
61
+ - build-resume [buildId]: Resume a previously blocked build
54
62
  - status: View overall progress
55
63
  - worktree: Manage git worktrees for parallel work
56
64
  - verify: Run build/test verification for current worktree
@@ -85,7 +93,7 @@ Examples:
85
93
  - weave init-config
86
94
  - weave troubleshoot "Cannot find module 'xyz'"`,
87
95
  args: {
88
- command: z.enum(['init', 'research', 'spec', 'design', 'prepare', 'refine-plan', 'approve-plan', 'flow', 'craft', 'status', 'worktree', 'verify', 'archive', 'loop-run', 'loop-start', 'loop-step', 'loop-status', 'loop-stop', 'loop-list', 'loop-sync', 'loop-watchdog', 'loop-poll', 'loop-operator', 'troubleshoot', 'record', 'help', 'repair', 'sync-agents', 'init-config'])
96
+ command: z.enum(['init', 'map', 'interview', 'research', 'spec', 'design', 'prepare', 'refine-plan', 'approve-plan', 'flow', 'craft', 'build', 'build-resume', 'status', 'worktree', 'verify', 'archive', 'loop-run', 'loop-start', 'loop-step', 'loop-status', 'loop-stop', 'loop-list', 'loop-sync', 'loop-watchdog', 'loop-poll', 'loop-operator', 'troubleshoot', 'record', 'help', 'repair', 'sync-agents', 'init-config'])
89
97
  .describe('Weave command to execute'),
90
98
  docsPath: z.string().optional()
91
99
  .describe('Path to requirements documents (for design command)'),
@@ -149,6 +157,14 @@ Examples:
149
157
  .describe('Polling interval for loop-poll/watchdog-style commands (default: 1000ms)'),
150
158
  pollCycles: z.number().int().min(1).max(1000).optional()
151
159
  .describe('Maximum polling cycles for loop-poll (default: 30)'),
160
+ deep: z.boolean().optional()
161
+ .describe('Run deep analysis with Graphify (for map command)'),
162
+ maxRetries: z.number().int().min(1).max(10).optional()
163
+ .describe('Maximum retries per task (for build command)'),
164
+ buildId: z.string().optional()
165
+ .describe('Build ID to resume (for build-resume command)'),
166
+ phaseIds: z.string().optional()
167
+ .describe('Comma-separated phase IDs (for build command)'),
152
168
  },
153
169
  execute: async (args, context) => {
154
170
  const { command } = args;
@@ -157,6 +173,14 @@ Examples:
157
173
  switch (command) {
158
174
  case 'init':
159
175
  return await handleInit(basePath);
176
+ case 'map':
177
+ return await handleMap(args, basePath);
178
+ case 'interview':
179
+ return await handleInterview(args, basePath);
180
+ case 'build':
181
+ return await handleBuild(args, basePath);
182
+ case 'build-resume':
183
+ return await handleBuildResume(args, basePath);
160
184
  case 'research':
161
185
  return await handleResearch(args, basePath);
162
186
  case 'spec':
@@ -1748,6 +1772,179 @@ async function handleFlow(args, basePath) {
1748
1772
  });
1749
1773
  return lines.join('\n');
1750
1774
  }
1775
+ // ============================================================================
1776
+ // Handle Map — Codebase Analysis
1777
+ // ============================================================================
1778
+ async function handleMap(args, basePath) {
1779
+ const lines = [];
1780
+ lines.push('## 🔍 Codebase Map');
1781
+ lines.push('');
1782
+ lines.push('Analyzing codebase structure...');
1783
+ lines.push('');
1784
+ const mapResult = await analyzeCodebase({
1785
+ basePath,
1786
+ deep: args.deep,
1787
+ onMessage: (msg) => { lines.push(`> ${msg}`); },
1788
+ });
1789
+ if (args.deep) {
1790
+ lines.push('Running Graphify deep analysis...');
1791
+ const graphifyPath = await runGraphifyAnalysis(basePath);
1792
+ if (graphifyPath) {
1793
+ lines.push(`Graphify report: \`${graphifyPath}\``);
1794
+ }
1795
+ else {
1796
+ lines.push('Graphify analysis skipped or failed.');
1797
+ }
1798
+ }
1799
+ lines.push('');
1800
+ lines.push('### Summary');
1801
+ lines.push(mapResult.summary);
1802
+ lines.push('');
1803
+ lines.push(`Full report: \`${mapResult.mapPath}\``);
1804
+ lines.push('');
1805
+ lines.push('Next: `weave command=interview docsPath="doc"` to discuss the plan.');
1806
+ return lines.join('\n');
1807
+ }
1808
+ // ============================================================================
1809
+ // Handle Interview — Multi-step Question Asking
1810
+ // ============================================================================
1811
+ async function handleInterview(args, basePath) {
1812
+ const docsPath = args.docsPath || 'docs';
1813
+ const lines = [];
1814
+ lines.push('## 💬 Interview');
1815
+ lines.push('');
1816
+ const mapResult = await readMapResult(basePath);
1817
+ if (mapResult) {
1818
+ lines.push(`📍 Map available: \`${mapResult.mapPath}\``);
1819
+ if (mapResult.structuralIssues.length > 0) {
1820
+ lines.push(`⚠️ ${mapResult.structuralIssues.length} structural issues detected.`);
1821
+ }
1822
+ lines.push('');
1823
+ }
1824
+ else {
1825
+ lines.push('ℹ️ No codebase map found. Run `weave command=map` first for deeper analysis.');
1826
+ lines.push('');
1827
+ }
1828
+ try {
1829
+ const interviewResult = await interviewStage({
1830
+ docsPath,
1831
+ basePath,
1832
+ mapResult,
1833
+ });
1834
+ lines.push(`### Documents Analyzed`);
1835
+ lines.push(`- ${interviewResult.intake.documents.length} document(s) analyzed`);
1836
+ lines.push(`- ${interviewResult.intake.features.length} feature(s) identified`);
1837
+ lines.push('');
1838
+ if (interviewResult.intake.structuralChanges && interviewResult.intake.structuralChanges.length > 0) {
1839
+ lines.push('### ⚠️ Structural Changes Detected');
1840
+ lines.push('The following structural changes were identified from codebase analysis:');
1841
+ lines.push('');
1842
+ for (const sc of interviewResult.intake.structuralChanges) {
1843
+ const icon = sc.breaking ? '🔴' : '🟡';
1844
+ lines.push(`- ${icon} **${sc.area}** — ${sc.proposedChange}`);
1845
+ lines.push(` - Why: ${sc.rationale}`);
1846
+ lines.push(` - Impact: ${sc.impact}`);
1847
+ lines.push(` - Status: ${sc.agreed ? '✅ Agreed' : '⏳ Pending approval'}`);
1848
+ }
1849
+ lines.push('');
1850
+ lines.push('To proceed, agree to structural changes via `weave command=approve-plan`.');
1851
+ lines.push('');
1852
+ }
1853
+ lines.push('### Questions');
1854
+ lines.push('Review the features and technical requirements above.');
1855
+ lines.push('');
1856
+ lines.push('Next: `weave command=design docsPath="docs/"` to create the plan.');
1857
+ }
1858
+ catch (e) {
1859
+ return `Error during interview: ${e.message || e}`;
1860
+ }
1861
+ return lines.join('\n');
1862
+ }
1863
+ // ============================================================================
1864
+ // Handle Build — Ralph-loop Autonomous Execution
1865
+ // ============================================================================
1866
+ async function handleBuild(args, basePath) {
1867
+ const lines = [];
1868
+ lines.push('## 🏗️ Build');
1869
+ lines.push('');
1870
+ const manager = getPhaseManager(basePath);
1871
+ const plan = await manager.loadPlan();
1872
+ if (!plan) {
1873
+ return 'Error: No active plan found. Run `weave command=design docsPath="docs/"` first.';
1874
+ }
1875
+ if (!plan.planApproved) {
1876
+ return 'Error: Plan not approved. Run `weave command=approve-plan` first.';
1877
+ }
1878
+ lines.push(`Plan: **${plan.projectName}** (approved at ${plan.planApprovedAt || 'N/A'})`);
1879
+ lines.push('');
1880
+ const orchestrator = new WeaveOrchestrator();
1881
+ const buildId = generateBuildId();
1882
+ const state = generateBuildState(buildId, plan.planName || plan.projectName, args.maxRetries || 3);
1883
+ const onMessages = [];
1884
+ lines.push('Starting autonomous build loop...');
1885
+ lines.push('');
1886
+ const result = await executeBuildLoop({
1887
+ plan,
1888
+ state,
1889
+ orchestrator,
1890
+ basePath,
1891
+ maxRetries: args.maxRetries,
1892
+ phaseIds: args.phaseIds ? args.phaseIds.split(',').map((id) => id.trim()).filter(Boolean) : undefined,
1893
+ onMessage: (msg) => { onMessages.push(msg); },
1894
+ });
1895
+ for (const msg of onMessages) {
1896
+ lines.push(msg);
1897
+ }
1898
+ lines.push('');
1899
+ if (result.success) {
1900
+ lines.push('## ✅ Build Complete');
1901
+ }
1902
+ else {
1903
+ lines.push('## ⚠️ Build Blocked');
1904
+ }
1905
+ lines.push('');
1906
+ lines.push(result.summary);
1907
+ if (result.tasksEscalated > 0 || result.tasksFailed > 0) {
1908
+ lines.push('');
1909
+ lines.push('To resume after fixing issues: `weave command=build-resume buildId="<buildId>"`');
1910
+ }
1911
+ return lines.join('\n');
1912
+ }
1913
+ // ============================================================================
1914
+ // Handle Build Resume
1915
+ // ============================================================================
1916
+ async function handleBuildResume(args, basePath) {
1917
+ const lines = [];
1918
+ lines.push('## 🔄 Build Resume');
1919
+ lines.push('');
1920
+ if (!args.buildId) {
1921
+ return 'Error: buildId is required. Use `weave command=build-resume buildId="<id>"`.';
1922
+ }
1923
+ const state = await loadBuildState(basePath, args.buildId);
1924
+ if (!state) {
1925
+ return `Error: Build state not found: ${args.buildId}`;
1926
+ }
1927
+ if (state.status !== 'blocked') {
1928
+ return `Build ${args.buildId} is not blocked (status: ${state.status}). No need to resume.`;
1929
+ }
1930
+ const manager = getPhaseManager(basePath);
1931
+ const plan = await manager.loadPlan();
1932
+ if (!plan) {
1933
+ return 'Error: No active plan found.';
1934
+ }
1935
+ state.status = 'running';
1936
+ state.escalationReason = undefined;
1937
+ const orchestrator = new WeaveOrchestrator();
1938
+ const result = await executeBuildLoop({
1939
+ plan,
1940
+ state,
1941
+ orchestrator,
1942
+ basePath,
1943
+ maxRetries: args.maxRetries || 3,
1944
+ });
1945
+ lines.push(result.summary);
1946
+ return lines.join('\n');
1947
+ }
1751
1948
  async function handleCraft(args, basePath) {
1752
1949
  const { phaseId, projectType } = args;
1753
1950
  let resolvedPhaseId = phaseId;