zero-workspace 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +187 -0
- package/config/component-versions.json +16 -0
- package/config/scenarioCapabilities.json +29 -0
- package/config/version-notes.yaml +244 -0
- package/dist/adapters/OutputAdapter.d.ts +79 -0
- package/dist/adapters/OutputAdapter.d.ts.map +1 -0
- package/dist/adapters/OutputAdapter.js +124 -0
- package/dist/adapters/OutputAdapter.js.map +1 -0
- package/dist/cli/check-node-version.d.ts +3 -0
- package/dist/cli/check-node-version.d.ts.map +1 -0
- package/dist/cli/check-node-version.js +153 -0
- package/dist/cli/check-node-version.js.map +1 -0
- package/dist/cli/plugins.d.ts +41 -0
- package/dist/cli/plugins.d.ts.map +1 -0
- package/dist/cli/plugins.js +742 -0
- package/dist/cli/plugins.js.map +1 -0
- package/dist/cli/rebuild.d.ts +63 -0
- package/dist/cli/rebuild.d.ts.map +1 -0
- package/dist/cli/rebuild.js +989 -0
- package/dist/cli/rebuild.js.map +1 -0
- package/dist/cli/repair.d.ts +7 -0
- package/dist/cli/repair.d.ts.map +1 -0
- package/dist/cli/repair.js +925 -0
- package/dist/cli/repair.js.map +1 -0
- package/dist/cli/setup.d.ts +7 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +452 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/update.d.ts +10 -0
- package/dist/cli/update.d.ts.map +1 -0
- package/dist/cli/update.js +426 -0
- package/dist/cli/update.js.map +1 -0
- package/dist/cli/webui.d.ts +6 -0
- package/dist/cli/webui.d.ts.map +1 -0
- package/dist/cli/webui.js +210 -0
- package/dist/cli/webui.js.map +1 -0
- package/dist/http/index.d.ts +3 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +15 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/middleware/errorHandler.d.ts +16 -0
- package/dist/http/middleware/errorHandler.d.ts.map +1 -0
- package/dist/http/middleware/errorHandler.js +79 -0
- package/dist/http/middleware/errorHandler.js.map +1 -0
- package/dist/http/routes/admin.d.ts +3 -0
- package/dist/http/routes/admin.d.ts.map +1 -0
- package/dist/http/routes/admin.js +730 -0
- package/dist/http/routes/admin.js.map +1 -0
- package/dist/http/routes/backup.d.ts +3 -0
- package/dist/http/routes/backup.d.ts.map +1 -0
- package/dist/http/routes/backup.js +172 -0
- package/dist/http/routes/backup.js.map +1 -0
- package/dist/http/routes/config.d.ts +3 -0
- package/dist/http/routes/config.d.ts.map +1 -0
- package/dist/http/routes/config.js +157 -0
- package/dist/http/routes/config.js.map +1 -0
- package/dist/http/routes/context.d.ts +3 -0
- package/dist/http/routes/context.d.ts.map +1 -0
- package/dist/http/routes/context.js +82 -0
- package/dist/http/routes/context.js.map +1 -0
- package/dist/http/routes/log.d.ts +3 -0
- package/dist/http/routes/log.d.ts.map +1 -0
- package/dist/http/routes/log.js +105 -0
- package/dist/http/routes/log.js.map +1 -0
- package/dist/http/routes/memo.d.ts +6 -0
- package/dist/http/routes/memo.d.ts.map +1 -0
- package/dist/http/routes/memo.js +29 -0
- package/dist/http/routes/memo.js.map +1 -0
- package/dist/http/routes/node.d.ts +3 -0
- package/dist/http/routes/node.d.ts.map +1 -0
- package/dist/http/routes/node.js +251 -0
- package/dist/http/routes/node.js.map +1 -0
- package/dist/http/routes/state.d.ts +3 -0
- package/dist/http/routes/state.d.ts.map +1 -0
- package/dist/http/routes/state.js +48 -0
- package/dist/http/routes/state.js.map +1 -0
- package/dist/http/routes/workspace.d.ts +3 -0
- package/dist/http/routes/workspace.d.ts.map +1 -0
- package/dist/http/routes/workspace.js +249 -0
- package/dist/http/routes/workspace.js.map +1 -0
- package/dist/http/server.d.ts +10 -0
- package/dist/http/server.d.ts.map +1 -0
- package/dist/http/server.js +284 -0
- package/dist/http/server.js.map +1 -0
- package/dist/http/services.d.ts +93 -0
- package/dist/http/services.d.ts.map +1 -0
- package/dist/http/services.js +297 -0
- package/dist/http/services.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1073 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/guidanceContent.d.ts +18 -0
- package/dist/prompts/guidanceContent.d.ts.map +1 -0
- package/dist/prompts/guidanceContent.js +814 -0
- package/dist/prompts/guidanceContent.js.map +1 -0
- package/dist/prompts/index.d.ts +2 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +4 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/instructions.d.ts +56 -0
- package/dist/prompts/instructions.d.ts.map +1 -0
- package/dist/prompts/instructions.js +1343 -0
- package/dist/prompts/instructions.js.map +1 -0
- package/dist/services/BackupService.d.ts +104 -0
- package/dist/services/BackupService.d.ts.map +1 -0
- package/dist/services/BackupService.js +549 -0
- package/dist/services/BackupService.js.map +1 -0
- package/dist/services/CapabilityService.d.ts +38 -0
- package/dist/services/CapabilityService.d.ts.map +1 -0
- package/dist/services/CapabilityService.js +256 -0
- package/dist/services/CapabilityService.js.map +1 -0
- package/dist/services/ConfigService.d.ts +35 -0
- package/dist/services/ConfigService.d.ts.map +1 -0
- package/dist/services/ConfigService.js +105 -0
- package/dist/services/ConfigService.js.map +1 -0
- package/dist/services/ContextService.d.ts +65 -0
- package/dist/services/ContextService.d.ts.map +1 -0
- package/dist/services/ContextService.js +503 -0
- package/dist/services/ContextService.js.map +1 -0
- package/dist/services/DetectionService.d.ts +76 -0
- package/dist/services/DetectionService.d.ts.map +1 -0
- package/dist/services/DetectionService.js +262 -0
- package/dist/services/DetectionService.js.map +1 -0
- package/dist/services/DispatchService.d.ts +267 -0
- package/dist/services/DispatchService.d.ts.map +1 -0
- package/dist/services/DispatchService.js +1357 -0
- package/dist/services/DispatchService.js.map +1 -0
- package/dist/services/EventService.d.ts +81 -0
- package/dist/services/EventService.d.ts.map +1 -0
- package/dist/services/EventService.js +187 -0
- package/dist/services/EventService.js.map +1 -0
- package/dist/services/GuidanceService.d.ts +64 -0
- package/dist/services/GuidanceService.d.ts.map +1 -0
- package/dist/services/GuidanceService.js +259 -0
- package/dist/services/GuidanceService.js.map +1 -0
- package/dist/services/HealthService.d.ts +43 -0
- package/dist/services/HealthService.d.ts.map +1 -0
- package/dist/services/HealthService.js +276 -0
- package/dist/services/HealthService.js.map +1 -0
- package/dist/services/InstallationService.d.ts +62 -0
- package/dist/services/InstallationService.d.ts.map +1 -0
- package/dist/services/InstallationService.js +204 -0
- package/dist/services/InstallationService.js.map +1 -0
- package/dist/services/LogService.d.ts +35 -0
- package/dist/services/LogService.d.ts.map +1 -0
- package/dist/services/LogService.js +189 -0
- package/dist/services/LogService.js.map +1 -0
- package/dist/services/MemoService.d.ts +39 -0
- package/dist/services/MemoService.d.ts.map +1 -0
- package/dist/services/MemoService.js +288 -0
- package/dist/services/MemoService.js.map +1 -0
- package/dist/services/NodeService.d.ts +90 -0
- package/dist/services/NodeService.d.ts.map +1 -0
- package/dist/services/NodeService.js +958 -0
- package/dist/services/NodeService.js.map +1 -0
- package/dist/services/OpenSpecParser.d.ts +43 -0
- package/dist/services/OpenSpecParser.d.ts.map +1 -0
- package/dist/services/OpenSpecParser.js +191 -0
- package/dist/services/OpenSpecParser.js.map +1 -0
- package/dist/services/ReferenceService.d.ts +35 -0
- package/dist/services/ReferenceService.d.ts.map +1 -0
- package/dist/services/ReferenceService.js +195 -0
- package/dist/services/ReferenceService.js.map +1 -0
- package/dist/services/RepairService.d.ts +36 -0
- package/dist/services/RepairService.d.ts.map +1 -0
- package/dist/services/RepairService.js +429 -0
- package/dist/services/RepairService.js.map +1 -0
- package/dist/services/SearchService.d.ts +34 -0
- package/dist/services/SearchService.d.ts.map +1 -0
- package/dist/services/SearchService.js +293 -0
- package/dist/services/SearchService.js.map +1 -0
- package/dist/services/SessionService.d.ts +136 -0
- package/dist/services/SessionService.d.ts.map +1 -0
- package/dist/services/SessionService.js +297 -0
- package/dist/services/SessionService.js.map +1 -0
- package/dist/services/StateService.d.ts +97 -0
- package/dist/services/StateService.d.ts.map +1 -0
- package/dist/services/StateService.js +846 -0
- package/dist/services/StateService.js.map +1 -0
- package/dist/services/TutorialService.d.ts +114 -0
- package/dist/services/TutorialService.d.ts.map +1 -0
- package/dist/services/TutorialService.js +1262 -0
- package/dist/services/TutorialService.js.map +1 -0
- package/dist/services/WorkspaceService.d.ts +273 -0
- package/dist/services/WorkspaceService.d.ts.map +1 -0
- package/dist/services/WorkspaceService.js +1764 -0
- package/dist/services/WorkspaceService.js.map +1 -0
- package/dist/services/index.d.ts +15 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +14 -0
- package/dist/services/index.js.map +1 -0
- package/dist/storage/FileSystemAdapter.d.ts +223 -0
- package/dist/storage/FileSystemAdapter.d.ts.map +1 -0
- package/dist/storage/FileSystemAdapter.js +384 -0
- package/dist/storage/FileSystemAdapter.js.map +1 -0
- package/dist/storage/JsonStorage.d.ts +158 -0
- package/dist/storage/JsonStorage.d.ts.map +1 -0
- package/dist/storage/JsonStorage.js +613 -0
- package/dist/storage/JsonStorage.js.map +1 -0
- package/dist/storage/MarkdownStorage.d.ts +178 -0
- package/dist/storage/MarkdownStorage.d.ts.map +1 -0
- package/dist/storage/MarkdownStorage.js +918 -0
- package/dist/storage/MarkdownStorage.js.map +1 -0
- package/dist/storage/SessionBindingStorage.d.ts +69 -0
- package/dist/storage/SessionBindingStorage.d.ts.map +1 -0
- package/dist/storage/SessionBindingStorage.js +131 -0
- package/dist/storage/SessionBindingStorage.js.map +1 -0
- package/dist/storage/index.d.ts +6 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +6 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/tools/capability.d.ts +18 -0
- package/dist/tools/capability.d.ts.map +1 -0
- package/dist/tools/capability.js +73 -0
- package/dist/tools/capability.js.map +1 -0
- package/dist/tools/config.d.ts +14 -0
- package/dist/tools/config.d.ts.map +1 -0
- package/dist/tools/config.js +61 -0
- package/dist/tools/config.js.map +1 -0
- package/dist/tools/context.d.ts +22 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/context.js +139 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/dispatch.d.ts +41 -0
- package/dist/tools/dispatch.d.ts.map +1 -0
- package/dist/tools/dispatch.js +380 -0
- package/dist/tools/dispatch.js.map +1 -0
- package/dist/tools/help.d.ts +44 -0
- package/dist/tools/help.d.ts.map +1 -0
- package/dist/tools/help.js +227 -0
- package/dist/tools/help.js.map +1 -0
- package/dist/tools/import.d.ts +17 -0
- package/dist/tools/import.d.ts.map +1 -0
- package/dist/tools/import.js +96 -0
- package/dist/tools/import.js.map +1 -0
- package/dist/tools/index.d.ts +12 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +13 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/log.d.ts +21 -0
- package/dist/tools/log.d.ts.map +1 -0
- package/dist/tools/log.js +93 -0
- package/dist/tools/log.js.map +1 -0
- package/dist/tools/memo.d.ts +26 -0
- package/dist/tools/memo.d.ts.map +1 -0
- package/dist/tools/memo.js +188 -0
- package/dist/tools/memo.js.map +1 -0
- package/dist/tools/node.d.ts +34 -0
- package/dist/tools/node.d.ts.map +1 -0
- package/dist/tools/node.js +328 -0
- package/dist/tools/node.js.map +1 -0
- package/dist/tools/search.d.ts +14 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +95 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/session.d.ts +22 -0
- package/dist/tools/session.d.ts.map +1 -0
- package/dist/tools/session.js +127 -0
- package/dist/tools/session.js.map +1 -0
- package/dist/tools/state.d.ts +10 -0
- package/dist/tools/state.d.ts.map +1 -0
- package/dist/tools/state.js +79 -0
- package/dist/tools/state.js.map +1 -0
- package/dist/tools/workspace.d.ts +38 -0
- package/dist/tools/workspace.d.ts.map +1 -0
- package/dist/tools/workspace.js +240 -0
- package/dist/tools/workspace.js.map +1 -0
- package/dist/types/capability.d.ts +36 -0
- package/dist/types/capability.d.ts.map +1 -0
- package/dist/types/capability.js +3 -0
- package/dist/types/capability.js.map +1 -0
- package/dist/types/confirmation.d.ts +35 -0
- package/dist/types/confirmation.d.ts.map +1 -0
- package/dist/types/confirmation.js +3 -0
- package/dist/types/confirmation.js.map +1 -0
- package/dist/types/context.d.ts +174 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +3 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/errors.d.ts +81 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +154 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/guidance.d.ts +162 -0
- package/dist/types/guidance.d.ts.map +1 -0
- package/dist/types/guidance.js +4 -0
- package/dist/types/guidance.js.map +1 -0
- package/dist/types/health.d.ts +61 -0
- package/dist/types/health.d.ts.map +1 -0
- package/dist/types/health.js +3 -0
- package/dist/types/health.js.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/memo.d.ts +132 -0
- package/dist/types/memo.d.ts.map +1 -0
- package/dist/types/memo.js +3 -0
- package/dist/types/memo.js.map +1 -0
- package/dist/types/node.d.ts +316 -0
- package/dist/types/node.d.ts.map +1 -0
- package/dist/types/node.js +3 -0
- package/dist/types/node.js.map +1 -0
- package/dist/types/repair.d.ts +62 -0
- package/dist/types/repair.d.ts.map +1 -0
- package/dist/types/repair.js +4 -0
- package/dist/types/repair.js.map +1 -0
- package/dist/types/search.d.ts +58 -0
- package/dist/types/search.d.ts.map +1 -0
- package/dist/types/search.js +3 -0
- package/dist/types/search.js.map +1 -0
- package/dist/types/settings.d.ts +109 -0
- package/dist/types/settings.d.ts.map +1 -0
- package/dist/types/settings.js +30 -0
- package/dist/types/settings.js.map +1 -0
- package/dist/types/workspace.d.ts +357 -0
- package/dist/types/workspace.d.ts.map +1 -0
- package/dist/types/workspace.js +3 -0
- package/dist/types/workspace.js.map +1 -0
- package/dist/utils/contentValidation.d.ts +47 -0
- package/dist/utils/contentValidation.d.ts.map +1 -0
- package/dist/utils/contentValidation.js +93 -0
- package/dist/utils/contentValidation.js.map +1 -0
- package/dist/utils/devLog.d.ts +43 -0
- package/dist/utils/devLog.d.ts.map +1 -0
- package/dist/utils/devLog.js +94 -0
- package/dist/utils/devLog.js.map +1 -0
- package/dist/utils/errorLogger.d.ts +27 -0
- package/dist/utils/errorLogger.d.ts.map +1 -0
- package/dist/utils/errorLogger.js +105 -0
- package/dist/utils/errorLogger.js.map +1 -0
- package/dist/utils/git.d.ts +123 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +400 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/hash.d.ts +32 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +37 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/id.d.ts +54 -0
- package/dist/utils/id.d.ts.map +1 -0
- package/dist/utils/id.js +96 -0
- package/dist/utils/id.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +42 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +228 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/manualChangeFormatter.d.ts +8 -0
- package/dist/utils/manualChangeFormatter.d.ts.map +1 -0
- package/dist/utils/manualChangeFormatter.js +21 -0
- package/dist/utils/manualChangeFormatter.js.map +1 -0
- package/dist/utils/paramValidator.d.ts +35 -0
- package/dist/utils/paramValidator.d.ts.map +1 -0
- package/dist/utils/paramValidator.js +214 -0
- package/dist/utils/paramValidator.js.map +1 -0
- package/dist/utils/port.d.ts +7 -0
- package/dist/utils/port.d.ts.map +1 -0
- package/dist/utils/port.js +28 -0
- package/dist/utils/port.js.map +1 -0
- package/dist/utils/processManager.d.ts +53 -0
- package/dist/utils/processManager.d.ts.map +1 -0
- package/dist/utils/processManager.js +267 -0
- package/dist/utils/processManager.js.map +1 -0
- package/dist/utils/sessionLogger.d.ts +28 -0
- package/dist/utils/sessionLogger.d.ts.map +1 -0
- package/dist/utils/sessionLogger.js +142 -0
- package/dist/utils/sessionLogger.js.map +1 -0
- package/dist/utils/time.d.ts +15 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/time.js +32 -0
- package/dist/utils/time.js.map +1 -0
- package/dist/utils/validation.d.ts +23 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +88 -0
- package/dist/utils/validation.js.map +1 -0
- package/docs//346/227/245/345/277/227/347/263/273/347/273/237.md +389 -0
- package/docs//347/224/250/346/210/267/346/211/213/345/206/214.md +1446 -0
- package/docs//347/224/250/346/210/267/346/211/213/345/206/214/344/270/216/346/212/200/346/234/257/346/214/207/345/215/227.md +873 -0
- package/package.json +94 -0
- package/plugin/README.md +141 -0
- package/plugin/agents/zero-executor.md +114 -0
- package/plugin/agents/zero-reviewer.md +133 -0
- package/plugin/docs/diagnostic-guide.md +128 -0
- package/plugin/hooks/hooks.json.deprecated +70 -0
- package/plugin/scripts/cursor-hook-entry.cjs +217 -0
- package/plugin/scripts/hook-entry.cjs +663 -0
- package/plugin/scripts/openspec-import.cjs +714 -0
- package/plugin/scripts/shared/binding.cjs +98 -0
- package/plugin/scripts/shared/config.cjs +65 -0
- package/plugin/scripts/shared/context.cjs +120 -0
- package/plugin/scripts/shared/index.cjs +34 -0
- package/plugin/scripts/shared/logger.cjs +196 -0
- package/plugin/scripts/shared/reminder.cjs +261 -0
- package/plugin/scripts/shared/utils.cjs +62 -0
- package/plugin/scripts/shared/workspace.cjs +322 -0
- package/plugin/skills/aligning-intent/SKILL.md +275 -0
- package/plugin/skills/analyzing-measurements/SKILL.md +223 -0
- package/plugin/skills/bootstrapping-workspace/SKILL.md +260 -0
- package/plugin/skills/designing-solutions/SKILL.md +363 -0
- package/plugin/skills/diagnosing-issues/SKILL.md +219 -0
- package/plugin/skills/discovering-context/SKILL.md +283 -0
- package/plugin/skills/dispatching-parent/SKILL.md +399 -0
- package/plugin/skills/executing-task/SKILL.md +340 -0
- package/plugin/skills/memo-create/SKILL.md +222 -0
- package/plugin/skills/planning-verification/SKILL.md +245 -0
- package/plugin/skills/preparing-dispatch/SKILL.md +299 -0
- package/plugin/skills/researching-tech/SKILL.md +223 -0
- package/plugin/skills/reviewing-quality/SKILL.md +354 -0
- package/plugin/skills/reviewing-spec/SKILL.md +333 -0
- package/plugin/skills/starting-info-flow/SKILL.md +196 -0
- package/web/README.md +5 -0
- package/web/dist/assets/DocsView-Bls_Vjsr.css +1 -0
- package/web/dist/assets/DocsView-Cxc0B63r.js +1447 -0
- package/web/dist/assets/HomeView-C7df9thb.js +9 -0
- package/web/dist/assets/HomeView-ufUdnfHk.css +1 -0
- package/web/dist/assets/MarkdownContent-DXp6CtSP.js +308 -0
- package/web/dist/assets/MarkdownContent-NFqiOBLH.css +1 -0
- package/web/dist/assets/NotFoundView-BYX1oZAn.css +1 -0
- package/web/dist/assets/NotFoundView-zrc0lT9q.js +1 -0
- package/web/dist/assets/WorkspaceView-BckqgNcX.js +27 -0
- package/web/dist/assets/WorkspaceView-J1dgpYMx.css +1 -0
- package/web/dist/assets/WsConfirmDialog-C1CvL4my.css +1 -0
- package/web/dist/assets/WsConfirmDialog-gLEP7uBD.js +4 -0
- package/web/dist/assets/arc-DPkKTkUT.js +1 -0
- package/web/dist/assets/architectureDiagram-VXUJARFQ-CEGpqUlZ.js +36 -0
- package/web/dist/assets/blockDiagram-VD42YOAC-Bv-mqdQH.js +122 -0
- package/web/dist/assets/c4Diagram-YG6GDRKO-DRyPatZ_.js +10 -0
- package/web/dist/assets/channel-B84mKLDZ.js +1 -0
- package/web/dist/assets/chunk-4BX2VUAB-c7DivX0u.js +1 -0
- package/web/dist/assets/chunk-55IACEB6-CGKTaLlo.js +1 -0
- package/web/dist/assets/chunk-B4BG7PRW-Czhx5Q_P.js +165 -0
- package/web/dist/assets/chunk-DI55MBZ5-CQVA7hcZ.js +220 -0
- package/web/dist/assets/chunk-FMBD7UC4-hEiPmi7V.js +15 -0
- package/web/dist/assets/chunk-QN33PNHL-rL6yYI-E.js +1 -0
- package/web/dist/assets/chunk-QZHKN3VN-BRyHBBzq.js +1 -0
- package/web/dist/assets/chunk-TZMSLE5B-D4PXmTz9.js +1 -0
- package/web/dist/assets/classDiagram-2ON5EDUG-CNn53ohi.js +1 -0
- package/web/dist/assets/classDiagram-v2-WZHVMYZB-CNn53ohi.js +1 -0
- package/web/dist/assets/cose-bilkent-S5V4N54A-BAREnRga.js +1 -0
- package/web/dist/assets/cytoscape.esm-BnkdMOzK.js +321 -0
- package/web/dist/assets/dagre-6UL2VRFP-DaYzb3MT.js +4 -0
- package/web/dist/assets/defaultLocale-C4B-KCzX.js +1 -0
- package/web/dist/assets/diagram-PSM6KHXK-BFltDqvd.js +24 -0
- package/web/dist/assets/diagram-QEK2KX5R-CR4VU2La.js +43 -0
- package/web/dist/assets/diagram-S2PKOQOG-0UfIeT-1.js +24 -0
- package/web/dist/assets/erDiagram-Q2GNP2WA-Bo17Xmng.js +60 -0
- package/web/dist/assets/flowDiagram-NV44I4VS-CzqhQp8s.js +162 -0
- package/web/dist/assets/ganttDiagram-JELNMOA3-TXwXtUcq.js +267 -0
- package/web/dist/assets/gitGraphDiagram-NY62KEGX-CoFQTy9O.js +65 -0
- package/web/dist/assets/graph-CIQcRIVd.js +1 -0
- package/web/dist/assets/index-BgLd_o_M.css +1 -0
- package/web/dist/assets/index-Cd_J3fZn.js +30 -0
- package/web/dist/assets/infoDiagram-WHAUD3N6-Dq0xXfVu.js +2 -0
- package/web/dist/assets/init-Gi6I4Gst.js +1 -0
- package/web/dist/assets/journeyDiagram-XKPGCS4Q-jIg5BOfC.js +139 -0
- package/web/dist/assets/kanban-definition-3W4ZIXB7-D2giu6aZ.js +89 -0
- package/web/dist/assets/katex-XbL3y5x-.js +261 -0
- package/web/dist/assets/layout-Bm-XCM-8.js +1 -0
- package/web/dist/assets/linear-FbekP9OZ.js +1 -0
- package/web/dist/assets/min-BrRCpYmF.js +1 -0
- package/web/dist/assets/mindmap-definition-VGOIOE7T-o-4ubbY9.js +68 -0
- package/web/dist/assets/noto-emoji-0-400-normal-BTQbhB77.woff +0 -0
- package/web/dist/assets/noto-emoji-0-400-normal-DHdy6Uhy.woff2 +0 -0
- package/web/dist/assets/noto-emoji-1-400-normal-0IvkdXBB.woff +0 -0
- package/web/dist/assets/noto-emoji-1-400-normal-BY9OovbM.woff2 +0 -0
- package/web/dist/assets/noto-emoji-10-400-normal-D9w4QCof.woff2 +0 -0
- package/web/dist/assets/noto-emoji-10-400-normal-DtCumcZR.woff +0 -0
- package/web/dist/assets/noto-emoji-11-400-normal-BboTlyvx.woff +0 -0
- package/web/dist/assets/noto-emoji-12-400-normal-BB5pgBKj.woff2 +0 -0
- package/web/dist/assets/noto-emoji-12-400-normal-g186qhiA.woff +0 -0
- package/web/dist/assets/noto-emoji-2-400-normal-BKCR1azW.woff2 +0 -0
- package/web/dist/assets/noto-emoji-2-400-normal-BYH0KhDr.woff +0 -0
- package/web/dist/assets/noto-emoji-3-400-normal-CnPTUeEK.woff +0 -0
- package/web/dist/assets/noto-emoji-3-400-normal-TrTb2VQM.woff2 +0 -0
- package/web/dist/assets/noto-emoji-4-400-normal-BxD0KVdj.woff +0 -0
- package/web/dist/assets/noto-emoji-4-400-normal-s_n9EyG1.woff2 +0 -0
- package/web/dist/assets/noto-emoji-5-400-normal-C190AIxR.woff +0 -0
- package/web/dist/assets/noto-emoji-5-400-normal-Ctfx4xc6.woff2 +0 -0
- package/web/dist/assets/noto-emoji-6-400-normal-DlXlXWt7.woff +0 -0
- package/web/dist/assets/noto-emoji-6-400-normal-NzsjD754.woff2 +0 -0
- package/web/dist/assets/noto-emoji-7-400-normal-BHP8KeA6.woff2 +0 -0
- package/web/dist/assets/noto-emoji-7-400-normal-CtuKhtAZ.woff +0 -0
- package/web/dist/assets/noto-emoji-8-400-normal-DR49ZFe7.woff +0 -0
- package/web/dist/assets/noto-emoji-8-400-normal-Dvmkf6b2.woff2 +0 -0
- package/web/dist/assets/noto-emoji-9-400-normal-BeHJQ2iK.woff2 +0 -0
- package/web/dist/assets/noto-emoji-9-400-normal-BlXmCgeQ.woff +0 -0
- package/web/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/web/dist/assets/pieDiagram-ADFJNKIX-C45wSpld.js +30 -0
- package/web/dist/assets/quadrantDiagram-AYHSOK5B-tv-_fe-W.js +7 -0
- package/web/dist/assets/reduce-CoLNNlNb.js +1 -0
- package/web/dist/assets/requirementDiagram-UZGBJVZJ-Dn6PDfkL.js +64 -0
- package/web/dist/assets/sankeyDiagram-TZEHDZUN-CbXTZAsG.js +10 -0
- package/web/dist/assets/sequenceDiagram-WL72ISMW-B-o1CUJ5.js +145 -0
- package/web/dist/assets/stateDiagram-FKZM4ZOC-hzrupXQi.js +1 -0
- package/web/dist/assets/stateDiagram-v2-4FDKWEC3-DN-c2M96.js +1 -0
- package/web/dist/assets/timeline-definition-IT6M3QCI-R5SP9GDo.js +61 -0
- package/web/dist/assets/treemap-KMMF4GRG-Pg9KlUOt.js +128 -0
- package/web/dist/assets/xychartDiagram-PRI3JC2R-C3vbJhd1.js +7 -0
- package/web/dist/favicon.svg +13 -0
- package/web/dist/index.html +17 -0
- package//351/205/215/347/275/256/346/226/271/345/274/217.md +330 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 智能提醒模块
|
|
3
|
+
* 根据节点状态、日志、问题等信息智能判断是否需要提醒
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('node:fs');
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
const { getNodeGraph, getNodeLog, getNodeProblem, getWorkspaceEntry } = require('./workspace.cjs');
|
|
9
|
+
const { DIR_SUFFIX } = require('./config.cjs');
|
|
10
|
+
|
|
11
|
+
// 提醒优先级
|
|
12
|
+
const PRIORITY = {
|
|
13
|
+
P0_PROBLEM: 0, // 有未解决的问题
|
|
14
|
+
P1_LOG_TIMEOUT: 1, // 执行中但长时间未记录日志
|
|
15
|
+
P2_ALL_COMPLETED: 2, // 所有子节点已完成
|
|
16
|
+
P3_PLAN_CONFIRM: 3, // 计划需要用户确认
|
|
17
|
+
P4_NO_LOG: 4, // 开始执行但未记录日志
|
|
18
|
+
P5_NO_PROBLEM: 5, // 执行较长时间但未记录问题
|
|
19
|
+
P6_FAILED_NODE: 6, // 执行节点失败后引导
|
|
20
|
+
P7_NO_DOCS: 7 // 执行中但无文档引用
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// 时间阈值(分钟)
|
|
24
|
+
const THRESHOLDS = {
|
|
25
|
+
LOG_TIMEOUT: 3, // 日志超时阈值
|
|
26
|
+
NO_LOG_START: 1, // 开始后无日志阈值
|
|
27
|
+
NO_PROBLEM: 5 // 无问题记录阈值
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 计算时间差(分钟)
|
|
32
|
+
* @param {string} timeStr - 时间字符串 (格式: YYYY-MM-DD HH:mm:ss)
|
|
33
|
+
* @returns {number} 分钟数
|
|
34
|
+
*/
|
|
35
|
+
function getMinutesSince(timeStr) {
|
|
36
|
+
if (!timeStr) return Infinity;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
// 解析时间字符串
|
|
40
|
+
const parsed = new Date(timeStr.replace(' ', 'T'));
|
|
41
|
+
if (isNaN(parsed.getTime())) return Infinity;
|
|
42
|
+
|
|
43
|
+
const now = new Date();
|
|
44
|
+
const diffMs = now.getTime() - parsed.getTime();
|
|
45
|
+
return Math.floor(diffMs / 60000);
|
|
46
|
+
} catch {
|
|
47
|
+
return Infinity;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 解析 ISO 时间字符串
|
|
53
|
+
* @param {string} isoStr - ISO 格式时间字符串
|
|
54
|
+
* @returns {number} 分钟数
|
|
55
|
+
*/
|
|
56
|
+
function getMinutesSinceISO(isoStr) {
|
|
57
|
+
if (!isoStr) return Infinity;
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const parsed = new Date(isoStr);
|
|
61
|
+
if (isNaN(parsed.getTime())) return Infinity;
|
|
62
|
+
|
|
63
|
+
const now = new Date();
|
|
64
|
+
const diffMs = now.getTime() - parsed.getTime();
|
|
65
|
+
return Math.floor(diffMs / 60000);
|
|
66
|
+
} catch {
|
|
67
|
+
return Infinity;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 检查节点是否有文档引用
|
|
73
|
+
* @param {string} workspaceId - 工作区 ID
|
|
74
|
+
* @param {string} nodeId - 节点 ID
|
|
75
|
+
* @returns {boolean} 是否有文档引用
|
|
76
|
+
*/
|
|
77
|
+
function hasDocumentReferences(workspaceId, nodeId) {
|
|
78
|
+
const entry = getWorkspaceEntry(workspaceId);
|
|
79
|
+
if (!entry || !entry.projectRoot) {
|
|
80
|
+
return true; // 无法确认时不提醒
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const infoPath = path.join(entry.projectRoot, `.zero-workspace${DIR_SUFFIX}`, workspaceId, 'nodes', nodeId, 'Info.md');
|
|
84
|
+
try {
|
|
85
|
+
const content = fs.readFileSync(infoPath, 'utf-8');
|
|
86
|
+
// 查找文档引用区块
|
|
87
|
+
const docsMatch = content.match(/## 文档引用\n\n([\s\S]*?)(?=\n##|$)/);
|
|
88
|
+
if (!docsMatch) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
// 检查是否有实际的文档引用(排除"无"或空内容)
|
|
92
|
+
const docsText = docsMatch[1].trim();
|
|
93
|
+
if (!docsText || docsText === '无' || docsText === '(无)') {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
// 检查是否有 active 状态的文档
|
|
97
|
+
return docsText.includes('- ') && !docsText.includes('[expired]');
|
|
98
|
+
} catch {
|
|
99
|
+
return true; // 文件读取失败时不提醒
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 分析节点状态,返回需要的提醒
|
|
105
|
+
* @param {string} workspaceId - 工作区 ID
|
|
106
|
+
* @param {string} nodeId - 节点 ID
|
|
107
|
+
* @returns {object|null} 提醒信息 { priority, type, message } 或 null
|
|
108
|
+
*/
|
|
109
|
+
function analyzeNodeStatus(workspaceId, nodeId) {
|
|
110
|
+
const graph = getNodeGraph(workspaceId);
|
|
111
|
+
if (!graph || !graph.nodes || !graph.nodes[nodeId]) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const node = graph.nodes[nodeId];
|
|
116
|
+
const status = node.status;
|
|
117
|
+
const nodeType = node.type;
|
|
118
|
+
const parentId = node.parentId;
|
|
119
|
+
|
|
120
|
+
// 获取日志和问题信息
|
|
121
|
+
const logInfo = getNodeLog(workspaceId, nodeId);
|
|
122
|
+
const problemInfo = getNodeProblem(workspaceId, nodeId);
|
|
123
|
+
|
|
124
|
+
// P0: 有未解决的问题(排除空问题占位符)
|
|
125
|
+
const hasProblem = problemInfo && problemInfo.problem &&
|
|
126
|
+
problemInfo.problem !== '(暂无)' &&
|
|
127
|
+
problemInfo.problem !== '暂无' &&
|
|
128
|
+
problemInfo.problem.trim() !== '';
|
|
129
|
+
if (hasProblem) {
|
|
130
|
+
return {
|
|
131
|
+
priority: PRIORITY.P0_PROBLEM,
|
|
132
|
+
type: 'problem',
|
|
133
|
+
message: `⚠️ 当前有未解决问题:${problemInfo.problem}${problemInfo.nextStep ? `\n下一步:${problemInfo.nextStep}` : ''}`
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// P6: 执行节点失败后引导
|
|
138
|
+
if (nodeType === 'execution' && status === 'failed') {
|
|
139
|
+
return {
|
|
140
|
+
priority: PRIORITY.P6_FAILED_NODE,
|
|
141
|
+
type: 'failed_node',
|
|
142
|
+
message: `❌ 任务执行失败。请分析失败原因:
|
|
143
|
+
- 如果是可修复的问题(如临时错误、配置问题),使用 node_transition(action="retry") 重试
|
|
144
|
+
- 如果任务过于复杂或需要重新规划,回到父规划节点 ${parentId || 'root'} 重新分解任务`
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// 执行节点状态检查
|
|
149
|
+
if (nodeType === 'execution' && status === 'implementing') {
|
|
150
|
+
const nodeUpdatedAt = node.updatedAt;
|
|
151
|
+
const minutesSinceUpdate = getMinutesSinceISO(nodeUpdatedAt);
|
|
152
|
+
|
|
153
|
+
// 获取日志时间
|
|
154
|
+
const lastLogTime = logInfo?.lastTime;
|
|
155
|
+
const minutesSinceLog = getMinutesSince(lastLogTime);
|
|
156
|
+
const hasLog = logInfo && logInfo.entryCount > 0;
|
|
157
|
+
|
|
158
|
+
// P4: 开始执行但未记录日志(1分钟)
|
|
159
|
+
if (!hasLog && minutesSinceUpdate >= THRESHOLDS.NO_LOG_START) {
|
|
160
|
+
return {
|
|
161
|
+
priority: PRIORITY.P4_NO_LOG,
|
|
162
|
+
type: 'no_log',
|
|
163
|
+
message: `💡 任务已开始 ${minutesSinceUpdate} 分钟但未记录日志,建议用 log_append 记录执行过程`
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// P1: 执行中但长时间未记录日志(3分钟)
|
|
168
|
+
if (hasLog && minutesSinceLog >= THRESHOLDS.LOG_TIMEOUT) {
|
|
169
|
+
return {
|
|
170
|
+
priority: PRIORITY.P1_LOG_TIMEOUT,
|
|
171
|
+
type: 'log_timeout',
|
|
172
|
+
message: `💡 任务执行中,已 ${minutesSinceLog} 分钟未记录日志,建议用 log_append 记录进展`
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// P5: 执行较长时间但未记录问题(5分钟)
|
|
177
|
+
if (minutesSinceUpdate >= THRESHOLDS.NO_PROBLEM && (!problemInfo || !problemInfo.problem)) {
|
|
178
|
+
return {
|
|
179
|
+
priority: PRIORITY.P5_NO_PROBLEM,
|
|
180
|
+
type: 'no_problem',
|
|
181
|
+
message: `💡 任务已执行 ${minutesSinceUpdate} 分钟,如遇到阻塞请用 problem_update 记录问题和下一步计划`
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// P7: 执行中但无文档引用(仅在执行超过1分钟后提醒)
|
|
186
|
+
if (minutesSinceUpdate >= THRESHOLDS.NO_LOG_START && !hasDocumentReferences(workspaceId, nodeId)) {
|
|
187
|
+
return {
|
|
188
|
+
priority: PRIORITY.P7_NO_DOCS,
|
|
189
|
+
type: 'no_docs',
|
|
190
|
+
message: `📄 当前节点无文档引用。如需参考文档请用 node_reference 添加,或确认父节点是否遗漏派发文档。`
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// 规划节点状态检查
|
|
196
|
+
if (nodeType === 'planning') {
|
|
197
|
+
const children = node.children || [];
|
|
198
|
+
|
|
199
|
+
// P2: monitoring 状态且所有子节点已完成
|
|
200
|
+
if (status === 'monitoring' && children.length > 0) {
|
|
201
|
+
const allCompleted = children.every(childId => {
|
|
202
|
+
const child = graph.nodes[childId];
|
|
203
|
+
return child && ['completed', 'failed', 'cancelled'].includes(child.status);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
if (allCompleted) {
|
|
207
|
+
return {
|
|
208
|
+
priority: PRIORITY.P2_ALL_COMPLETED,
|
|
209
|
+
type: 'all_completed',
|
|
210
|
+
message: `✅ 所有 ${children.length} 个子节点已完成,请调用 node_transition(action="complete") 汇总结论`
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// P3: planning 状态 + 有子节点 + 是根节点的直接子节点
|
|
216
|
+
if (status === 'planning' && children.length > 0 && parentId === 'root') {
|
|
217
|
+
return {
|
|
218
|
+
priority: PRIORITY.P3_PLAN_CONFIRM,
|
|
219
|
+
type: 'plan_confirm',
|
|
220
|
+
message: `📋 计划已创建 ${children.length} 个子节点,请向用户展示计划并等待确认后再开始执行`
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 生成智能提醒内容
|
|
230
|
+
* @param {object} binding - 会话绑定信息
|
|
231
|
+
* @returns {string|null} 提醒内容或 null
|
|
232
|
+
*/
|
|
233
|
+
function generateSmartReminder(binding) {
|
|
234
|
+
if (!binding || !binding.workspaceId) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// 获取聚焦节点(优先使用 graph.currentFocus 作为权威来源)
|
|
239
|
+
const graph = getNodeGraph(binding.workspaceId);
|
|
240
|
+
const focusNodeId = graph?.currentFocus || binding.focusedNodeId;
|
|
241
|
+
if (!focusNodeId) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const reminder = analyzeNodeStatus(binding.workspaceId, focusNodeId);
|
|
246
|
+
if (!reminder) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return `<zero-smart-reminder>\n${reminder.message}\n</zero-smart-reminder>`;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
module.exports = {
|
|
254
|
+
PRIORITY,
|
|
255
|
+
THRESHOLDS,
|
|
256
|
+
getMinutesSince,
|
|
257
|
+
getMinutesSinceISO,
|
|
258
|
+
hasDocumentReferences,
|
|
259
|
+
analyzeNodeStatus,
|
|
260
|
+
generateSmartReminder
|
|
261
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用工具函数
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 读取 JSON 文件
|
|
9
|
+
* @param {string} filePath - 文件路径
|
|
10
|
+
* @returns {object|null} 解析后的 JSON 对象或 null
|
|
11
|
+
*/
|
|
12
|
+
function readJsonFile(filePath) {
|
|
13
|
+
try {
|
|
14
|
+
if (!fs.existsSync(filePath)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
18
|
+
return JSON.parse(content);
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 读取标准输入
|
|
26
|
+
* @returns {Promise<object>} 解析后的 JSON 对象
|
|
27
|
+
*/
|
|
28
|
+
async function readStdin() {
|
|
29
|
+
return new Promise((resolve) => {
|
|
30
|
+
let data = '';
|
|
31
|
+
|
|
32
|
+
// 设置超时,防止无限等待
|
|
33
|
+
const timeout = setTimeout(() => {
|
|
34
|
+
resolve({});
|
|
35
|
+
}, 3000);
|
|
36
|
+
|
|
37
|
+
process.stdin.setEncoding('utf8');
|
|
38
|
+
process.stdin.on('data', (chunk) => {
|
|
39
|
+
data += chunk;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
process.stdin.on('end', () => {
|
|
43
|
+
clearTimeout(timeout);
|
|
44
|
+
try {
|
|
45
|
+
resolve(JSON.parse(data));
|
|
46
|
+
} catch {
|
|
47
|
+
resolve({});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// 如果没有输入,立即结束
|
|
52
|
+
if (process.stdin.isTTY) {
|
|
53
|
+
clearTimeout(timeout);
|
|
54
|
+
resolve({});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = {
|
|
60
|
+
readJsonFile,
|
|
61
|
+
readStdin
|
|
62
|
+
};
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工作区数据读取逻辑
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
const { readJsonFile } = require('./utils.cjs');
|
|
8
|
+
const { INDEX_PATH, DIR_SUFFIX } = require('./config.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 获取工作区入口信息
|
|
12
|
+
* @param {string} workspaceId - 工作区 ID
|
|
13
|
+
* @returns {object|null} 工作区入口信息
|
|
14
|
+
*/
|
|
15
|
+
function getWorkspaceEntry(workspaceId) {
|
|
16
|
+
const index = readJsonFile(INDEX_PATH);
|
|
17
|
+
if (!index || !index.workspaces) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return index.workspaces.find(ws => ws.id === workspaceId) || null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 获取工作区配置
|
|
25
|
+
* @param {string} workspaceId - 工作区 ID
|
|
26
|
+
* @returns {object|null} 工作区配置
|
|
27
|
+
*/
|
|
28
|
+
function getWorkspaceConfig(workspaceId) {
|
|
29
|
+
const entry = getWorkspaceEntry(workspaceId);
|
|
30
|
+
if (!entry || !entry.projectRoot) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const configPath = path.join(entry.projectRoot, `.zero-workspace${DIR_SUFFIX}`, entry.dirName, 'workspace.json');
|
|
35
|
+
return readJsonFile(configPath);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 解析 Workspace.md
|
|
40
|
+
* @param {string} content - Markdown 内容
|
|
41
|
+
* @returns {object} 解析结果
|
|
42
|
+
*/
|
|
43
|
+
function parseWorkspaceMd(content) {
|
|
44
|
+
const result = {
|
|
45
|
+
goal: '',
|
|
46
|
+
rules: [],
|
|
47
|
+
docs: []
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// 解析目标
|
|
51
|
+
const goalMatch = content.match(/## 目标\n\n([\s\S]*?)(?=\n##|$)/);
|
|
52
|
+
if (goalMatch) {
|
|
53
|
+
result.goal = goalMatch[1].trim();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 解析规则
|
|
57
|
+
const rulesMatch = content.match(/## 规则\n\n[\s\S]*?\n\n([\s\S]*?)(?=\n##|$)/);
|
|
58
|
+
if (rulesMatch) {
|
|
59
|
+
const rulesText = rulesMatch[1];
|
|
60
|
+
result.rules = rulesText
|
|
61
|
+
.split('\n')
|
|
62
|
+
.filter(line => line.startsWith('- '))
|
|
63
|
+
.map(line => line.slice(2).trim());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 获取工作区 Markdown 数据
|
|
71
|
+
* @param {string} workspaceId - 工作区 ID
|
|
72
|
+
* @returns {object|null} 解析后的 Markdown 数据
|
|
73
|
+
*/
|
|
74
|
+
function getWorkspaceMdData(workspaceId) {
|
|
75
|
+
const entry = getWorkspaceEntry(workspaceId);
|
|
76
|
+
if (!entry || !entry.projectRoot) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const mdPath = path.join(entry.projectRoot, `.zero-workspace${DIR_SUFFIX}`, entry.dirName, 'Workspace.md');
|
|
81
|
+
try {
|
|
82
|
+
const content = fs.readFileSync(mdPath, 'utf-8');
|
|
83
|
+
return parseWorkspaceMd(content);
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 获取节点图
|
|
91
|
+
* @param {string} workspaceId - 工作区 ID
|
|
92
|
+
* @returns {object|null} 节点图数据
|
|
93
|
+
*/
|
|
94
|
+
function getNodeGraph(workspaceId) {
|
|
95
|
+
const entry = getWorkspaceEntry(workspaceId);
|
|
96
|
+
if (!entry || !entry.projectRoot) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const graphPath = path.join(entry.projectRoot, `.zero-workspace${DIR_SUFFIX}`, entry.dirName, 'graph.json');
|
|
101
|
+
return readJsonFile(graphPath);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 解析节点 Info.md
|
|
106
|
+
* @param {string} content - Markdown 内容
|
|
107
|
+
* @returns {object} 解析结果
|
|
108
|
+
*/
|
|
109
|
+
function parseNodeInfo(content) {
|
|
110
|
+
const result = {
|
|
111
|
+
title: '',
|
|
112
|
+
status: '',
|
|
113
|
+
requirement: ''
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// 解析标题
|
|
117
|
+
const titleMatch = content.match(/^# (.+)$/m);
|
|
118
|
+
if (titleMatch) {
|
|
119
|
+
result.title = titleMatch[1].trim();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 解析状态(从 frontmatter 或内容中)
|
|
123
|
+
const statusMatch = content.match(/status:\s*(.+)/);
|
|
124
|
+
if (statusMatch) {
|
|
125
|
+
result.status = statusMatch[1].trim();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 解析需求
|
|
129
|
+
const reqMatch = content.match(/## 需求\n\n([\s\S]*?)(?=\n##|$)/);
|
|
130
|
+
if (reqMatch) {
|
|
131
|
+
result.requirement = reqMatch[1].trim();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 获取节点信息
|
|
139
|
+
* @param {string} workspaceId - 工作区 ID
|
|
140
|
+
* @param {string} nodeId - 节点 ID
|
|
141
|
+
* @returns {object|null} 节点信息
|
|
142
|
+
*/
|
|
143
|
+
function getNodeInfo(workspaceId, nodeId) {
|
|
144
|
+
const entry = getWorkspaceEntry(workspaceId);
|
|
145
|
+
if (!entry || !entry.projectRoot) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const infoPath = path.join(entry.projectRoot, `.zero-workspace${DIR_SUFFIX}`, entry.dirName, 'nodes', nodeId, 'Info.md');
|
|
150
|
+
try {
|
|
151
|
+
const content = fs.readFileSync(infoPath, 'utf-8');
|
|
152
|
+
return parseNodeInfo(content);
|
|
153
|
+
} catch {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 解析 Log.md 获取日志信息
|
|
160
|
+
* @param {string} content - Markdown 内容
|
|
161
|
+
* @returns {object} 解析结果 { lastEntry, lastTime, entryCount }
|
|
162
|
+
*/
|
|
163
|
+
function parseLogMd(content) {
|
|
164
|
+
const result = {
|
|
165
|
+
lastEntry: null,
|
|
166
|
+
lastTime: null,
|
|
167
|
+
entryCount: 0
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// 匹配日志表格行: | 时间 | 操作者 | 事件 |
|
|
171
|
+
const tableRows = content.match(/\| \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} \|[^|]+\|[^|]+\|/g);
|
|
172
|
+
if (!tableRows || tableRows.length === 0) {
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
result.entryCount = tableRows.length;
|
|
177
|
+
|
|
178
|
+
// 获取最后一条日志
|
|
179
|
+
const lastRow = tableRows[tableRows.length - 1];
|
|
180
|
+
const parts = lastRow.split('|').map(s => s.trim()).filter(s => s);
|
|
181
|
+
if (parts.length >= 3) {
|
|
182
|
+
result.lastTime = parts[0];
|
|
183
|
+
result.lastEntry = {
|
|
184
|
+
time: parts[0],
|
|
185
|
+
operator: parts[1],
|
|
186
|
+
event: parts[2]
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* 获取节点日志信息
|
|
195
|
+
* @param {string} workspaceId - 工作区 ID
|
|
196
|
+
* @param {string} nodeId - 节点 ID
|
|
197
|
+
* @returns {object|null} 日志信息 { lastEntry, lastTime, entryCount }
|
|
198
|
+
*/
|
|
199
|
+
function getNodeLog(workspaceId, nodeId) {
|
|
200
|
+
const entry = getWorkspaceEntry(workspaceId);
|
|
201
|
+
if (!entry || !entry.projectRoot) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const logPath = path.join(entry.projectRoot, `.zero-workspace${DIR_SUFFIX}`, entry.dirName, 'nodes', nodeId, 'Log.md');
|
|
206
|
+
try {
|
|
207
|
+
const content = fs.readFileSync(logPath, 'utf-8');
|
|
208
|
+
return parseLogMd(content);
|
|
209
|
+
} catch {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 解析 Problem.md 获取问题信息
|
|
216
|
+
* @param {string} content - Markdown 内容
|
|
217
|
+
* @returns {object} 解析结果 { problem, nextStep }
|
|
218
|
+
*/
|
|
219
|
+
function parseProblemMd(content) {
|
|
220
|
+
const result = {
|
|
221
|
+
problem: null,
|
|
222
|
+
nextStep: null
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// 解析当前问题
|
|
226
|
+
const problemMatch = content.match(/## 当前问题\n\n([\s\S]*?)(?=\n##|$)/);
|
|
227
|
+
if (problemMatch) {
|
|
228
|
+
const problemText = problemMatch[1].trim();
|
|
229
|
+
if (problemText && problemText !== '无') {
|
|
230
|
+
result.problem = problemText;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// 解析下一步计划(支持 "下一步" 和 "下一步计划" 两种格式)
|
|
235
|
+
const nextStepMatch = content.match(/## 下一步(?:计划)?\n\n([\s\S]*?)(?=\n##|$)/);
|
|
236
|
+
if (nextStepMatch) {
|
|
237
|
+
const nextStepText = nextStepMatch[1].trim();
|
|
238
|
+
if (nextStepText && nextStepText !== '无' && nextStepText !== '(暂无)') {
|
|
239
|
+
result.nextStep = nextStepText;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return result;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* 获取节点问题信息
|
|
248
|
+
* @param {string} workspaceId - 工作区 ID
|
|
249
|
+
* @param {string} nodeId - 节点 ID
|
|
250
|
+
* @returns {object|null} 问题信息 { problem, nextStep }
|
|
251
|
+
*/
|
|
252
|
+
function getNodeProblem(workspaceId, nodeId) {
|
|
253
|
+
const entry = getWorkspaceEntry(workspaceId);
|
|
254
|
+
if (!entry || !entry.projectRoot) {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const problemPath = path.join(entry.projectRoot, `.zero-workspace${DIR_SUFFIX}`, entry.dirName, 'nodes', nodeId, 'Problem.md');
|
|
259
|
+
try {
|
|
260
|
+
const content = fs.readFileSync(problemPath, 'utf-8');
|
|
261
|
+
return parseProblemMd(content);
|
|
262
|
+
} catch {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* 获取与指定 cwd 匹配的活跃工作区列表
|
|
269
|
+
* @param {string} cwd - 当前工作目录
|
|
270
|
+
* @returns {Array<object>} 匹配的工作区列表 [{ id, name, projectRoot, goal }]
|
|
271
|
+
*/
|
|
272
|
+
function getWorkspacesByCwd(cwd) {
|
|
273
|
+
const index = readJsonFile(INDEX_PATH);
|
|
274
|
+
if (!index || !index.workspaces) {
|
|
275
|
+
return [];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// 规范化 cwd 路径
|
|
279
|
+
const normalizedCwd = path.resolve(cwd);
|
|
280
|
+
|
|
281
|
+
// 查找匹配的活跃工作区
|
|
282
|
+
const matchedWorkspaces = index.workspaces
|
|
283
|
+
.filter(ws => {
|
|
284
|
+
// 只匹配活跃工作区
|
|
285
|
+
if (ws.status !== 'active') return false;
|
|
286
|
+
|
|
287
|
+
// 检查 projectRoot 是否匹配
|
|
288
|
+
if (!ws.projectRoot) return false;
|
|
289
|
+
const normalizedRoot = path.resolve(ws.projectRoot);
|
|
290
|
+
|
|
291
|
+
// cwd 等于或是 projectRoot 的子目录
|
|
292
|
+
return normalizedCwd === normalizedRoot ||
|
|
293
|
+
normalizedCwd.startsWith(normalizedRoot + path.sep);
|
|
294
|
+
})
|
|
295
|
+
.map(ws => {
|
|
296
|
+
// 获取工作区目标
|
|
297
|
+
const mdData = getWorkspaceMdData(ws.id);
|
|
298
|
+
return {
|
|
299
|
+
id: ws.id,
|
|
300
|
+
name: ws.name,
|
|
301
|
+
projectRoot: ws.projectRoot,
|
|
302
|
+
goal: mdData?.goal || ''
|
|
303
|
+
};
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
return matchedWorkspaces;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
module.exports = {
|
|
310
|
+
getWorkspaceEntry,
|
|
311
|
+
getWorkspaceConfig,
|
|
312
|
+
getWorkspaceMdData,
|
|
313
|
+
getNodeGraph,
|
|
314
|
+
getNodeInfo,
|
|
315
|
+
getNodeLog,
|
|
316
|
+
getNodeProblem,
|
|
317
|
+
parseWorkspaceMd,
|
|
318
|
+
parseNodeInfo,
|
|
319
|
+
parseLogMd,
|
|
320
|
+
parseProblemMd,
|
|
321
|
+
getWorkspacesByCwd
|
|
322
|
+
};
|