kenaz 0.0.0-stage → 0.3.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/bin/kenaz.js +3 -0
- package/core/.agents/skills/remotion-best-practices/SKILL.md +61 -0
- package/core/.agents/skills/remotion-best-practices/rules/3d.md +86 -0
- package/core/.agents/skills/remotion-best-practices/rules/animations.md +27 -0
- package/core/.agents/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +173 -0
- package/core/.agents/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
- package/core/.agents/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +103 -0
- package/core/.agents/skills/remotion-best-practices/rules/assets.md +78 -0
- package/core/.agents/skills/remotion-best-practices/rules/audio-visualization.md +198 -0
- package/core/.agents/skills/remotion-best-practices/rules/audio.md +169 -0
- package/core/.agents/skills/remotion-best-practices/rules/calculate-metadata.md +134 -0
- package/core/.agents/skills/remotion-best-practices/rules/can-decode.md +81 -0
- package/core/.agents/skills/remotion-best-practices/rules/charts.md +120 -0
- package/core/.agents/skills/remotion-best-practices/rules/compositions.md +154 -0
- package/core/.agents/skills/remotion-best-practices/rules/display-captions.md +184 -0
- package/core/.agents/skills/remotion-best-practices/rules/extract-frames.md +229 -0
- package/core/.agents/skills/remotion-best-practices/rules/ffmpeg.md +38 -0
- package/core/.agents/skills/remotion-best-practices/rules/fonts.md +152 -0
- package/core/.agents/skills/remotion-best-practices/rules/get-audio-duration.md +58 -0
- package/core/.agents/skills/remotion-best-practices/rules/get-video-dimensions.md +68 -0
- package/core/.agents/skills/remotion-best-practices/rules/get-video-duration.md +60 -0
- package/core/.agents/skills/remotion-best-practices/rules/gifs.md +141 -0
- package/core/.agents/skills/remotion-best-practices/rules/images.md +134 -0
- package/core/.agents/skills/remotion-best-practices/rules/import-srt-captions.md +69 -0
- package/core/.agents/skills/remotion-best-practices/rules/light-leaks.md +73 -0
- package/core/.agents/skills/remotion-best-practices/rules/lottie.md +70 -0
- package/core/.agents/skills/remotion-best-practices/rules/maps.md +412 -0
- package/core/.agents/skills/remotion-best-practices/rules/measuring-dom-nodes.md +34 -0
- package/core/.agents/skills/remotion-best-practices/rules/measuring-text.md +140 -0
- package/core/.agents/skills/remotion-best-practices/rules/parameters.md +109 -0
- package/core/.agents/skills/remotion-best-practices/rules/sequencing.md +118 -0
- package/core/.agents/skills/remotion-best-practices/rules/sfx.md +30 -0
- package/core/.agents/skills/remotion-best-practices/rules/subtitles.md +36 -0
- package/core/.agents/skills/remotion-best-practices/rules/tailwind.md +11 -0
- package/core/.agents/skills/remotion-best-practices/rules/text-animations.md +20 -0
- package/core/.agents/skills/remotion-best-practices/rules/timing.md +179 -0
- package/core/.agents/skills/remotion-best-practices/rules/transcribe-captions.md +70 -0
- package/core/.agents/skills/remotion-best-practices/rules/transitions.md +197 -0
- package/core/.agents/skills/remotion-best-practices/rules/transparent-videos.md +106 -0
- package/core/.agents/skills/remotion-best-practices/rules/trimming.md +51 -0
- package/core/.agents/skills/remotion-best-practices/rules/videos.md +171 -0
- package/core/.agents/skills/remotion-best-practices/rules/voiceover.md +99 -0
- package/core/.agents/skills/supabase-postgres-best-practices/AGENTS.md +90 -0
- package/core/.agents/skills/supabase-postgres-best-practices/CLAUDE.md +1 -0
- package/core/.agents/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/query-index-types.md +45 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/core/.agents/skills/supabase-postgres-best-practices/references/security-rls-performance.md +57 -0
- package/core/.agents/skills/typesafe-ai/LICENSE +21 -0
- package/core/.agents/skills/typesafe-ai/SKILL.md +149 -0
- package/core/.agents/skills/vercel-react-best-practices/AGENTS.md +2934 -0
- package/core/.agents/skills/vercel-react-best-practices/SKILL.md +136 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/core/.agents/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
- package/core/.claude/agents/pcb-reviewer.md +146 -0
- package/core/.claude/commands/Amelia.md +5 -0
- package/core/.claude/commands/Ansuz.md +38 -0
- package/core/.claude/commands/Huginn.md +25 -0
- package/core/.claude/commands/agent-worker.md +168 -0
- package/core/.claude/commands/architect.md +24 -0
- package/core/.claude/commands/archive.md +24 -0
- package/core/.claude/commands/canary.md +17 -0
- package/core/.claude/commands/incident.md +15 -0
- package/core/.claude/commands/init.md +112 -0
- package/core/.claude/commands/legacy_dev.md +18 -0
- package/core/.claude/commands/product-review.md +131 -0
- package/core/.claude/commands/review.md +14 -0
- package/core/.claude/commands/security.md +15 -0
- package/core/.claude/commands/spec.md +22 -0
- package/core/.claude/commands/strategy.md +141 -0
- package/core/.claude/commands/sunny.md +1 -0
- package/core/.claude/commands//347/224/242/345/223/201.md +15 -0
- package/core/.claude/commands//347/224/242/345/223/201/346/252/242/350/246/226.md +129 -0
- package/core/.claude/commands//350/250/255/350/250/210.md +14 -0
- package/core/.claude/commands//350/251/225/344/274/260.md +16 -0
- package/core/.claude/commands//351/200/262/345/272/246.md +15 -0
- package/core/.claude/hooks/__tests__/substrate.test.js +122 -0
- package/core/.claude/hooks/__tests__/task-1866-cli-guard.test.js +193 -0
- package/core/.claude/hooks/__tests__/task-1977-dedupe-guard.test.js +125 -0
- package/core/.claude/hooks/__tests__/task-2087-mark-landed-idempotent.test.js +128 -0
- package/core/.claude/hooks/__tests__/task-2253-null-tip-marker-reuse.test.js +84 -0
- package/core/.claude/hooks/__tests__/task-2381-project-guard-walkup.test.js +53 -0
- package/core/.claude/hooks/_ansuz-conversation.js +183 -0
- package/core/.claude/hooks/_ansuz-conversation.test.js +90 -0
- package/core/.claude/hooks/_dedupe-guard.js +75 -0
- package/core/.claude/hooks/_peer-project-root.js +113 -0
- package/core/.claude/hooks/_peer-project-root.test.js +121 -0
- package/core/.claude/hooks/_peer-waiting-line.js +27 -0
- package/core/.claude/hooks/_project-guard.js +45 -0
- package/core/.claude/hooks/_run-user-prompt.js +134 -0
- package/core/.claude/hooks/_run-user-prompt.test.js +80 -0
- package/core/.claude/hooks/_session-identity.js +62 -0
- package/core/.claude/hooks/_session-pin.js +34 -0
- package/core/.claude/hooks/_session-pin.test.js +89 -0
- package/core/.claude/hooks/_signal-fence.js +17 -0
- package/core/.claude/hooks/_substrate-paths.js +95 -0
- package/core/.claude/hooks/_user-scope.js +23 -0
- package/core/.claude/hooks/ansuz-session-pin-via-turn-context.test.js +52 -0
- package/core/.claude/hooks/ansuz-session-pin.js +171 -0
- package/core/.claude/hooks/ansuz-session-pin.test.js +140 -0
- package/core/.claude/hooks/context-check.js +51 -0
- package/core/.claude/hooks/core-resolve.js +230 -0
- package/core/.claude/hooks/daemon-outbox-hook.js +139 -0
- package/core/.claude/hooks/fatigue-check.js +52 -0
- package/core/.claude/hooks/handoff-snapshot-on-commit.js +154 -0
- package/core/.claude/hooks/handoff-snapshot-on-decision.js +188 -0
- package/core/.claude/hooks/handoff-snapshot-on-question.js +158 -0
- package/core/.claude/hooks/handoff-staleness.js +197 -0
- package/core/.claude/hooks/jev-thalamus-context.js +17 -0
- package/core/.claude/hooks/jev-thalamus-context.test.js +41 -0
- package/core/.claude/hooks/lease-release.js +119 -0
- package/core/.claude/hooks/lease-touch.js +96 -0
- package/core/.claude/hooks/memory-guard.js +723 -0
- package/core/.claude/hooks/memory-guard.test.js +574 -0
- package/core/.claude/hooks/reflex-feedback.js +5 -0
- package/core/.claude/hooks/session-init.ps1 +49 -0
- package/core/.claude/hooks/sound-event.js +70 -0
- package/core/.claude/hooks/sound-event.sh +37 -0
- package/core/.claude/hooks/stream-delta.js +169 -0
- package/core/.claude/hooks/synapse-first-investigation.js +326 -0
- package/core/.claude/hooks/synapse-first-investigation.test.js +126 -0
- package/core/.claude/hooks/task-bridge.js +33 -0
- package/core/.claude/hooks/turn-context-peer.test.js +115 -0
- package/core/.claude/hooks/turn-context-session-line.test.js +69 -0
- package/core/.claude/hooks/turn-context.js +215 -0
- package/core/.claude/hooks/worktree-create.js +1232 -0
- package/core/.claude/hooks/worktree-remove.js +181 -0
- package/core/.claude/no-hooks.settings.json +3 -0
- package/core/.claude/settings.json +180 -0
- package/core/.claude/skills/adapt/SKILL.md +199 -0
- package/core/.claude/skills/animate/SKILL.md +190 -0
- package/core/.claude/skills/architect_agent/SKILL.md +408 -0
- package/core/.claude/skills/assessment_agent/SKILL.md +289 -0
- package/core/.claude/skills/audit/SKILL.md +129 -0
- package/core/.claude/skills/backend_agent/SKILL.md +407 -0
- package/core/.claude/skills/backend_engineer/SKILL.md +788 -0
- package/core/.claude/skills/bolder/SKILL.md +132 -0
- package/core/.claude/skills/clarify/SKILL.md +180 -0
- package/core/.claude/skills/code_reviewer/SKILL.md +305 -0
- package/core/.claude/skills/code_reviewer/patterns.yaml +85 -0
- package/core/.claude/skills/colorize/SKILL.md +158 -0
- package/core/.claude/skills/critique/SKILL.md +118 -0
- package/core/.claude/skills/delight/SKILL.md +317 -0
- package/core/.claude/skills/designer/SKILL.md +845 -0
- package/core/.claude/skills/dev_agent/SKILL.md +503 -0
- package/core/.claude/skills/developer/SKILL.md +792 -0
- package/core/.claude/skills/distill/SKILL.md +137 -0
- package/core/.claude/skills/extract/SKILL.md +95 -0
- package/core/.claude/skills/feature_agent/SKILL.md +303 -0
- package/core/.claude/skills/frontend-design/SKILL.md +127 -0
- package/core/.claude/skills/frontend-design/reference/color-and-contrast.md +132 -0
- package/core/.claude/skills/frontend-design/reference/interaction-design.md +123 -0
- package/core/.claude/skills/frontend-design/reference/motion-design.md +99 -0
- package/core/.claude/skills/frontend-design/reference/responsive-design.md +114 -0
- package/core/.claude/skills/frontend-design/reference/spatial-design.md +100 -0
- package/core/.claude/skills/frontend-design/reference/typography.md +131 -0
- package/core/.claude/skills/frontend-design/reference/ux-writing.md +107 -0
- package/core/.claude/skills/frontend_agent/SKILL.md +327 -0
- package/core/.claude/skills/harden/SKILL.md +358 -0
- package/core/.claude/skills/heimdall/SKILL.md +84 -0
- package/core/.claude/skills/huginn/SKILL.md +208 -0
- package/core/.claude/skills/incident_response/SKILL.md +315 -0
- package/core/.claude/skills/legacy_dev/SKILL.md +202 -0
- package/core/.claude/skills/normalize/SKILL.md +67 -0
- package/core/.claude/skills/onboard/SKILL.md +243 -0
- package/core/.claude/skills/optimization_agent/SKILL.md +340 -0
- package/core/.claude/skills/optimize/SKILL.md +269 -0
- package/core/.claude/skills/pcb-review/SKILL.md +39 -0
- package/core/.claude/skills/polish/SKILL.md +202 -0
- package/core/.claude/skills/product_manager/SKILL.md +1091 -0
- package/core/.claude/skills/qa_engineer/SKILL.md +1269 -0
- package/core/.claude/skills/quieter/SKILL.md +118 -0
- package/core/.claude/skills/remotion-best-practices/SKILL.md +61 -0
- package/core/.claude/skills/remotion-best-practices/rules/3d.md +86 -0
- package/core/.claude/skills/remotion-best-practices/rules/animations.md +27 -0
- package/core/.claude/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +173 -0
- package/core/.claude/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
- package/core/.claude/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +103 -0
- package/core/.claude/skills/remotion-best-practices/rules/assets.md +78 -0
- package/core/.claude/skills/remotion-best-practices/rules/audio-visualization.md +198 -0
- package/core/.claude/skills/remotion-best-practices/rules/audio.md +169 -0
- package/core/.claude/skills/remotion-best-practices/rules/calculate-metadata.md +134 -0
- package/core/.claude/skills/remotion-best-practices/rules/can-decode.md +81 -0
- package/core/.claude/skills/remotion-best-practices/rules/charts.md +120 -0
- package/core/.claude/skills/remotion-best-practices/rules/compositions.md +154 -0
- package/core/.claude/skills/remotion-best-practices/rules/display-captions.md +184 -0
- package/core/.claude/skills/remotion-best-practices/rules/extract-frames.md +229 -0
- package/core/.claude/skills/remotion-best-practices/rules/ffmpeg.md +38 -0
- package/core/.claude/skills/remotion-best-practices/rules/fonts.md +152 -0
- package/core/.claude/skills/remotion-best-practices/rules/get-audio-duration.md +58 -0
- package/core/.claude/skills/remotion-best-practices/rules/get-video-dimensions.md +68 -0
- package/core/.claude/skills/remotion-best-practices/rules/get-video-duration.md +60 -0
- package/core/.claude/skills/remotion-best-practices/rules/gifs.md +141 -0
- package/core/.claude/skills/remotion-best-practices/rules/images.md +134 -0
- package/core/.claude/skills/remotion-best-practices/rules/import-srt-captions.md +69 -0
- package/core/.claude/skills/remotion-best-practices/rules/light-leaks.md +73 -0
- package/core/.claude/skills/remotion-best-practices/rules/lottie.md +70 -0
- package/core/.claude/skills/remotion-best-practices/rules/maps.md +412 -0
- package/core/.claude/skills/remotion-best-practices/rules/measuring-dom-nodes.md +34 -0
- package/core/.claude/skills/remotion-best-practices/rules/measuring-text.md +140 -0
- package/core/.claude/skills/remotion-best-practices/rules/parameters.md +109 -0
- package/core/.claude/skills/remotion-best-practices/rules/sequencing.md +118 -0
- package/core/.claude/skills/remotion-best-practices/rules/sfx.md +30 -0
- package/core/.claude/skills/remotion-best-practices/rules/subtitles.md +36 -0
- package/core/.claude/skills/remotion-best-practices/rules/tailwind.md +11 -0
- package/core/.claude/skills/remotion-best-practices/rules/text-animations.md +20 -0
- package/core/.claude/skills/remotion-best-practices/rules/timing.md +179 -0
- package/core/.claude/skills/remotion-best-practices/rules/transcribe-captions.md +70 -0
- package/core/.claude/skills/remotion-best-practices/rules/transitions.md +197 -0
- package/core/.claude/skills/remotion-best-practices/rules/transparent-videos.md +106 -0
- package/core/.claude/skills/remotion-best-practices/rules/trimming.md +51 -0
- package/core/.claude/skills/remotion-best-practices/rules/videos.md +171 -0
- package/core/.claude/skills/remotion-best-practices/rules/voiceover.md +99 -0
- package/core/.claude/skills/security_agent/SKILL.md +312 -0
- package/core/.claude/skills/spec_optimizer/SKILL.md +299 -0
- package/core/.claude/skills/sre_agent/SKILL.md +1347 -0
- package/core/.claude/skills/sunny/SKILL.md +74 -0
- package/core/.claude/skills/supabase-postgres-best-practices/AGENTS.md +90 -0
- package/core/.claude/skills/supabase-postgres-best-practices/CLAUDE.md +1 -0
- package/core/.claude/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/query-index-types.md +45 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/core/.claude/skills/supabase-postgres-best-practices/references/security-rls-performance.md +57 -0
- package/core/.claude/skills/synapse_maintain/SKILL.md +84 -0
- package/core/.claude/skills/ui-ux-pro-max/SKILL.md +377 -0
- package/core/.claude/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/core/.claude/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/core/.claude/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/core/.claude/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/core/.claude/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/core/.claude/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/core/.claude/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/core/.claude/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/core/.claude/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/core/.claude/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/core/.claude/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/core/.claude/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/core/.claude/skills/ui-ux-pro-max/scripts/core.py +253 -0
- package/core/.claude/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/core/.claude/skills/ui-ux-pro-max/scripts/search.py +106 -0
- package/core/.claude/skills/vercel-react-best-practices/AGENTS.md +2934 -0
- package/core/.claude/skills/vercel-react-best-practices/SKILL.md +136 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/core/.claude/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
- package/core/.collaboration/README.md +258 -0
- package/core/.collaboration/cli/commands/assign.js +39 -0
- package/core/.collaboration/cli/commands/claim.js +33 -0
- package/core/.collaboration/cli/commands/complete.js +44 -0
- package/core/.collaboration/cli/commands/create.js +110 -0
- package/core/.collaboration/cli/commands/get.js +83 -0
- package/core/.collaboration/cli/commands/index.js +52 -0
- package/core/.collaboration/cli/commands/list.js +51 -0
- package/core/.collaboration/cli/commands/lock.js +45 -0
- package/core/.collaboration/cli/commands/rebuild.js +39 -0
- package/core/.collaboration/cli/commands/search.js +61 -0
- package/core/.collaboration/cli/commands/stats.js +61 -0
- package/core/.collaboration/cli/commands/transfer.js +41 -0
- package/core/.collaboration/cli/commands/unlock.js +48 -0
- package/core/.collaboration/cli/formatters/help-formatter.js +70 -0
- package/core/.collaboration/cli/formatters/index.js +7 -0
- package/core/.collaboration/cli/task-cli.js +46 -0
- package/core/.collaboration/cli/utils/arg-parser.js +74 -0
- package/core/.collaboration/cli/utils/git-user.js +25 -0
- package/core/.collaboration/cli/utils/index.js +9 -0
- package/core/.collaboration/cli/utils/output.js +10 -0
- package/core/.collaboration/config/default.yaml +189 -0
- package/core/.collaboration/core/conflict-resolver.js +461 -0
- package/core/.collaboration/core/conflict-resolver.test.js +389 -0
- package/core/.collaboration/core/id-generator.js +303 -0
- package/core/.collaboration/core/migrate-legacy.js +260 -0
- package/core/.collaboration/core/package.json +1 -0
- package/core/.collaboration/core/task-2257-estimated-hours.test.js +72 -0
- package/core/.collaboration/core/task-2260-dir-layout-move.test.js +60 -0
- package/core/.collaboration/core/task-2264-single-after-capture.test.js +61 -0
- package/core/.collaboration/core/task-2288-followups.test.js +121 -0
- package/core/.collaboration/core/task-api-json.js +211 -0
- package/core/.collaboration/core/task-api.js +3729 -0
- package/core/.collaboration/core/task-api.test.js +1268 -0
- package/core/.collaboration/docs/API.md +787 -0
- package/core/.collaboration/docs/ARCHITECTURE.md +596 -0
- package/core/.collaboration/docs/CLI.md +821 -0
- package/core/.collaboration/docs/FAQ.md +695 -0
- package/core/.collaboration/docs/MIGRATION.md +804 -0
- package/core/.collaboration/docs/examples/README.md +320 -0
- package/core/.collaboration/docs/examples/advanced-queries.js +261 -0
- package/core/.collaboration/docs/examples/basic-usage.js +184 -0
- package/core/.collaboration/docs/examples/team-workflow.js +352 -0
- package/core/.collaboration/hooks/README.md +70 -0
- package/core/.collaboration/hooks/config.json +10 -0
- package/core/.collaboration/hooks/install.js +400 -0
- package/core/.collaboration/hooks/post-merge.js +163 -0
- package/core/.collaboration/hooks/pre-commit.js +264 -0
- package/core/.collaboration/hooks/synapse-hook.js +486 -0
- package/core/.collaboration/hooks/synapse-hook.test.js +69 -0
- package/core/.failure/INDEX.yaml +231 -0
- package/core/.failure/agent-execution/FAIL-001-agent-no-output.yaml +391 -0
- package/core/.failure/agent-execution/FAIL-004_agent_platform_specific_commands.md +194 -0
- package/core/.failure/agent-execution/FAIL-005_background_agent_permission_denied.md +204 -0
- package/core/.failure/agent-execution/FAIL-007-pm-lead-wrong-team-invocation.yaml +0 -0
- package/core/.failure/agent-execution/FAIL-008-bypass-api-direct-yaml-write.yaml +94 -0
- package/core/.failure/agent-execution/FAIL-010-phase0-poem-format-skipped.yaml +28 -0
- package/core/.failure/agent-execution/FAIL-010-skipping-cognitive-checkpoint-after-verification.yaml +59 -0
- package/core/.failure/agent-execution/FAIL-012-grep-shortcut-during-investigation.yaml +85 -0
- package/core/.failure/agent-execution/FAIL-013-search-cwd-drift-and-case-mismatch.yaml +103 -0
- package/core/.failure/agent-execution/FAIL-014-shared-worktree-premature-death-verdict.yaml +35 -0
- package/core/.failure/agent-execution/FAIL-AUTO-TASK_1413.yaml +31 -0
- package/core/.failure/agent-execution/FAIL-AUTO-TASK_1427.yaml +41 -0
- package/core/.failure/agent-execution/FAIL-AUTO-TASK_904.yaml +30 -0
- package/core/.failure/agent-execution/README.md +68 -0
- package/core/.failure/architecture/FAIL-004_session_based_skill_recognition.md +128 -0
- package/core/.failure/architecture/FAIL-006-python-version-compatibility.yaml +445 -0
- package/core/.failure/architecture/README.md +87 -0
- package/core/.failure/code-quality/README.md +89 -0
- package/core/.failure/data-integrity/FAIL-002-json-bom.yaml +220 -0
- package/core/.failure/data-integrity/README.md +141 -0
- package/core/.failure/pipeline/FAIL-003-queue-pollution.yaml +335 -0
- package/core/.failure/pipeline/README.md +95 -0
- package/core/.failure/retired/FAIL-009-skipping-synapse-pulse-before-code-change.yaml +49 -0
- package/core/.failure/tools/README.md +230 -0
- package/core/.failure/tools/USAGE_GUIDE.md +323 -0
- package/core/.failure/tools/check_bom.js +101 -0
- package/core/.failure/tools/check_failures.ps1 +387 -0
- package/core/.failure/tools/fix_json.js +58 -0
- package/core/.failure/tools/log_failure.ps1 +474 -0
- package/core/.failure/tools/remove_bom.js +46 -0
- package/core/.failure/tools/validate_json.js +50 -0
- package/core/.formation/.episode-input.json +10 -0
- package/core/.formation/README.md +188 -0
- package/core/.formation/bifrost/CGDD_hook_lifecycle.js +575 -0
- package/core/.formation/bifrost/HOOK_PARITY_VERIFICATION.md +241 -0
- package/core/.formation/bifrost/README.md +71 -0
- package/core/.formation/bifrost/codex-doctor.js +106 -0
- package/core/.formation/bifrost/codex-doctor.test.js +51 -0
- package/core/.formation/bifrost/launch.js +510 -0
- package/core/.formation/bifrost/launch.test.js +217 -0
- package/core/.formation/bifrost/openai/codex-hook-shim.js +171 -0
- package/core/.formation/bifrost/openai/codex-hook-shim.test.js +107 -0
- package/core/.formation/bifrost/openai/models.json +36 -0
- package/core/.formation/bifrost/openai/relay.js +781 -0
- package/core/.formation/bifrost/openai/relay.test.js +71 -0
- package/core/.formation/bifrost/session.js +382 -0
- package/core/.formation/bifrost/session.test.js +121 -0
- package/core/.formation/bifrost/setup-codex.js +685 -0
- package/core/.formation/bifrost/setup-codex.test.js +102 -0
- package/core/.formation/bifrost/shared/ansuz-boot-policy.js +31 -0
- package/core/.formation/bifrost/shared/ansuz-boot-policy.test.js +40 -0
- package/core/.formation/bifrost/shared/boot-context.js +68 -0
- package/core/.formation/bifrost/shared/boot-context.test.js +67 -0
- package/core/.formation/bifrost/shared/codex-appserver.js +191 -0
- package/core/.formation/bifrost/shared/codex-injection.js +126 -0
- package/core/.formation/bifrost/shared/codex-session-registry.js +105 -0
- package/core/.formation/bifrost/shared/codex-session-registry.test.js +126 -0
- package/core/.formation/bifrost/shared/consolidate.js +286 -0
- package/core/.formation/bifrost/shared/stream-json.js +103 -0
- package/core/.formation/bifrost/shared/tools.js +278 -0
- package/core/.formation/bifrost/sync.js +142 -0
- package/core/.formation/briefs/scheduler-evolution.md +209 -0
- package/core/.formation/lead.yaml +118 -0
- package/core/.formation/legacy.bak/designer.yaml +57 -0
- package/core/.formation/legacy.bak/pm.yaml +57 -0
- package/core/.formation/legacy.bak/qa.yaml +57 -0
- package/core/.formation/legacy.bak/review.yaml +62 -0
- package/core/.formation/legacy.bak/scheduler.yaml +129 -0
- package/core/.formation/legacy.bak/sre.yaml +57 -0
- package/core/.formation/legion/forge.yaml +299 -0
- package/core/.formation/legion/hive.yaml +238 -0
- package/core/.formation/native/claude/README.md +61 -0
- package/core/.formation/native/claude/models.json +42 -0
- package/core/.formation/role-map.yaml +274 -0
- package/core/.formation/roles/_shared/modules/code_review.yaml +98 -0
- package/core/.formation/roles/_shared/modules/security.yaml +103 -0
- package/core/.formation/roles/_shared/modules/testing.yaml +14 -0
- package/core/.formation/roles/backend/role.yaml +93 -0
- package/core/.formation/roles/code_reviewer/role.yaml +102 -0
- package/core/.formation/roles/database_optimizer/role.yaml +107 -0
- package/core/.formation/roles/designer/role.yaml +66 -0
- package/core/.formation/roles/developer/role.yaml +75 -0
- package/core/.formation/roles/frontend/role.yaml +134 -0
- package/core/.formation/roles/incident_response/role.yaml +89 -0
- package/core/.formation/roles/qa/role.yaml +89 -0
- package/core/.formation/roles/security/role.yaml +87 -0
- package/core/.formation/roles/sre/role.yaml +66 -0
- package/core/.formation/skills/coordinator.yaml +52 -0
- package/core/.formation/solo/diagnosis.yaml +78 -0
- package/core/.formation/solo/strategy.yaml +121 -0
- package/core/.formation/spec/task_operations.parity.test.js +426 -0
- package/core/.formation/spec/task_operations.yaml +291 -0
- package/core/.formation/squad/blitz.yaml +192 -0
- package/core/.formation/squad/strategy-tribunal.yaml +354 -0
- package/core/.formation/squad/strategy.yaml +349 -0
- package/core/.formation/squad/sweep.yaml +208 -0
- package/core/.formation/tests/hello.txt +2 -0
- package/core/.formation/tools/__tests__/m1-claim-gate.test.js +175 -0
- package/core/.formation/tools/__tests__/m1-hmap-convid.test.js +216 -0
- package/core/.formation/tools/__tests__/release-lock.test.js +176 -0
- package/core/.formation/tools/__tests__/subagent-bifrost-guard.test.js +234 -0
- package/core/.formation/tools/__tests__/subagent-codex-harness.test.js +96 -0
- package/core/.formation/tools/__tests__/task-1863-claim-late-release.test.js +160 -0
- package/core/.formation/tools/__tests__/task-2265-singleton-identity.test.js +134 -0
- package/core/.formation/tools/__tests__/task-2281-singleton-readers.test.js +64 -0
- package/core/.formation/tools/__tests__/task2030-worktree-node-modules.test.js +221 -0
- package/core/.formation/tools/__tests__/task2067-worktree-branch-reuse.test.js +148 -0
- package/core/.formation/tools/alaya-gate.js +198 -0
- package/core/.formation/tools/analytics.js +172 -0
- package/core/.formation/tools/broadcast.js +103 -0
- package/core/.formation/tools/commit-sync.js +154 -0
- package/core/.formation/tools/coordinator.js +350 -0
- package/core/.formation/tools/dashboard-models-chain.test.js +60 -0
- package/core/.formation/tools/dispatch-cortex-context.test.js +52 -0
- package/core/.formation/tools/dispatch-detail/cross-project-worktree.md +40 -0
- package/core/.formation/tools/dispatch-detail/testing-module.md +53 -0
- package/core/.formation/tools/dispatch-detail/worktree-subagent-mode.md +72 -0
- package/core/.formation/tools/dispatch-dryrun.test.js +54 -0
- package/core/.formation/tools/dispatch-model-policy.test.js +165 -0
- package/core/.formation/tools/dispatch-notifier.js +84 -0
- package/core/.formation/tools/dispatch-registry.js +346 -0
- package/core/.formation/tools/dispatch.js +1931 -0
- package/core/.formation/tools/formations.js +1203 -0
- package/core/.formation/tools/forseti-verify.js +1170 -0
- package/core/.formation/tools/git-salvage.js +269 -0
- package/core/.formation/tools/guard-attribution.js +224 -0
- package/core/.formation/tools/headless-branch-recovery.test.js +64 -0
- package/core/.formation/tools/headless-dryrun.test.js +79 -0
- package/core/.formation/tools/headless-v2.js +659 -0
- package/core/.formation/tools/headless.js +1071 -0
- package/core/.formation/tools/integration.js +528 -0
- package/core/.formation/tools/jev-correction.js +214 -0
- package/core/.formation/tools/jev-correction.test.js +178 -0
- package/core/.formation/tools/legacy-scheduler.js +1994 -0
- package/core/.formation/tools/lib/exec-tree.js +92 -0
- package/core/.formation/tools/lib/exec-tree.test.js +82 -0
- package/core/.formation/tools/loader.js +190 -0
- package/core/.formation/tools/log-reader.js +232 -0
- package/core/.formation/tools/logger.js +273 -0
- package/core/.formation/tools/mcp-allowlist.test.js +40 -0
- package/core/.formation/tools/memory-loader.js +422 -0
- package/core/.formation/tools/merge-lock-heartbeat.test.js +35 -0
- package/core/.formation/tools/no-hooks.settings.json +3 -0
- package/core/.formation/tools/pool-status-push.js +121 -0
- package/core/.formation/tools/pool-status-push.test.js +165 -0
- package/core/.formation/tools/post-complete/bounded-http.js +102 -0
- package/core/.formation/tools/post-complete/bounded-http.test.js +130 -0
- package/core/.formation/tools/post-complete/cognitive.js +270 -0
- package/core/.formation/tools/post-complete/git-merge.js +2845 -0
- package/core/.formation/tools/post-complete/health.js +464 -0
- package/core/.formation/tools/post-complete/integration-gaps.js +98 -0
- package/core/.formation/tools/post-complete/outcome.js +874 -0
- package/core/.formation/tools/post-complete/staging.js +390 -0
- package/core/.formation/tools/post-complete/subagent-transcript-stats.js +460 -0
- package/core/.formation/tools/post-complete/subagent-transcript-stats.test.js +680 -0
- package/core/.formation/tools/post-complete/task1536.test.js +627 -0
- package/core/.formation/tools/post-complete/task1543.test.js +261 -0
- package/core/.formation/tools/post-complete/task1876.test.js +287 -0
- package/core/.formation/tools/post-complete/task1957.test.js +293 -0
- package/core/.formation/tools/post-complete/task1997.test.js +401 -0
- package/core/.formation/tools/post-complete/task2028.test.js +232 -0
- package/core/.formation/tools/post-complete/task2029.test.js +275 -0
- package/core/.formation/tools/post-complete/task2036.test.js +330 -0
- package/core/.formation/tools/post-complete/task2038.test.js +246 -0
- package/core/.formation/tools/post-complete/task2071.test.js +231 -0
- package/core/.formation/tools/post-complete/task2233.test.js +100 -0
- package/core/.formation/tools/post-complete/task2240.test.js +134 -0
- package/core/.formation/tools/post-complete/task2244.test.js +199 -0
- package/core/.formation/tools/post-complete/task2255.test.js +28 -0
- package/core/.formation/tools/post-complete/task2268.test.js +106 -0
- package/core/.formation/tools/post-complete/task2341.test.js +74 -0
- package/core/.formation/tools/post-complete/task2345.test.js +38 -0
- package/core/.formation/tools/post-complete/testing.js +482 -0
- package/core/.formation/tools/post-complete/wish.js +177 -0
- package/core/.formation/tools/post-complete/worktree-rescue.test.js +283 -0
- package/core/.formation/tools/post-complete.js +3660 -0
- package/core/.formation/tools/post-complete.test.js +1002 -0
- package/core/.formation/tools/pre-dispatch-snapshot.test.js +328 -0
- package/core/.formation/tools/process-state.js +33 -0
- package/core/.formation/tools/prompt.js +2183 -0
- package/core/.formation/tools/prompt.test.js +875 -0
- package/core/.formation/tools/remote-conflict.js +98 -0
- package/core/.formation/tools/revert-daemon-state.js +162 -0
- package/core/.formation/tools/route-audit.test.js +55 -0
- package/core/.formation/tools/runner.js +1332 -0
- package/core/.formation/tools/supabase-client.js +104 -0
- package/core/.formation/tools/task-sync.js +236 -0
- package/core/.formation/tools/task-utils.js +344 -0
- package/core/.formation/tools/task2028-headless-worktree.test.js +112 -0
- package/core/.formation/tools/test-drift.js +148 -0
- package/core/.formation/tools/tests/headless-mcp-args-plumbing.test.js +123 -0
- package/core/.formation/tools/tests/relay-mcp-overrides.test.js +112 -0
- package/core/.formation/tools/transcript-recorder.js +574 -0
- package/core/.formation/tools/utils-claude-cmd.test.js +28 -0
- package/core/.formation/tools/utils-worktree-config.test.js +44 -0
- package/core/.formation/tools/utils.js +1020 -0
- package/core/.formation/tools/verify-acceptance.js +585 -0
- package/core/.formation/tools/worktree-leak.test.js +162 -0
- package/core/.formation/tools/worktree-reclaim.js +259 -0
- package/core/.formation/tools/worktree-reclaim.test.js +182 -0
- package/core/.formation/tools/yggdrasil-local.js +97 -0
- package/core/.formation/unit/do.yaml +78 -0
- package/core/.formation/unit/heimdall.yaml +96 -0
- package/core/.formation/unit/plan.yaml +67 -0
- package/core/.formation/unit/think.yaml +58 -0
- package/core/.kenaz/MUNINN_SNAPSHOT9_EPISODE.json +32 -0
- package/core/.kenaz/MUNINN_SNAPSHOT9_RUNE.json +23 -0
- package/core/.kenaz/MUNINN_SNAPSHOT9_SUMMARY.md +89 -0
- package/core/.kenaz/ash_TASK_1428-20260507.json +14 -0
- package/core/.kenaz/cache/native-models/claude.json +42 -0
- package/core/.kenaz/claude-hooks-manifest.json +119 -0
- package/core/.kenaz/cortex.yaml +100 -0
- package/core/.kenaz/curator_state.json +7 -0
- package/core/.kenaz/dashboard-quick-prompts.json +9 -0
- package/core/.kenaz/designs/METAPLASTICITY_CONFIDENCE_DESIGN.md +537 -0
- package/core/.kenaz/designs/REFLEX_INITIATOR_DESIGN.md +501 -0
- package/core/.kenaz/designs/TASK_1385_handoff_mcp_design.md +426 -0
- package/core/.kenaz/designs/TASK_932_hippocampus_consolidation.md +103 -0
- package/core/.kenaz/designs/TASK_934_efe_signal_engine.md +97 -0
- package/core/.kenaz/designs/TASK_935_self_evolution_framework.md +154 -0
- package/core/.kenaz/designs/VISION_cognitive_architecture_roadmap.md +159 -0
- package/core/.kenaz/designs/metaplasticity_simulation_results.json +696 -0
- package/core/.kenaz/docs/INDEX.md +214 -0
- package/core/.kenaz/docs/README.md +290 -0
- package/core/.kenaz/docs/registry.json +962 -0
- package/core/.kenaz/docs/schema.json +144 -0
- package/core/.kenaz/docs/tools/GIT_HOOK_GUIDE.md +203 -0
- package/core/.kenaz/docs/tools/RAG_INTEGRATION_GUIDE.md +306 -0
- package/core/.kenaz/docs/tools/README.md +99 -0
- package/core/.kenaz/docs/tools/TIME_ESTIMATION_GUIDE.md +299 -0
- package/core/.kenaz/docs/tools/package-lock.json +618 -0
- package/core/.kenaz/docs/tools/package.json +34 -0
- package/core/.kenaz/docs/tools/src/cli.ts +365 -0
- package/core/.kenaz/docs/tools/src/field-extractor.ts +152 -0
- package/core/.kenaz/docs/tools/src/index.ts +14 -0
- package/core/.kenaz/docs/tools/src/registry.ts +664 -0
- package/core/.kenaz/docs/tools/src/search.ts +195 -0
- package/core/.kenaz/docs/tools/src/types.ts +88 -0
- package/core/.kenaz/docs/tools/test-git-hook.sh +79 -0
- package/core/.kenaz/docs/tools/tsconfig.json +20 -0
- package/core/.kenaz/docs/tools/verify.sh +106 -0
- package/core/.kenaz/episodes/SESSION_ansuz-prompt-1785087304784.yaml +68 -0
- package/core/.kenaz/huginn-exploration.json +8 -0
- package/core/.kenaz/knowledge/ladybug_2c51da1e_shadow_file_frame_group.patch +163 -0
- package/core/.kenaz/knowledge/ladybug_30cf85690e_shadow_page_read_during_checkpoint.patch +393 -0
- package/core/.kenaz/knowledge/ladybug_7a17858d3a_node_group_delete_lock.patch +102 -0
- package/core/.kenaz/knowledge/ladybug_926a0ba1_column_checkpoint.patch +412 -0
- package/core/.kenaz/knowledge/ladybug_a346c4c4b6_pk_index_header_pages.patch +144 -0
- package/core/.kenaz/knowledge/ladybug_ba5f38815b_csr_node_group.patch +86 -0
- package/core/.kenaz/main-memory/README.md +230 -0
- package/core/.kenaz/main-memory/kenaz/cortex/001_cortex_overview.md +168 -0
- package/core/.kenaz/main-memory/kenaz/cortex/001_rag_engine_overview.md +30 -0
- package/core/.kenaz/main-memory/kenaz/memory-system/001_three_tier_architecture.md +361 -0
- package/core/.kenaz/main-memory/kenaz/pipeline/001_task_execution_flow.md +117 -0
- package/core/.kenaz/main-memory/kenaz/pipeline/001_task_granularity.md +154 -0
- package/core/.kenaz/main-memory/kenaz/pipeline/002_team_priority.md +51 -0
- package/core/.kenaz/main-memory/kenaz/pipeline/003_feature_id_system.md +46 -0
- package/core/.kenaz/main-memory/kenaz/rules/001_gen_007_self_containment.md +108 -0
- package/core/.kenaz/main-memory/kenaz/rules/001_rule_priority_system.md +121 -0
- package/core/.kenaz/main-memory/kenaz/rules/002_agt_006_pre_check.md +0 -0
- package/core/.kenaz/main-memory/kenaz/rules/003_ppl_002_task_archival.md +48 -0
- package/core/.kenaz/main-memory/kenaz/system/001_dual_track_task_system.md +197 -0
- package/core/.kenaz/main-memory/knowledge/patterns/001_json_bom_issue.md +78 -0
- package/core/.kenaz/main-memory/knowledge/patterns/001_leader_worker_pattern.md +0 -0
- package/core/.kenaz/main-memory/knowledge/patterns/002_scope_path_conflict.md +115 -0
- package/core/.kenaz/main-memory/knowledge/patterns/002_task_dependency_resolution.md +223 -0
- package/core/.kenaz/main-memory/knowledge/patterns/003_question_protocol.md +242 -0
- package/core/.kenaz/main-memory/knowledge/patterns/004_user_insight_value.md +111 -0
- package/core/.kenaz/main-memory/knowledge/patterns/005_file_lock_pattern.md +274 -0
- package/core/.kenaz/main-memory/knowledge/references/001_ppl_rules.md +28 -0
- package/core/.kenaz/main-memory/knowledge/solutions/001_json_bom_issue.md +137 -0
- package/core/.kenaz/main-memory/knowledge/solutions/001_team_invocation.md +0 -0
- package/core/.kenaz/main-memory/knowledge/solutions/002_passive_monitoring.md +0 -0
- package/core/.kenaz/main-memory/knowledge/solutions/003_windows_file_race_condition.md +239 -0
- package/core/.kenaz/main-memory/registry.json +326 -0
- package/core/.kenaz/main-memory/version.yaml +58 -0
- package/core/.kenaz/muninn_episode_write.ps1 +17 -0
- package/core/.kenaz/muninn_snapshot11_rune_candidates.md +63 -0
- package/core/.kenaz/muninn_snapshot1_rune_candidates.md +49 -0
- package/core/.kenaz/orphan_audit_2026-05.md +181 -0
- package/core/.kenaz/ownership.yaml +155 -0
- package/core/.kenaz/peer.yaml +72 -0
- package/core/.kenaz/project.yaml +62 -0
- package/core/.kenaz/rune_ansuz_literature_validation_strategy.md +40 -0
- package/core/.kenaz/rune_efe_active_inference_validation.md +36 -0
- package/core/.kenaz/rune_yggdrasil_filesystem_scoped_project.md +41 -0
- package/core/.kenaz/rune_yggdrasil_project_identity_folder_name.md +41 -0
- package/core/.kenaz/rune_yggdrasil_relay_protocol_project_mismatch.md +39 -0
- package/core/.kenaz/runes_TASK_1428.json +57 -0
- package/core/.kenaz/specialist/ansuz_motivational_state.schema.json +138 -0
- package/core/.kenaz/specialist/ansuz_rules.yaml +241 -0
- package/core/.kenaz/specialist/ansuz_session_handoff.schema.json +128 -0
- package/core/.kenaz/specialist/chart_TASK_1657.json +50 -0
- package/core/.kenaz/specialist/cognitive-hub-e2e.test.js +494 -0
- package/core/.kenaz/specialist/daemon-manifest.yaml +168 -0
- package/core/.kenaz/specialist/empty_ac_audit_report.md +63 -0
- package/core/.kenaz/specialist/episode_muninn_completion_1785056865691.json +91 -0
- package/core/.kenaz/specialist/field_report_watermark.json +1 -0
- package/core/.kenaz/specialist/gc1826_driver.js +118 -0
- package/core/.kenaz/specialist/heimdall_proposal_1017c07f.json +13 -0
- package/core/.kenaz/specialist/heimdall_proposal_3dfaa8b9.json +12 -0
- package/core/.kenaz/specialist/heimdall_proposal_57af18f9.json +15 -0
- package/core/.kenaz/specialist/heimdall_proposal_57b1aa1b.json +14 -0
- package/core/.kenaz/specialist/heimdall_proposal_5a3c9473.json +13 -0
- package/core/.kenaz/specialist/identity_verdicts/TASK_1073.json +75 -0
- package/core/.kenaz/specialist/identity_verdicts/TASK_TEST.json +77 -0
- package/core/.kenaz/specialist/memory_guard_fired.json +1 -0
- package/core/.kenaz/specialist/memory_guard_trigger_cache.json +1 -0
- package/core/.kenaz/specialist/memory_source_priority.yaml +260 -0
- package/core/.kenaz/specialist/motivational_state.schema.json +62 -0
- package/core/.kenaz/specialist/prompt_1775.txt +317 -0
- package/core/.kenaz/specialist/prompt_1776.txt +326 -0
- package/core/.kenaz/specialist/prompt_1791.txt +320 -0
- package/core/.kenaz/specialist/prompt_1792.txt +320 -0
- package/core/.kenaz/specialist/prompt_1795.txt +281 -0
- package/core/.kenaz/specialist/prompt_1813.txt +332 -0
- package/core/.kenaz/specialist/prompt_1814.txt +401 -0
- package/core/.kenaz/specialist/prompt_1815.txt +394 -0
- package/core/.kenaz/specialist/prompt_1816.txt +437 -0
- package/core/.kenaz/specialist/prompt_1818.txt +361 -0
- package/core/.kenaz/specialist/prompt_1819.txt +421 -0
- package/core/.kenaz/specialist/prompt_1821.txt +345 -0
- package/core/.kenaz/specialist/prompt_1822.txt +313 -0
- package/core/.kenaz/specialist/prompt_1824.txt +348 -0
- package/core/.kenaz/specialist/prompt_1826.txt +388 -0
- package/core/.kenaz/specialist/retired_organs/README.md +58 -0
- package/core/.kenaz/specialist/rune_calibration_poc.md +175 -0
- package/core/.kenaz/specialist/rune_efe_salience_gap.md +21 -0
- package/core/.kenaz/specialist/rune_ember_autonomous_dispatch_gate.md +24 -0
- package/core/.kenaz/specialist/rune_post_dispatch_verification_pattern.md +31 -0
- package/core/.kenaz/specialist/rune_surprise_proxy_improvement.md +28 -0
- package/core/.kenaz/specialist/rune_worktree_dispatch_pattern.md +31 -0
- package/core/.kenaz/specialist/rune_yaml_filter_desync_fix.md +26 -0
- package/core/.kenaz/specialist/rune_yggdrasil_project_identity_folder_name.md +24 -0
- package/core/.kenaz/specialist/sessions/chart_TASK_1599.json +41 -0
- package/core/.kenaz/specialist/sessions/hmap_028aa781-aad2-48c0-9a61-5540565d4a7f.json +5 -0
- package/core/.kenaz/specialist/sessions/hmap_20210387-0c64-400c-9d0a-53042a0cbd89.json +5 -0
- package/core/.kenaz/specialist/sessions/hmap_c1375c5d-fd9f-44bd-a83e-353ecbb0392f.json +5 -0
- package/core/.kenaz/specialist/sessions/scratch_028aa781-aad2-48c0-9a61-5540565d4a7f.json +6 -0
- package/core/.kenaz/specialist/sessions/scratch_0acc0fb3-24f9-453f-9e92-6ef1cdf03a7c.json +6 -0
- package/core/.kenaz/specialist/sessions/scratch_20210387-0c64-400c-9d0a-53042a0cbd89.json +6 -0
- package/core/.kenaz/specialist/sessions/scratch_2f10623e-b7a1-4647-905e-9dc7c4d99f9c.json +6 -0
- package/core/.kenaz/specialist/sessions/scratch_5a38b62d-608a-488c-82f0-7e47e95e0905.json +6 -0
- package/core/.kenaz/specialist/sessions/scratch_5d9758ef-d9b6-4ffe-a017-3ed26d0a313b.json +6 -0
- package/core/.kenaz/specialist/sessions/scratch_c1375c5d-fd9f-44bd-a83e-353ecbb0392f.json +6 -0
- package/core/.kenaz/specialist/sessions/scratch_c9f3c711-b73d-4fcd-ad2a-7b2bc024ee77.json +6 -0
- package/core/.kenaz/specialist/sessions/scratch_e72e5274-1c81-4655-a05a-f87d1ecb2917.json +6 -0
- package/core/.kenaz/specialist/sessions/scratch_f740cdbe-f756-41fc-98fb-2b1413d51901.json +6 -0
- package/core/.kenaz/specialist/t1777_probe.txt +1 -0
- package/core/.kenaz/specialist/task1825_update.json +43 -0
- package/core/.kenaz/specialist/task1827_update.json +43 -0
- package/core/.kenaz/specialist/task1828_update.json +43 -0
- package/core/.kenaz/specialist/taskgen/consolidation_i.json +38 -0
- package/core/.kenaz/specialist/taskgen/csharp_a.json +44 -0
- package/core/.kenaz/specialist/taskgen/csharp_b.json +40 -0
- package/core/.kenaz/specialist/taskgen/embedding_e.json +34 -0
- package/core/.kenaz/specialist/taskgen/hygiene_fg.json +39 -0
- package/core/.kenaz/specialist/taskgen/pathology_h.json +36 -0
- package/core/.kenaz/specialist/taskgen/unity_noise_d.json +38 -0
- package/core/.kenaz/specialist/taskgen/visibility_c.json +38 -0
- package/core/.kenaz/specialist/verify_1837.js +302 -0
- package/core/.kenaz/specialist/verify_1838.js +124 -0
- package/core/.kenaz/tmp/heimdall_proposal_fc7e0944.json +10 -0
- package/core/.kenaz/tmp_heimdall_proposal_8d3e392.json +13 -0
- package/core/.kenaz/tmp_props.json +1 -0
- package/core/.kenaz/tmp_sounddrop_t1_prompt.txt +371 -0
- package/core/.kenaz/user_model.schema.json +107 -0
- package/core/.matrix/README.md +257 -0
- package/core/.matrix/index.matrix +5 -0
- package/core/.mcp.json +8 -0
- package/core/.prefrontal/.gitkeep +0 -0
- package/core/.prefrontal/proposals/.gitkeep +0 -0
- package/core/.rule/INDEX.yaml +99 -0
- package/core/.rule/MECHANIZED.md +61 -0
- package/core/.rule/code/README.md +211 -0
- package/core/.rule/code/backend.yaml +294 -0
- package/core/.rule/code/checklist.yaml +258 -0
- package/core/.rule/code/maintainability.yaml +227 -0
- package/core/.rule/code/naming.yaml +106 -0
- package/core/.rule/code/principles.yaml +71 -0
- package/core/.rule/code/reusability.yaml +192 -0
- package/core/.rule/code/structure.yaml +218 -0
- package/core/.rule/code/style.yaml +197 -0
- package/core/.rule/design/ui.yaml +79 -0
- package/core/.rule/general/agent-workflow.yaml +572 -0
- package/core/.rule/general/cortex-memory-recall.yaml +446 -0
- package/core/.rule/general/cortex-tools.yaml +181 -0
- package/core/.rule/general/cross-platform.yaml +107 -0
- package/core/.rule/general/ddx-synapse-stack.yaml +162 -0
- package/core/.rule/general/file-size-threshold.yaml +45 -0
- package/core/.rule/general/identity-contract.schema.yaml +251 -0
- package/core/.rule/general/memory-language.yaml +67 -0
- package/core/.rule/general/memory-source-priority.yaml +207 -0
- package/core/.rule/general/pipeline.yaml +246 -0
- package/core/.rule/general/principles.yaml +77 -0
- package/core/.rule/general/project-self-containment.yaml +253 -0
- package/core/.rule/general/rust-verify-target.yaml +80 -0
- package/core/.rule/general/specialist-identity-contract.yaml +153 -0
- package/core/.rule/general/sunny-access-control.yaml +60 -0
- package/core/.rule/general/synapse-code-intelligence.yaml +375 -0
- package/core/.rule/general/synapse-cognitive-fusion.yaml +301 -0
- package/core/.rule/general/system-invariants.yaml +248 -0
- package/core/.rule/general/task-pool-routing.yaml +102 -0
- package/core/.rule/general/worktree-isolation.yaml +79 -0
- package/core/.rule/pipeline/PPL-002-completed-task-archival.yaml +528 -0
- package/core/.rule/pipeline/auto-update.yaml +282 -0
- package/core/.rule/pipeline/task-execution.yaml +368 -0
- package/core/.rule/tools/check-permissions.js +197 -0
- package/core/.specialist/Amelia/README.md +329 -0
- package/core/.specialist/Amelia/capability.yaml +386 -0
- package/core/.specialist/Amelia/knowledge.yaml +217 -0
- package/core/.specialist/Amelia/principles.yaml +10 -0
- package/core/.specialist/Amelia/rule.yaml +79 -0
- package/core/.specialist/Amelia/workflow.yaml +241 -0
- package/core/.specialist/Ansuz/HEURISTIC_BOOT_ROUTING.md +39 -0
- package/core/.specialist/Ansuz/ROUTING.md +35 -0
- package/core/.specialist/Ansuz/RULES.md +79 -0
- package/core/.specialist/Ansuz/SYSTEM_DOC.md +611 -0
- package/core/.specialist/Ansuz/VERIFY.md +38 -0
- package/core/.specialist/Ansuz/capability.yaml +338 -0
- package/core/.specialist/Ansuz/cognitive_principles.yaml +62 -0
- package/core/.specialist/Ansuz/concepts/agent_types.yaml +22 -0
- package/core/.specialist/Ansuz/concepts/autonomous_agenda.yaml +170 -0
- package/core/.specialist/Ansuz/concepts/autonomy_contract.yaml +126 -0
- package/core/.specialist/Ansuz/concepts/boot_ritual.yaml +107 -0
- package/core/.specialist/Ansuz/concepts/boot_rules_summary.yaml +16 -0
- package/core/.specialist/Ansuz/concepts/capability_pointers.yaml +21 -0
- package/core/.specialist/Ansuz/concepts/cognitive_fluency_contract.yaml +264 -0
- package/core/.specialist/Ansuz/concepts/cognitive_systems_competence_map.yaml +14 -0
- package/core/.specialist/Ansuz/concepts/cognitive_systems_hippocampus.yaml +14 -0
- package/core/.specialist/Ansuz/concepts/cognitive_systems_overview.yaml +27 -0
- package/core/.specialist/Ansuz/concepts/cognitive_systems_serendipity.yaml +14 -0
- package/core/.specialist/Ansuz/concepts/cognitive_systems_turn_context.yaml +13 -0
- package/core/.specialist/Ansuz/concepts/commitment_layer.yaml +150 -0
- package/core/.specialist/Ansuz/concepts/completion_tracking.yaml +29 -0
- package/core/.specialist/Ansuz/concepts/deep_knowledge_pointers.yaml +28 -0
- package/core/.specialist/Ansuz/concepts/evolvable_guardrails.yaml +20 -0
- package/core/.specialist/Ansuz/concepts/fatigue_handoff.yaml +84 -0
- package/core/.specialist/Ansuz/concepts/formation_quick_ref.yaml +28 -0
- package/core/.specialist/Ansuz/concepts/guardrails_immutable.yaml +31 -0
- package/core/.specialist/Ansuz/concepts/identity.yaml +48 -0
- package/core/.specialist/Ansuz/concepts/interaction_protocol.yaml +42 -0
- package/core/.specialist/Ansuz/concepts/meta_evolvable_tier.yaml +28 -0
- package/core/.specialist/Ansuz/concepts/mindset.yaml +18 -0
- package/core/.specialist/Ansuz/concepts/phase9_verification.yaml +21 -0
- package/core/.specialist/Ansuz/concepts/phase_protocol.yaml +66 -0
- package/core/.specialist/Ansuz/concepts/principles.yaml +65 -0
- package/core/.specialist/Ansuz/concepts/self_evolution_overview.yaml +53 -0
- package/core/.specialist/Ansuz/concepts/task_first_protocol.yaml +7 -0
- package/core/.specialist/Ansuz/concepts/task_pool.yaml +119 -0
- package/core/.specialist/Ansuz/concepts/task_system.yaml +22 -0
- package/core/.specialist/Ansuz/concepts/write_verification.yaml +26 -0
- package/core/.specialist/Ansuz/core.yaml +224 -0
- package/core/.specialist/Ansuz/decisions/ADR-requirement-graph-layer.md +390 -0
- package/core/.specialist/Ansuz/elixir.yaml +70 -0
- package/core/.specialist/Ansuz/exo_cortex_tools.yaml +13 -0
- package/core/.specialist/Ansuz/experiments/boot_ablation_replay.js +197 -0
- package/core/.specialist/Ansuz/guards/blind_spot_guards.yaml +28 -0
- package/core/.specialist/Ansuz/guards/lesson_guards.yaml +203 -0
- package/core/.specialist/Ansuz/identity_contract.yaml +375 -0
- package/core/.specialist/Ansuz/knowledge.yaml +284 -0
- package/core/.specialist/Ansuz/modules/amelia_review.yaml +112 -0
- package/core/.specialist/Ansuz/modules/ddx.yaml +47 -0
- package/core/.specialist/Ansuz/modules/design_checks.yaml +47 -0
- package/core/.specialist/Ansuz/modules/identity_verification.yaml +119 -0
- package/core/.specialist/Ansuz/modules/loop_guard.yaml +36 -0
- package/core/.specialist/Ansuz/modules/prevention.yaml +84 -0
- package/core/.specialist/Ansuz/modules/prophecy.yaml +95 -0
- package/core/.specialist/Ansuz/modules/pulse_empty.yaml +36 -0
- package/core/.specialist/Ansuz/modules/qa_intake.yaml +29 -0
- package/core/.specialist/Ansuz/modules/recall.yaml +45 -0
- package/core/.specialist/Ansuz/principles.yaml +31 -0
- package/core/.specialist/Ansuz/research/EMBER_architecture_comparison.md +142 -0
- package/core/.specialist/Ansuz/rule.yaml +97 -0
- package/core/.specialist/Ansuz/self_model_seed.backup.json +100 -0
- package/core/.specialist/Ansuz/self_model_seed.json +100 -0
- package/core/.specialist/Ansuz/self_model_seed.sha256 +1 -0
- package/core/.specialist/Ansuz/tools/ansuz-handoff-snapshot.js +626 -0
- package/core/.specialist/Ansuz/tools/ansuz-handoff.js +437 -0
- package/core/.specialist/Ansuz/tools/ansuz-sdk-runner.js +1254 -0
- package/core/.specialist/Ansuz/tools/ansuz-sdk-runner.test.js +137 -0
- package/core/.specialist/Ansuz/tools/ansuz-state.js +288 -0
- package/core/.specialist/Ansuz/tools/bootstrap-anchors.js +289 -0
- package/core/.specialist/Ansuz/tools/handoff-freshness-milestone.test.js +73 -0
- package/core/.specialist/Ansuz/tools/handoff-resolver.js +207 -0
- package/core/.specialist/Ansuz/tools/handoff-session-identity.test.js +333 -0
- package/core/.specialist/Ansuz/tools/handoff-snapshot-args.test.js +25 -0
- package/core/.specialist/Ansuz/tools/install-claude-hooks.js +354 -0
- package/core/.specialist/Ansuz/tools/install-claude-hooks.test.js +110 -0
- package/core/.specialist/Ansuz/tools/package.json +16 -0
- package/core/.specialist/Ansuz/tools/preservation-coordinator.js +504 -0
- package/core/.specialist/Ansuz/tools/verify-and-land.js +1012 -0
- package/core/.specialist/Ansuz/tools/verify-and-land.test.js +1099 -0
- package/core/.specialist/Ansuz/workflow.yaml +1273 -0
- package/core/.specialist/Forseti/capability.yaml +210 -0
- package/core/.specialist/Forseti/core.yaml +176 -0
- package/core/.specialist/Forseti/principles.yaml +88 -0
- package/core/.specialist/Forseti/rule.yaml +86 -0
- package/core/.specialist/Heimdall/SKILL.md +65 -0
- package/core/.specialist/Heimdall/capability.yaml +134 -0
- package/core/.specialist/Heimdall/core.yaml +275 -0
- package/core/.specialist/Heimdall/principles.yaml +66 -0
- package/core/.specialist/Heimdall/rule.yaml +68 -0
- package/core/.specialist/Huginn/capability.yaml +234 -0
- package/core/.specialist/Huginn/core.yaml +482 -0
- package/core/.specialist/Huginn/principles.yaml +57 -0
- package/core/.specialist/Huginn/rule.yaml +121 -0
- package/core/.specialist/REFLECTION_TO_CONTROL.md +347 -0
- package/core/.specialist/ansuz_session_handoff.json +96 -0
- package/core/.specialist/experiments/rg_benchmark.js +523 -0
- package/core/.specialist/experiments/rg_benchmark_results.json +27 -0
- package/core/.specialist/shared/cognitive-primer.md +15 -0
- package/core/.specialist/shared/guard_schema.json +290 -0
- package/core/.specialist/shared/principles.yaml +213 -0
- package/core/.specialist/tests/runtime-discovery/README.md +224 -0
- package/core/.specialist/tests/runtime-discovery/active-project-polling.test.js +495 -0
- package/core/.specialist/tests/runtime-discovery/port-binding.test.js +418 -0
- package/core/.specialist/tests/runtime-discovery/resolver-priority.test.js +693 -0
- package/core/.specialist/tests/runtime-discovery/resolver-skip-on-invalid.test.js +467 -0
- package/core/.specialist/tests/runtime-discovery/resolver-symmetry.test.js +679 -0
- package/core/.specialist/tests/runtime-discovery/tail-cli-project-path.test.js +231 -0
- package/core/.specialist/tools/MEMORY_RECALL_TRIGGERS.md +156 -0
- package/core/.specialist/tools/README.md +129 -0
- package/core/.specialist/tools/__tests__/freya-cli-contract.test.js +156 -0
- package/core/.specialist/tools/__tests__/task-1863-boot-lease-reuse.test.js +99 -0
- package/core/.specialist/tools/__tests__/task-1917-orphan-detection.test.js +175 -0
- package/core/.specialist/tools/__tests__/task-1977-banner-cap.test.js +129 -0
- package/core/.specialist/tools/__tests__/task-1983-lease-project-path.test.js +96 -0
- package/core/.specialist/tools/__tests__/task-2218-boot-session-id.test.js +118 -0
- package/core/.specialist/tools/__tests__/task-2222-session-identity-interleave.test.js +203 -0
- package/core/.specialist/tools/__tests__/task-2246-reap-honesty.test.js +96 -0
- package/core/.specialist/tools/__tests__/task-2254-handoff-archive-contract.test.js +60 -0
- package/core/.specialist/tools/__tests__/task-2272-open-card-status-quote.test.js +26 -0
- package/core/.specialist/tools/__tests__/task-2374-usage-counter.test.js +34 -0
- package/core/.specialist/tools/ansuz-boot-fast.js +1120 -0
- package/core/.specialist/tools/ansuz-boot-fast.test.js +705 -0
- package/core/.specialist/tools/canary.js +501 -0
- package/core/.specialist/tools/context-injection.js +395 -0
- package/core/.specialist/tools/design-reasoning.js +493 -0
- package/core/.specialist/tools/discovery-fixtures.js +308 -0
- package/core/.specialist/tools/discovery-runner.js +460 -0
- package/core/.specialist/tools/failure-detector.js +1132 -0
- package/core/.specialist/tools/identity-scorer.js +714 -0
- package/core/.specialist/tools/jev-optional-context.js +107 -0
- package/core/.specialist/tools/jev-optional-context.test.js +152 -0
- package/core/.specialist/tools/lesson-guard.js +1084 -0
- package/core/.specialist/tools/lib/chart-path.js +159 -0
- package/core/.specialist/tools/lib/chart-path.test.js +171 -0
- package/core/.specialist/tools/lib/project-resolver.js +200 -0
- package/core/.specialist/tools/lib/project-resolver.test.js +241 -0
- package/core/.specialist/tools/memory-action-log.js +839 -0
- package/core/.specialist/tools/phase-gate.js +3754 -0
- package/core/.specialist/tools/phase-gate.test.js +85 -0
- package/core/.specialist/tools/phase9-policy.test.js +109 -0
- package/core/.specialist/tools/precompute-runner.js +444 -0
- package/core/.specialist/tools/prompt-files.test.js +169 -0
- package/core/.specialist/tools/replay-detectors.js +290 -0
- package/core/.specialist/tools/rule-engine.js +621 -0
- package/core/.specialist/tools/session-boot-ownership.test.js +117 -0
- package/core/.specialist/tools/session-project-state.test.js +65 -0
- package/core/.specialist/tools/session.js +1866 -0
- package/core/.specialist/tools/stream-lease.js +263 -0
- package/core/.specialist/tools/task-bridge-jev.test.js +170 -0
- package/core/.specialist/tools/task-bridge.js +765 -0
- package/core/.specialist/tools/verify-identity.js +453 -0
- package/core/.specialist/tools/wish-mandate-delivery.test.js +76 -0
- package/core/.system/README.md +555 -0
- package/core/.system/agent-skills/README.md +724 -0
- package/core/.system/archive/README.md +499 -0
- package/core/.system/assessment/README.md +645 -0
- package/core/.system/cli-tools/README.md +724 -0
- package/core/.system/collaboration/KNOWLEDGE.md +65 -0
- package/core/.system/collaboration/README.md +570 -0
- package/core/.system/cortex/MODULES.md +1046 -0
- package/core/.system/dashboard/FRONTEND.md +812 -0
- package/core/.system/dashboard/README.md +737 -0
- package/core/.system/external-skills/README.md +522 -0
- package/core/.system/failure/README.md +723 -0
- package/core/.system/formation/LEGACY_SKILLS.md +972 -0
- package/core/.system/formation/POST_COMPLETE.md +600 -0
- package/core/.system/formation/README.md +1092 -0
- package/core/.system/formation/TOOLS_REFERENCE.md +1145 -0
- package/core/.system/githooks/README.md +846 -0
- package/core/.system/kenaz/README.md +787 -0
- package/core/.system/memory/README.md +716 -0
- package/core/.system/pipeline/README.md +712 -0
- package/core/.system/rule/README.md +794 -0
- package/core/.system/specialist/README.md +669 -0
- package/core/.system/specialist/STRUCTURE.md +262 -0
- package/core/.system/sunny/README.md +476 -0
- package/core/.system/sunny/RULES.json +89 -0
- package/core/.system/sunny/knowledge/INDEX.md +37 -0
- package/core/.system/sunny/knowledge/agent-teams-api.md +0 -0
- package/core/.system/sunny/knowledge/ansuz-specialist.md +500 -0
- package/core/.system/sunny/knowledge/claude-cli-spawn.md +177 -0
- package/core/.system/sunny/knowledge/collaboration-api.md +925 -0
- package/core/.system/sunny/teammates/README.md +107 -0
- package/core/.system/sunny/teammates/how_to_use.yaml +101 -0
- package/core/.system/sunny/teammates/tools/headless/launcher.js +318 -0
- package/core/.system/sunny/teammates/tools/powershell/launcher.js +241 -0
- package/core/.system/sunny/teammates/tools/powershell/start.bat +50 -0
- package/core/.system/sunny/teammates/tools/utils/env.js +96 -0
- package/core/.system/sunny/teammates/tools/utils/format-output.js +329 -0
- package/core/.system/sunny/tools.json +101 -0
- package/core/.vendor/js-yaml.cjs +2795 -0
- package/core/.vendor/require-yaml.cjs +8 -0
- package/core/CLAUDE.md +172 -0
- package/core/KENAZ_CORE_VERSION +1 -0
- package/core/dev/ALAYA_FIELD_FEEDBACK_DESIGN.md +126 -0
- package/core/dev/ANSUZ_SCAFFOLD_DIET_2026-09-20.md +231 -0
- package/core/dev/ANSUZ_STARTUP_INJECTION_REVIEW.md +355 -0
- package/core/dev/ANSUZ_WORKFLOW_MODERNIZATION.md +143 -0
- package/core/dev/CORTEX_META_GRAPH_ASSESSMENT.md +99 -0
- package/core/dev/FREYA_DOWNSTREAM_BUGS_2026-09-19.md +44 -0
- package/core/dev/GLOBAL_MEMORY_IDENTITY_CONSOLIDATION.md +263 -0
- package/core/dev/GUARD_EFFECTIVENESS_DESIGN.md +180 -0
- package/core/dev/HEALTH_GATE_VARIANCE_ASSESSMENT.md +271 -0
- package/core/dev/HOOK_DIET_2026-09-21.md +126 -0
- package/core/dev/JEV_INTEGRATION_PLAN.md +189 -0
- package/core/dev/KENAZ_AGENT_CONNECT_v1_SPEC.md +139 -0
- package/core/dev/MOBILE_DESIGN_SPEC.md +569 -0
- package/core/dev/MULTI_ANSUZ_SPEC.md +136 -0
- package/core/dev/MUNINN_RETIREMENT.md +115 -0
- package/core/dev/PHASE3_ATTRIBUTION_POPULATION_DIAGNOSIS.md +211 -0
- package/core/dev/PHASE3_P3-2B_TASKLEVEL_PROBE.md +83 -0
- package/core/dev/PHASE3_P3-2_POPULATION_DISJOINTNESS.md +83 -0
- package/core/dev/PHASE3_P3-2_REMEASURE_REPORT.md +231 -0
- package/core/dev/PREDICTION_GROUNDING_DESIGN.md +376 -0
- package/core/dev/PRODUCT_SPEC.md +317 -0
- package/core/dev/PRODUCT_SPEC_FOR_AI_tepmlate.md +716 -0
- package/core/dev/PROJECT_REGISTRY_DUPLICATE_ASSESSMENT.md +86 -0
- package/core/dev/STARTUP_TIMELINE_TASK_1995.md +181 -0
- package/core/dev/SYNAPSE_WORKER_PER_PROJECT.md +881 -0
- package/core/dev/TASK_1680_P3-3_DISPATCH_SPEC.md +96 -0
- package/core/dev/TASK_1684_CALIBRATION_IMPACT_ANALYSIS.md +170 -0
- package/core/dev/TASK_1684_FORK_A_GOODHART_DESIGN.md +171 -0
- package/core/dev/TASK_1684_P3_2_REMEASURE_VALIDATION.md +262 -0
- package/core/dev/TASK_1903_SIGNAL_AUC_MEASUREMENT.md +207 -0
- package/core/dev/TASK_1904_BRANCH_INTEGRITY_AUDIT.md +146 -0
- package/core/dev/ansuz-eval/README.md +38 -0
- package/core/dev/ansuz-eval/build-fixtures.js +87 -0
- package/core/dev/ansuz-eval/grade.js +96 -0
- package/core/dev/ansuz-eval/grader.test.js +117 -0
- package/core/dev/ansuz-eval/tasks.md +32 -0
- package/core/dev/archive/ansuz/BOOT_FULL.md +141 -0
- package/core/dev/archive/ansuz/agents/ansuz-boot.md +176 -0
- package/core/dev/archive/ansuz/designs/alaya-passive-surfacing.md +84 -0
- package/core/dev/archive/ansuz/designs/cc_memory_indexing.md +307 -0
- package/core/dev/archive/ansuz/designs/check_guard.md +322 -0
- package/core/dev/archive/ansuz/designs/consequence_loop.md +227 -0
- package/core/dev/archive/ansuz/designs/mcp_kuzudb_lock_architecture.md +312 -0
- package/core/dev/archive/ansuz/designs/phase0_git_enrichment.md +278 -0
- package/core/dev/archive/ansuz/designs/refactor_mcp_tools_synapse.md +490 -0
- package/core/dev/archive/ansuz/designs/semantic_markdown_extraction.md +167 -0
- package/core/dev/archive/ansuz/designs/task_1372_prompt_injects_into.md +193 -0
- package/core/dev/archive/ansuz/designs/thought_stack.md +286 -0
- package/core/dev/archive/ansuz/investigations/reachability_unified_api_2026-04-11.md +330 -0
- package/core/dev/archive/ansuz/investigations/synapse_orphans_indexing_bug_2026-04-11.md +352 -0
- package/core/dev/archive/ansuz/investigations/synapse_orphans_reindex_verification_2026-04-11.md +48 -0
- package/core/dev/archive/ansuz/investigations/synapse_orphans_verification_2026-04-11.md +170 -0
- package/core/dev/archive/ansuz/legacy/kernel.yaml +399 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_0.yaml +418 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_1.yaml +376 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_10.yaml +35 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_11.yaml +582 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_2.yaml +94 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_3.yaml +274 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_4.yaml +67 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_5.yaml +32 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_6.yaml +91 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_7.yaml +58 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_8.yaml +146 -0
- package/core/dev/archive/ansuz/legacy/phases/phase_9.yaml +424 -0
- package/core/dev/archive/ansuz/specs/INDEX_bifrost_hook_parity.yaml +92 -0
- package/core/dev/archive/ansuz/specs/active-inference-formation.yaml +453 -0
- package/core/dev/archive/ansuz/specs/brief_TASK_1228_userpromptsubmit.yaml +191 -0
- package/core/dev/archive/ansuz/specs/brief_TASK_1229_pretooluse_posttooluse.yaml +250 -0
- package/core/dev/archive/ansuz/specs/brief_TASK_1230_sessionstart_stop.yaml +301 -0
- package/core/dev/archive/ansuz/specs/brief_TASK_1231_verification.yaml +272 -0
- package/core/dev/design/PHASE4_DESIGN.md +559 -0
- package/core/dev/design/dashboard_docs_integration_PLAN.md +388 -0
- package/core/dev/design/matrix_format_ABBREVIATIONS.md +655 -0
- package/core/dev/design/matrix_format_DESIGN_SPEC.md +601 -0
- package/core/dev/design/matrix_format_DISCUSSION_SUMMARY.md +484 -0
- package/core/dev/design/matrix_format_EXAMPLE_memory.matrix +13 -0
- package/core/dev/design/matrix_format_EXAMPLE_project_status.matrix +9 -0
- package/core/dev/design/matrix_format_EXAMPLE_tasks.matrix +14 -0
- package/core/dev/design/matrix_format_SYNTAX_BNF.md +754 -0
- package/core/dev/design/matrix_format_TOKEN_COMPARISON.md +484 -0
- package/core/dev/design/matrix_v2_COGNITIVE_DESIGN.md +503 -0
- package/core/dev/design/matrix_v2_DISCUSSION_SUMMARY.md +414 -0
- package/core/dev/design/matrix_v2_EXAMPLE.matrix +67 -0
- package/core/dev/designs/EXPANDABLE_CARD_DESIGN_SPEC.md +509 -0
- package/core/dev/jev-eval/ACTIVE_CORRECTION.md +52 -0
- package/core/dev/jev-eval/ANNOTATION_GUIDE.md +68 -0
- package/core/dev/jev-eval/BASELINE_COMPARISON.md +45 -0
- package/core/dev/jev-eval/CONTEXT_REVIEW.md +31 -0
- package/core/dev/jev-eval/EVALUATION_STATUS.md +39 -0
- package/core/dev/jev-eval/HISTORICAL_CORPUS.md +33 -0
- package/core/dev/jev-eval/PACKAGING_VERIFICATION.md +42 -0
- package/core/dev/jev-eval/README.md +101 -0
- package/core/dev/jev-eval/THALAMUS_RANKING.md +58 -0
- package/core/dev/jev-eval/VALIDATION_PROGRESS.md +54 -0
- package/core/dev/jev-eval/cli.mjs +50 -0
- package/core/dev/jev-eval/context.mjs +183 -0
- package/core/dev/jev-eval/corpus.mjs +186 -0
- package/core/dev/jev-eval/fixtures/conversation-review.seed.jsonl +6 -0
- package/core/dev/jev-eval/fixtures/synthetic.jsonl +11 -0
- package/core/dev/jev-eval/metrics.mjs +67 -0
- package/core/dev/jev-eval/muninn-baseline.mjs +119 -0
- package/core/dev/jev-eval/providers.mjs +95 -0
- package/core/dev/jev-eval/reports/annotation-pilot-2026-09-20.json +32 -0
- package/core/dev/jev-eval/reports/context-review-2026-09-20.json +48 -0
- package/core/dev/jev-eval/reports/conversation-review.pending.json +151 -0
- package/core/dev/jev-eval/reports/history-corpus-2026-09-20.json +52 -0
- package/core/dev/jev-eval/reports/length-probe-2026-09-20.json +133 -0
- package/core/dev/jev-eval/reports/live-smoke-2026-09-20.json +616 -0
- package/core/dev/jev-eval/reports/muninn-baseline-2026-09-20.json +52 -0
- package/core/dev/jev-eval/reports/resilience-2026-09-20.json +520 -0
- package/core/dev/jev-eval/reports/rules-baseline.json +197 -0
- package/core/dev/jev-eval/reports/synthetic-review.pending.json +357 -0
- package/core/dev/jev-eval/resilience.mjs +71 -0
- package/core/dev/jev-eval/review.mjs +78 -0
- package/core/dev/jev-eval/schema.mjs +87 -0
- package/core/dev/jev-eval/test/context.test.mjs +95 -0
- package/core/dev/jev-eval/test/corpus.test.mjs +102 -0
- package/core/dev/jev-eval/test/eval.test.mjs +146 -0
- package/core/dev/jev-eval/test/muninn-baseline.test.mjs +71 -0
- package/core/dev/jev-eval/test/resilience.test.mjs +72 -0
- package/core/dev/jev-eval/test/review.test.mjs +61 -0
- package/core/dev/pipeline/LOCK_STATE.json +4 -0
- package/core/dev/pipeline/OPTIMIZATION_PROPOSALS.json +32 -0
- package/core/dev/pipeline/PHASE3_PLANNING_SUMMARY.md +338 -0
- package/core/dev/pipeline/PIPELINE_CONFIG.json +46 -0
- package/core/dev/pipeline/PROGRESS.md +113 -0
- package/core/dev/pipeline/PROGRESS_template.md +860 -0
- package/core/dev/pipeline/QA_REPORT_F008.md +431 -0
- package/core/dev/pipeline/QA_REPORT_LOCAL_CLAUDE_DIAGNOSIS.md +583 -0
- package/core/dev/pipeline/README.md +210 -0
- package/core/dev/pipeline/SELF_ENHANCEMENT_STATUS.json.bak +47 -0
- package/core/dev/pipeline/TASK_QUEUE.json +192 -0
- package/core/dev/pipeline/WORKFLOW_GUIDE.md +824 -0
- package/core/dev/pipeline/archived/TASK_015_tauri_init.yaml +53 -0
- package/core/dev/pipeline/archived/TASK_016_tauri_commands.yaml +54 -0
- package/core/dev/pipeline/archived/TASK_017_rust_pty.yaml +54 -0
- package/core/dev/pipeline/archived/TASK_018_tauri_bundle.yaml +53 -0
- package/core/dev/pipeline/archived/TASK_019_release_workflow.yaml +56 -0
- package/core/dev/pipeline/archived/TASK_020_update_ui.yaml +54 -0
- package/core/dev/pipeline/archived/TASK_021_update_notification_ui.yaml +55 -0
- package/core/dev/pipeline/archived/TASK_022_remove_node_pty.yaml +65 -0
- package/core/dev/pipeline/archived/TASK_023_api_routes_migration.yaml +86 -0
- package/core/dev/pipeline/archived/TASK_024_feature_id_system.yaml +51 -0
- package/core/dev/pipeline/archived/TASK_025_executable_acceptance.yaml +66 -0
- package/core/dev/pipeline/archived/TASK_026_spec_versioning.yaml +56 -0
- package/core/dev/pipeline/archived/TASK_027_drift_detection.yaml +60 -0
- package/core/dev/pipeline/archived/TASK_028_tauri_pty_manager.yaml +60 -0
- package/core/dev/pipeline/archived/TASK_029_tauri_pty_commands.yaml +62 -0
- package/core/dev/pipeline/archived/TASK_030_frontend_session_adapter.yaml +54 -0
- package/core/dev/pipeline/archived/TASK_031_terminal_tauri_events.yaml +56 -0
- package/core/dev/pipeline/archived/TASK_041_scheduler_data_models.yaml +54 -0
- package/core/dev/pipeline/archived/TASK_042_path_lock_manager.yaml +53 -0
- package/core/dev/pipeline/archived/TASK_043_process_manager.yaml +57 -0
- package/core/dev/pipeline/archived/TASK_044_git_integration.yaml +85 -0
- package/core/dev/pipeline/archived/TASK_045_task_queue_manager.yaml +54 -0
- package/core/dev/pipeline/archived/TASK_046_scheduler_dispatcher.yaml +60 -0
- package/core/dev/pipeline/archived/TASK_047_tauri_scheduler_commands.yaml +55 -0
- package/core/dev/pipeline/archived/TASK_048_realtime_status_push.yaml +92 -0
- package/core/dev/pipeline/archived/TASK_049_frontend_scheduler_integration.yaml +58 -0
- package/core/dev/pipeline/archived/TASK_050_error_recovery.yaml +56 -0
- package/core/dev/pipeline/archived/TASK_051_optimization_proposals_backend.yaml +53 -0
- package/core/dev/pipeline/archived/TASK_052_optimization_proposals_ui.yaml +58 -0
- package/core/dev/pipeline/archived/TASK_053_optimization_proposals_diff_view.yaml +54 -0
- package/core/dev/pipeline/archived/TASK_054_multi_project_scheduler_state.yaml +76 -0
- package/core/dev/pipeline/archived/TASK_055_scheduler_api_project_scope.yaml +64 -0
- package/core/dev/pipeline/archived/TASK_056_frontend_scheduler_project_scope.yaml +62 -0
- package/core/dev/pipeline/archived/TASK_057_scheduler_module_structure.yaml +54 -0
- package/core/dev/pipeline/archived/TASK_058_scheduler_models_extract.yaml +51 -0
- package/core/dev/pipeline/archived/TASK_059_scheduler_core_extract.yaml +51 -0
- package/core/dev/pipeline/archived/TASK_060_scheduler_commands_extract.yaml +51 -0
- package/core/dev/pipeline/archived/TASK_061_scheduler_specialized_commands.yaml +53 -0
- package/core/dev/pipeline/archived/TASK_062_process_manager_module_structure.yaml +56 -0
- package/core/dev/pipeline/archived/TASK_063_process_manager_core_extract.yaml +56 -0
- package/core/dev/pipeline/archived/TASK_064_recovery_module_structure.yaml +57 -0
- package/core/dev/pipeline/archived/TASK_065_recovery_core_extract.yaml +56 -0
- package/core/dev/pipeline/archived/TASK_066_self_enhancement_scheduler_models.yaml +60 -0
- package/core/dev/pipeline/archived/TASK_067_agents_section_quick_actions.yaml +53 -0
- package/core/dev/pipeline/archived/TASK_067_self_enhancement_scheduler_core.yaml +65 -0
- package/core/dev/pipeline/archived/TASK_068_agent_workflow_rule_enhancement.yaml +46 -0
- package/core/dev/pipeline/archived/TASK_068_self_enhancement_tauri_commands.yaml +61 -0
- package/core/dev/pipeline/archived/TASK_069_agent_wizard_responsive.yaml +46 -0
- package/core/dev/pipeline/archived/TASK_069_self_enhancement_ui.yaml +62 -0
- package/core/dev/pipeline/archived/TASK_070_preview_panel_redesign.yaml +62 -0
- package/core/dev/pipeline/archived/TASK_070_self_enhancement_integration.yaml +57 -0
- package/core/dev/pipeline/archived/TASK_071_preview_panel_qa.yaml +98 -0
- package/core/dev/pipeline/archived/TASK_071_single_agent_config.yaml +57 -0
- package/core/dev/pipeline/archived/TASK_072_preview_modal_esc_fix.yaml +71 -0
- package/core/dev/pipeline/archived/TASK_072_product_review_module.yaml +57 -0
- package/core/dev/pipeline/archived/TASK_073_agents_page_component_refactor.yaml +68 -0
- package/core/dev/pipeline/archived/TASK_073_rename_single_agent.yaml +64 -0
- package/core/dev/pipeline/archived/TASK_074_preview_mode_ui_diagnosis.yaml +71 -0
- package/core/dev/pipeline/archived/TASK_074_single_agent_ui_toggle.yaml +56 -0
- package/core/dev/pipeline/archived/TASK_075_agents_page_component_refactor.yaml +69 -0
- package/core/dev/pipeline/archived/TASK_075_single_agent_integration_test.yaml +75 -0
- package/core/dev/pipeline/archived/TASK_076_preview_mode_ui_diagnosis.yaml +70 -0
- package/core/dev/pipeline/archived/TASK_076_single_agent_continuous_mode.yaml +65 -0
- package/core/dev/pipeline/archived/TASK_077_failure_directory_structure.yaml +51 -0
- package/core/dev/pipeline/archived/TASK_077_single_agent_typescript_types.yaml +59 -0
- package/core/dev/pipeline/archived/TASK_078_fail_001_agent_no_output.yaml +53 -0
- package/core/dev/pipeline/archived/TASK_078_single_agent_ui_simplify.yaml +74 -0
- package/core/dev/pipeline/archived/TASK_079_dashboard_rwd_responsive.yaml +63 -0
- package/core/dev/pipeline/archived/TASK_079_fail_002_json_bom.yaml +56 -0
- package/core/dev/pipeline/archived/TASK_080_fail_003_queue_pollution.yaml +56 -0
- package/core/dev/pipeline/archived/TASK_080_http_server_module.yaml +55 -0
- package/core/dev/pipeline/archived/TASK_081_failure_logging_tools.yaml +57 -0
- package/core/dev/pipeline/archived/TASK_081_http_api_routes.yaml +62 -0
- package/core/dev/pipeline/archived/TASK_082_frontend_api_adapter.yaml +51 -0
- package/core/dev/pipeline/archived/TASK_082_integrate_failure_to_workflow.yaml +60 -0
- package/core/dev/pipeline/archived/TASK_083_cleanup_nextjs_api.yaml +48 -0
- package/core/dev/pipeline/archived/TASK_083_task_queue_cleanup.yaml +67 -0
- package/core/dev/pipeline/archived/TASK_084_rust_dead_code_cleanup.yaml +66 -0
- package/core/dev/pipeline/archived/TASK_084_scheduler_sync_logic_fix.yaml +68 -0
- package/core/dev/pipeline/archived/TASK_085_http_api_web_mode_fixes.yaml +46 -0
- package/core/dev/pipeline/archived/TASK_085_memory_consolidation_0204_0205.yaml +98 -0
- package/core/dev/pipeline/archived/TASK_086_collapsible_preview_panel.yaml +161 -0
- package/core/dev/pipeline/archived/TASK_086_web_mode_feature_parity.yaml +62 -0
- package/core/dev/pipeline/archived/TASK_087_manual_memory_archival.yaml +163 -0
- package/core/dev/pipeline/archived/TASK_087_mobile_http_control.yaml +68 -0
- package/core/dev/pipeline/archived/TASK_088_fail_003_to_ppl_002_rule.yaml +63 -0
- package/core/dev/pipeline/archived/TASK_088_mobile_http_qa.yaml +121 -0
- package/core/dev/pipeline/archived/TASK_089_agent_collaboration_topic.yaml +60 -0
- package/core/dev/pipeline/archived/TASK_089_web_mode_monitor_fix.yaml +58 -0
- package/core/dev/pipeline/archived/TASK_090_cli_detection_fix.yaml +61 -0
- package/core/dev/pipeline/archived/TASK_090_ui_ux_lessons_topic.yaml +63 -0
- package/core/dev/pipeline/archived/TASK_091_expandable_card_design.yaml +56 -0
- package/core/dev/pipeline/archived/TASK_091_move_agent_section_components.yaml +65 -0
- package/core/dev/pipeline/archived/TASK_092_expandable_card_component.yaml +60 -0
- package/core/dev/pipeline/archived/TASK_092_refactor_agent_create_wizard.yaml +84 -0
- package/core/dev/pipeline/archived/TASK_093_taskcard_detail_integration.yaml +57 -0
- package/core/dev/pipeline/archived/TASK_093_update_barrel_exports_test.yaml +84 -0
- package/core/dev/pipeline/archived/TASK_094_ai_agent_generation_enhancement.yaml +115 -0
- package/core/dev/pipeline/archived/TASK_094_proposalcard_detail_integration.yaml +55 -0
- package/core/dev/pipeline/archived/TASK_095_preview_fixes.yaml +129 -0
- package/core/dev/pipeline/archived/TASK_095_single_agent_task_selector.yaml +60 -0
- package/core/dev/pipeline/archived/TASK_096_agents_page_ux_improvements.yaml +163 -0
- package/core/dev/pipeline/archived/TASK_096_single_agent_status_sync.yaml +60 -0
- package/core/dev/pipeline/archived/TASK_097_local_claude_error_logging.yaml +59 -0
- package/core/dev/pipeline/archived/TASK_097_single_agent_monitor_events.yaml +59 -0
- package/core/dev/pipeline/archived/TASK_098_product_manager_team_phase2.yaml +60 -0
- package/core/dev/pipeline/archived/TASK_098_single_agent_refactor_test.yaml +58 -0
- package/core/dev/pipeline/archived/TASK_099_backend_team_creation.yaml +258 -0
- package/core/dev/pipeline/archived/TASK_100_frontend_team_creation.yaml +61 -0
- package/core/dev/pipeline/archived/TASK_101_orchestrator_system.yaml +403 -0
- package/core/dev/pipeline/archived/TASK_102_designer_sre_teams.yaml +90 -0
- package/core/dev/pipeline/archived/TASK_103_integration_testing.yaml +86 -0
- package/core/dev/pipeline/archived/TASK_128_integration_testing.yaml +83 -0
- package/core/dev/pipeline/archived/TASK_134_cortex_v2_phase3_file_watcher.yaml +65 -0
- package/core/dev/pipeline/archived/TASK_134_team_http_api.yaml +96 -0
- package/core/dev/pipeline/archived/TASK_135_cortex_v2_phase3_git_monitor.yaml +63 -0
- package/core/dev/pipeline/archived/TASK_136_cortex_v2_phase3_change_analyzer.yaml +69 -0
- package/core/dev/pipeline/archived/TASK_137_cortex_v2_phase3_cache_invalidator.yaml +67 -0
- package/core/dev/pipeline/archived/TASK_137_team_orchestrator_integration.yaml +93 -0
- package/core/dev/pipeline/archived/TASK_138_cortex_v2_phase3_distributed_cache.yaml +68 -0
- package/core/dev/pipeline/archived/TASK_138_matrix_folder_structure.yaml +61 -0
- package/core/dev/pipeline/archived/TASK_139_cortex_v2_phase3_cache_prewarming.yaml +65 -0
- package/core/dev/pipeline/archived/TASK_146_unified_documentation.yaml +141 -0
- package/core/dev/pipeline/archived/TASK_147_pipeline_execution_rules.yaml +76 -0
- package/core/dev/pipeline/archived/TASK_148_update_claude_md.yaml +77 -0
- package/core/dev/pipeline/archived/TASK_149_fix_nextjs_mdx_serialization.yaml +63 -0
- package/core/dev/pipeline/archived/TASK_149_update_team_docs.yaml +77 -0
- package/core/dev/pipeline/archived/TASK_150_pipeline_workflow_guide.yaml +82 -0
- package/core/dev/pipeline/archived/TASK_164_fix_smart_context_switch.yaml +49 -0
- package/core/dev/pipeline/archived/TASK_165_ctags_symbol_index.yaml +53 -0
- package/core/dev/pipeline/archived/TASK_166_symbol_search_mcp_tool.yaml +48 -0
- package/core/dev/pipeline/archived/TASK_167_llm_module_summary.yaml +55 -0
- package/core/dev/pipeline/archived/TASK_168_map_reduce_context.yaml +51 -0
- package/core/dev/pipeline/archived/TASK_169_v2_integration_testing.yaml +52 -0
- package/core/dev/pipeline/backups/archive_2026-02-04T22-07-22/TASK_QUEUE_backup.json +95 -0
- package/core/dev/pipeline/docs/multi-agent-coordination.md +446 -0
- package/core/dev/pipeline/docs/overview.md +406 -0
- package/core/dev/pipeline/docs/task-management.md +412 -0
- package/core/dev/pipeline/docs/workflows.md +32 -0
- package/core/dev/pipeline/orchestrator/schemas/task_queue_schema.json +58 -0
- package/core/dev/pipeline/orchestrator/schemas/task_schema.json +139 -0
- package/core/dev/pipeline/plans/PLAN_task_cli_refactor.md +281 -0
- package/core/dev/pipeline/tasks/.gitkeep +1 -0
- package/core/dev/pipeline/test_results/TASK_TEST_PARALLEL_002_result.txt +27 -0
- package/core/dev/plans/CLI_FIRST_INSTALL_FLOW.md +128 -0
- package/core/dev/plans/FORMATION_RETIREMENT_PLAN.md +313 -0
- package/core/dev/plans/KUZU_REPLACEMENT_PLAN.md +126 -0
- package/core/dev/schemas/PRODUCT_SPEC.example.yaml +382 -0
- package/core/dev/schemas/PRODUCT_SPEC.schema.json +800 -0
- package/core/dev/schemas/README.md +517 -0
- package/core/dev/schemas/TASK.schema.json +226 -0
- package/core/dev/schemas/dataflows_ground_truth.yaml +173 -0
- package/core/dev/schemas/dataflows_spec.yaml +160 -0
- package/core/dev/schemas/extends_ground_truth.yaml +66 -0
- package/core/dev/schemas/extends_spec.yaml +121 -0
- package/core/dev/schemas/implements_ground_truth.yaml +77 -0
- package/core/dev/schemas/implements_spec.yaml +140 -0
- package/core/dev/scripts/CRASH_DIAGNOSIS.md +47 -0
- package/core/dev/scripts/README.md +142 -0
- package/core/dev/scripts/RUN_ONCE.bat +40 -0
- package/core/dev/scripts/START_DEV_AGENT.bat +63 -0
- package/core/dev/scripts/START_MULTI_AGENT.bat +80 -0
- package/core/dev/scripts/check-alaya-report-isolation.js +255 -0
- package/core/dev/scripts/check-file-size.js +268 -0
- package/core/dev/scripts/ci-feedback.js +251 -0
- package/core/dev/scripts/clean-verify-targets.js +132 -0
- package/core/dev/scripts/cleanup-queue.js +184 -0
- package/core/dev/scripts/cleanup_queue.js +86 -0
- package/core/dev/scripts/dev_agent_scheduler.ps1 +536 -0
- package/core/dev/scripts/dispatch-stats.js +384 -0
- package/core/dev/scripts/dispatch-stats.test.js +162 -0
- package/core/dev/scripts/gc-agent-worktrees.js +461 -0
- package/core/dev/scripts/gc-agent-worktrees.test.js +48 -0
- package/core/dev/scripts/hooks/README.md +148 -0
- package/core/dev/scripts/init_git.ps1 +396 -0
- package/core/dev/scripts/init_git.sh +337 -0
- package/core/dev/scripts/init_project.ps1 +851 -0
- package/core/dev/scripts/init_project.sh +477 -0
- package/core/dev/scripts/js-yaml-resolution.test.js +48 -0
- package/core/dev/scripts/kenaz-session.js +354 -0
- package/core/dev/scripts/kenaz-session.test.js +234 -0
- package/core/dev/scripts/legacy/README.md +39 -0
- package/core/dev/scripts/legacy/dev_agent_scheduler.ps1.bak +536 -0
- package/core/dev/scripts/legacy/multi_agent_scheduler.ps1.bak +1978 -0
- package/core/dev/scripts/matrix/CLI_README.md +214 -0
- package/core/dev/scripts/matrix/README.md +310 -0
- package/core/dev/scripts/matrix/package-lock.json +4266 -0
- package/core/dev/scripts/matrix/package.json +55 -0
- package/core/dev/scripts/matrix/src/abbreviations.ts +295 -0
- package/core/dev/scripts/matrix/src/cli/commands/convert.ts +211 -0
- package/core/dev/scripts/matrix/src/cli/commands/create.ts +95 -0
- package/core/dev/scripts/matrix/src/cli/commands/delete.ts +102 -0
- package/core/dev/scripts/matrix/src/cli/commands/list-tags.ts.wip +140 -0
- package/core/dev/scripts/matrix/src/cli/commands/manage-tags.ts.wip +173 -0
- package/core/dev/scripts/matrix/src/cli/commands/query.ts +261 -0
- package/core/dev/scripts/matrix/src/cli/commands/read.ts +77 -0
- package/core/dev/scripts/matrix/src/cli/commands/stats.ts.wip +168 -0
- package/core/dev/scripts/matrix/src/cli/commands/tokens.ts.wip +126 -0
- package/core/dev/scripts/matrix/src/cli/commands/update.ts +147 -0
- package/core/dev/scripts/matrix/src/cli/commands/validate.ts +275 -0
- package/core/dev/scripts/matrix/src/cli/index.ts +350 -0
- package/core/dev/scripts/matrix/src/cli/utils/file-handler.ts +72 -0
- package/core/dev/scripts/matrix/src/cli/utils/logger.ts +65 -0
- package/core/dev/scripts/matrix/src/index.ts +62 -0
- package/core/dev/scripts/matrix/src/indexer/tag-indexer.ts +165 -0
- package/core/dev/scripts/matrix/src/parser.ts +281 -0
- package/core/dev/scripts/matrix/src/serializer.ts +151 -0
- package/core/dev/scripts/matrix/src/validator.ts +301 -0
- package/core/dev/scripts/matrix/tests/abbreviations.test.ts +122 -0
- package/core/dev/scripts/matrix/tests/cli.test.ts +177 -0
- package/core/dev/scripts/matrix/tests/convert.test.ts +143 -0
- package/core/dev/scripts/matrix/tests/parser.test.ts +203 -0
- package/core/dev/scripts/matrix/tests/query.test.ts +85 -0
- package/core/dev/scripts/matrix/tests/serializer.test.ts +197 -0
- package/core/dev/scripts/matrix/tests/validate.test.ts +141 -0
- package/core/dev/scripts/matrix/tests/validator.test.ts +167 -0
- package/core/dev/scripts/matrix/tsconfig.json +20 -0
- package/core/dev/scripts/matrix/types/index.d.ts +111 -0
- package/core/dev/scripts/matrix/types/index.d.ts.map +1 -0
- package/core/dev/scripts/matrix/types/index.js +8 -0
- package/core/dev/scripts/matrix/types/index.js.map +1 -0
- package/core/dev/scripts/matrix/types/index.ts +124 -0
- package/core/dev/scripts/memory-guard-eval.js +330 -0
- package/core/dev/scripts/memory-usage-report.js +152 -0
- package/core/dev/scripts/migrate-task-dependencies.js +198 -0
- package/core/dev/scripts/multi_agent_scheduler.ps1 +2021 -0
- package/core/dev/scripts/multi_agent_scheduler.sh +1344 -0
- package/core/dev/scripts/probe/ansuz-scaffold-ablation.js +579 -0
- package/core/dev/scripts/probe/ansuz-scaffold-ablation.test.js +244 -0
- package/core/dev/scripts/probe/hippocampus-concurrency.js +247 -0
- package/core/dev/scripts/probe/hook-latency-probe.js +315 -0
- package/core/dev/scripts/probe/hook-latency-probe.test.js +105 -0
- package/core/dev/scripts/probe/prediction-signal-auc.js +483 -0
- package/core/dev/scripts/probe/prediction-signal-auc.test.js +200 -0
- package/core/dev/scripts/reset_tasks.js +99 -0
- package/core/dev/scripts/run-rust-tests.js +207 -0
- package/core/dev/scripts/run-rust-tests.test.js +154 -0
- package/core/dev/scripts/run_once.sh +47 -0
- package/core/dev/scripts/rust-verify-worktree.js +591 -0
- package/core/dev/scripts/rust-verify-worktree.test.js +574 -0
- package/core/dev/scripts/seh_probe.rs +26 -0
- package/core/dev/scripts/setup_mcp.ps1 +192 -0
- package/core/dev/scripts/setup_mcp.sh +159 -0
- package/core/dev/scripts/setup_rag.ps1 +304 -0
- package/core/dev/scripts/setup_rag.sh +230 -0
- package/core/dev/scripts/start_dev_agent.sh +137 -0
- package/core/dev/scripts/start_multi_agent.sh +41 -0
- package/core/dev/scripts/sync_task_queue.ps1 +505 -0
- package/core/dev/scripts/sync_task_queue.sh +392 -0
- package/core/dev/scripts/task1961/RUNBOOK.md +300 -0
- package/core/dev/scripts/task1961/fixtures/never-listens.server.js +54 -0
- package/core/dev/scripts/task1961/fixtures/slow-serve.server.js +134 -0
- package/core/dev/scripts/task1961/run-fixture.js +659 -0
- package/core/dev/scripts/task1961/selftest.js +247 -0
- package/core/dev/scripts/test-pty-ws-tunnel.js +229 -0
- package/core/dev/scripts/validate_pipeline.js +197 -0
- package/core/dev/scripts/verify-isbar-capture.js +100 -0
- package/core/dev/scripts/verify-target-dir.js +69 -0
- package/core/dev/scripts/verify-task-1839.js +141 -0
- package/core/dev/specs/agent-connect/PROTOCOL.md +177 -0
- package/core/dev/specs/agent-connect/SDK_GUIDE.md +915 -0
- package/core/dev/specs/agent-connect/examples/minimal-site/README.md +137 -0
- package/core/dev/specs/agent-connect/examples/minimal-site/package.json +12 -0
- package/core/dev/specs/agent-connect/examples/minimal-site/public/index.html +116 -0
- package/core/dev/specs/agent-connect/examples/minimal-site/public/install-redirect.js +73 -0
- package/core/dev/specs/agent-connect/examples/minimal-site/server.js +516 -0
- package/core/dev/specs/agent-connect/examples/minimal-site/test/smoke.test.mjs +263 -0
- package/core/dev/specs/agent-connect/history/DEFECT_REPORT_kenaz-agent-hub_2026-09-09_v0.4-empty-prompt-no-first-turn.md +77 -0
- package/core/dev/specs/agent-connect/history/DEFECT_REPORT_kenaz-agent-hub_2026-09-09_v0.4-prompt-mojibake.md +90 -0
- package/core/dev/specs/agent-connect/history/FEATURE_REQUEST_kenaz-agent-hub_2026-09-07.md +61 -0
- package/core/dev/specs/agent-connect/history/FEATURE_REQUEST_kenaz-agent-hub_2026-09-08_relay-v1-conformance.md +76 -0
- package/core/dev/specs/agent-connect/history/FEATURE_REQUEST_kenaz-agent-hub_2026-09-09_v0.4-session-channel.md +87 -0
- package/core/dev/specs/agent-connect/history/FLOWPIX_REPLY_agent-hub_2026-09-08_relay-v1-answers.md +68 -0
- package/core/dev/specs/agent-connect/history/FLOWPIX_bridge_CONTRACT.md +642 -0
- package/core/dev/specs/agent-connect/history/FLOWPIX_spikes_relay_spike_relay.mjs +244 -0
- package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-07.md +77 -0
- package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-08_direction-change-v0.3.md +44 -0
- package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-08_relay-v1-answers-ack.md +37 -0
- package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-08_relay-v1-conformance.md +56 -0
- package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-09_annotations-install-coldstart.md +44 -0
- package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-09_empty-prompt-first-turn.md +56 -0
- package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-09_prompt-mojibake-fixed.md +48 -0
- package/core/dev/specs/agent-connect/history/KENAZ_RESPONSE_agent-hub_2026-09-09_session-channel.md +57 -0
- package/core/dev/specs/agent-connect/history/PROTOCOL_v0.3_snapshot.md +379 -0
- package/core/dev/specs/agent-connect/history/README.md +47 -0
- package/core/dev/specs/peer/CODEX_INTERACTIVE_PUSH.md +65 -0
- package/core/dev/specs/peer/CODEX_PEER_PULL_SPIKE.md +54 -0
- package/core/dev/specs/peer/MODS_SPIKE.md +133 -0
- package/core/dev/specs/peer/PER_PROJECT_ADDRESSING.md +143 -0
- package/core/dev/specs/peer/SWARM_PROTOCOLS.md +256 -0
- package/core/dev/specs/peer/codex-hook-shim-peer.test.js +101 -0
- package/core/dev/specs/peer/codex-push-launcher.test.js +142 -0
- package/core/dev/specs/peer/setup-codex-hooks.test.js +22 -0
- package/core/dev/specs/peer-ansuz/DELIVERY_SPIKE.md +397 -0
- package/core/dev/specs/peer-ansuz/DESIGN.md +109 -0
- package/core/dev/specs/peer-ansuz/spike/claude_poke.js +129 -0
- package/core/dev/specs/peer-ansuz/spike/claude_session_start_hook.js +37 -0
- package/core/dev/specs/peer-ansuz/spike/claude_settings_hook.json +14 -0
- package/core/dev/specs/peer-ansuz/spike/codex_appserver_client.js +105 -0
- package/core/dev/specs/peer-ansuz/spike/codex_appserver_query.js +29 -0
- package/core/dev/specs/peer-ansuz/spike/extract_timeline.js +26 -0
- package/core/dev/specs/synapse/SYMBOL_IDENTITY.md +305 -0
- package/core/dev/spikes/A4-cypher-varlen.md +176 -0
- package/core/dev/spikes/bloat-rounds.sh +25 -0
- package/core/dev/spikes/mods/clean-claude.js +9 -0
- package/core/dev/spikes/mods/drive-probe.js +29 -0
- package/core/dev/spikes/mods/e2e-peer.js +71 -0
- package/core/dev/spikes/mods/evidence/e2e-peer-control.json +17 -0
- package/core/dev/spikes/mods/evidence/e2e-peer-mod.json +17 -0
- package/core/dev/spikes/mods/evidence/probe-006a6e65-d807-4bc1-b648-fd7d1edfe0b4.jsonl +4 -0
- package/core/dev/spikes/mods/evidence/probe-cebdf1f7-f9c4-47a8-83cd-7c0786177404.jsonl +12 -0
- package/core/dev/spikes/mods/evidence/probe-eb21147d-10ce-4c32-93ed-37ca37d88d5a.jsonl +11 -0
- package/core/dev/spikes/mods/evidence/stream-cebdf1f7.jsonl +18 -0
- package/core/dev/spikes/mods/kenaz-mod-probe/.claude-plugin/plugin.json +1 -0
- package/core/dev/spikes/mods/kenaz-mod-probe/hooks/hooks.json +1 -0
- package/core/dev/spikes/mods/kenaz-mod-probe/hooks/register.ts +65 -0
- package/core/dev/spikes/mods/kenaz-mod-probe/tsconfig.json +3 -0
- package/core/k-cli/README.md +423 -0
- package/core/k-cli/package.json +21 -0
- package/core/k-cli/templates/k-cli.md +91 -0
- package/core/k-cli/test/TEST_SPEC.md +134 -0
- package/core/k-cli/test/run.sh +469 -0
- package/core/plugins/kenaz/.claude-plugin/plugin.json +1 -0
- package/core/plugins/kenaz/.mcp.json +5 -0
- package/core/plugins/kenaz/INVENTORY.md +48 -0
- package/core/plugins/kenaz/README.md +55 -0
- package/core/plugins/kenaz/commands/Amelia.md +5 -0
- package/core/plugins/kenaz/commands/Ansuz.md +38 -0
- package/core/plugins/kenaz/commands/architect.md +24 -0
- package/core/plugins/kenaz/commands/incident.md +15 -0
- package/core/plugins/kenaz/commands/kenaz.md +12 -0
- package/core/plugins/kenaz/commands/review.md +14 -0
- package/core/plugins/kenaz/commands/security.md +15 -0
- package/core/plugins/kenaz/commands/spec.md +22 -0
- package/core/plugins/kenaz/commands/strategy.md +141 -0
- package/core/plugins/kenaz/commands//347/224/242/345/223/201.md +15 -0
- package/core/plugins/kenaz/commands//350/250/255/350/250/210.md +14 -0
- package/core/plugins/kenaz/commands//350/251/225/344/274/260.md +16 -0
- package/core/plugins/kenaz/guidance.md +5 -0
- package/core/plugins/kenaz/hooks/core-resolve.js +230 -0
- package/core/plugins/kenaz/hooks/hooks.json +31 -0
- package/core/plugins/kenaz/hooks/kenaz-hook.js +112 -0
- package/core/plugins/kenaz/hooks/mode.js +39 -0
- package/core/plugins/kenaz/scripts/kenaz-mode.js +46 -0
- package/core/plugins/kenaz/scripts/kenaz.test.js +123 -0
- package/core/plugins/kenaz/scripts/sync.js +45 -0
- package/core/plugins/kenaz/scripts/ygg.js +157 -0
- package/core/plugins/kenaz/skills/adapt/SKILL.md +199 -0
- package/core/plugins/kenaz/skills/animate/SKILL.md +190 -0
- package/core/plugins/kenaz/skills/architect_agent/SKILL.md +408 -0
- package/core/plugins/kenaz/skills/assessment_agent/SKILL.md +289 -0
- package/core/plugins/kenaz/skills/audit/SKILL.md +129 -0
- package/core/plugins/kenaz/skills/backend_agent/SKILL.md +407 -0
- package/core/plugins/kenaz/skills/backend_engineer/SKILL.md +788 -0
- package/core/plugins/kenaz/skills/bolder/SKILL.md +132 -0
- package/core/plugins/kenaz/skills/clarify/SKILL.md +180 -0
- package/core/plugins/kenaz/skills/code_reviewer/SKILL.md +305 -0
- package/core/plugins/kenaz/skills/code_reviewer/patterns.yaml +85 -0
- package/core/plugins/kenaz/skills/colorize/SKILL.md +158 -0
- package/core/plugins/kenaz/skills/critique/SKILL.md +118 -0
- package/core/plugins/kenaz/skills/delight/SKILL.md +317 -0
- package/core/plugins/kenaz/skills/designer/SKILL.md +845 -0
- package/core/plugins/kenaz/skills/dev_agent/SKILL.md +503 -0
- package/core/plugins/kenaz/skills/developer/SKILL.md +792 -0
- package/core/plugins/kenaz/skills/distill/SKILL.md +137 -0
- package/core/plugins/kenaz/skills/extract/SKILL.md +95 -0
- package/core/plugins/kenaz/skills/feature_agent/SKILL.md +303 -0
- package/core/plugins/kenaz/skills/frontend-design/SKILL.md +127 -0
- package/core/plugins/kenaz/skills/frontend-design/reference/color-and-contrast.md +132 -0
- package/core/plugins/kenaz/skills/frontend-design/reference/interaction-design.md +123 -0
- package/core/plugins/kenaz/skills/frontend-design/reference/motion-design.md +99 -0
- package/core/plugins/kenaz/skills/frontend-design/reference/responsive-design.md +114 -0
- package/core/plugins/kenaz/skills/frontend-design/reference/spatial-design.md +100 -0
- package/core/plugins/kenaz/skills/frontend-design/reference/typography.md +131 -0
- package/core/plugins/kenaz/skills/frontend-design/reference/ux-writing.md +107 -0
- package/core/plugins/kenaz/skills/frontend_agent/SKILL.md +327 -0
- package/core/plugins/kenaz/skills/harden/SKILL.md +358 -0
- package/core/plugins/kenaz/skills/incident_response/SKILL.md +315 -0
- package/core/plugins/kenaz/skills/normalize/SKILL.md +67 -0
- package/core/plugins/kenaz/skills/onboard/SKILL.md +243 -0
- package/core/plugins/kenaz/skills/optimize/SKILL.md +269 -0
- package/core/plugins/kenaz/skills/polish/SKILL.md +202 -0
- package/core/plugins/kenaz/skills/product_manager/SKILL.md +1091 -0
- package/core/plugins/kenaz/skills/qa_engineer/SKILL.md +1269 -0
- package/core/plugins/kenaz/skills/quieter/SKILL.md +118 -0
- package/core/plugins/kenaz/skills/security_agent/SKILL.md +312 -0
- package/core/plugins/kenaz/skills/spec_optimizer/SKILL.md +299 -0
- package/core/plugins/kenaz/skills/sre_agent/SKILL.md +1347 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/SKILL.md +377 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/scripts/core.py +253 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/core/plugins/kenaz/skills/ui-ux-pro-max/scripts/search.py +106 -0
- package/core/plugins/kenaz-peer/.claude-plugin/plugin.json +1 -0
- package/core/plugins/kenaz-peer/hooks/hooks.json +1 -0
- package/core/plugins/kenaz-peer/hooks/register.test.ts +62 -0
- package/core/plugins/kenaz-peer/hooks/register.ts +146 -0
- package/core/plugins/kenaz-peer/tsconfig.json +3 -0
- package/lib/cli.js +251 -0
- package/lib/cli.test.js +59 -0
- package/lib/dashboard.js +80 -0
- package/lib/dashboard.test.js +59 -0
- package/package.json +28 -4
- package/vendor/install-kenaz-cli.js +268 -0
- package/README.md +0 -3
|
@@ -0,0 +1,2183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formation Prompt Builder
|
|
3
|
+
* 根據陣型和技能定義組裝 prompt
|
|
4
|
+
*
|
|
5
|
+
* 每個陣型有不同的 prompt 結構:
|
|
6
|
+
* - unit: 角色 + 行為 + 任務 + 工作流程 + 輸出
|
|
7
|
+
* - solo: 角色 + 視角列表 + 行為 + 任務 + 工作流程 + 輸出
|
|
8
|
+
* - squad: 為每個成員分別組裝 prompt(含分工 scope)
|
|
9
|
+
* - legion: 為 team lead + 每個成員分別組裝 prompt(含溝通規則)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// ─────────────────────────────────────────
|
|
13
|
+
// Memory Loader(記憶系統整合)
|
|
14
|
+
// ─────────────────────────────────────────
|
|
15
|
+
let memoryLoader = null;
|
|
16
|
+
try {
|
|
17
|
+
memoryLoader = require('./memory-loader');
|
|
18
|
+
} catch { /* memory-loader not available — graceful degradation */ }
|
|
19
|
+
|
|
20
|
+
// ─────────────────────────────────────────
|
|
21
|
+
// Shared Principles Loader(共享原則注入)
|
|
22
|
+
// ─────────────────────────────────────────
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
const path = require('path');
|
|
25
|
+
const { buildWorktreeGitAddCommand } = require('./utils');
|
|
26
|
+
// TASK_2104: Alaya relevance gate (cosine floor + stack match) extracted to
|
|
27
|
+
// a dependency-free module so task-api.js's echoAlayaLessons can share it
|
|
28
|
+
// without pulling in Formation-only deps. Re-exported below unchanged so
|
|
29
|
+
// prompt.test.js's imports keep working.
|
|
30
|
+
const {
|
|
31
|
+
buildTaskContextQuery,
|
|
32
|
+
deriveTaskStack,
|
|
33
|
+
deriveBijaStack,
|
|
34
|
+
passesAlayaRelevanceGate,
|
|
35
|
+
dedupBijas,
|
|
36
|
+
ALAYA_MIN_COSINE_DEFAULT,
|
|
37
|
+
ALAYA_STACK_OVERRIDE_COSINE,
|
|
38
|
+
ALAYA_CANDIDATE_POOL,
|
|
39
|
+
} = require('./alaya-gate');
|
|
40
|
+
|
|
41
|
+
// Shared core-path resolver (validates existsSync+isDirectory, falls back to KENAZ_SOURCE_DIR)
|
|
42
|
+
let _resolveCoreDir = null;
|
|
43
|
+
try {
|
|
44
|
+
_resolveCoreDir = require(path.join(__dirname, '..', '..', '.claude', 'hooks', 'core-resolve')).resolveCoreDir;
|
|
45
|
+
} catch { /* graceful degradation — older installs without the export */ }
|
|
46
|
+
|
|
47
|
+
let _sharedPrinciplesCache = null;
|
|
48
|
+
|
|
49
|
+
// ─────────────────────────────────────────
|
|
50
|
+
// Shared Module Tag Rules(模組自動注入規則)
|
|
51
|
+
// ─────────────────────────────────────────
|
|
52
|
+
|
|
53
|
+
// TASK_2371: opt-in only — a task must carry the explicit review tag. No keyword
|
|
54
|
+
// match on generic tags (auth/test/...) or chart warnings; a 100-line OWASP
|
|
55
|
+
// block on an unrelated auth card was pure noise.
|
|
56
|
+
const MODULE_TAG_RULES = [
|
|
57
|
+
{ tags: ['security-review'], module: 'security.yaml' },
|
|
58
|
+
{ tags: ['testing-review'], module: 'testing.yaml' },
|
|
59
|
+
{ tags: ['code-review'], module: 'code_review.yaml' },
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Resolve which shared modules to inject based on task tags and optional chart context.
|
|
64
|
+
* @param {string|object} taskData - task JSON string or parsed object
|
|
65
|
+
* @param {string|null} [chartPath] - optional path to chart.json for richer context
|
|
66
|
+
* @param {string|null} [corePath] - KenazAI root path (defaults to two levels up from __dirname)
|
|
67
|
+
* @returns {string[]} list of absolute module file paths to inject
|
|
68
|
+
*/
|
|
69
|
+
function resolveModules(taskData, chartPath, corePath) {
|
|
70
|
+
const modules = new Set();
|
|
71
|
+
let taskTags = [];
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const parsed = typeof taskData === 'string' ? JSON.parse(taskData) : taskData;
|
|
75
|
+
if (parsed) {
|
|
76
|
+
taskTags = (parsed.tags || []).map(t => String(t).toLowerCase());
|
|
77
|
+
}
|
|
78
|
+
} catch { /* not JSON */ }
|
|
79
|
+
|
|
80
|
+
// Tag-based matching
|
|
81
|
+
for (const rule of MODULE_TAG_RULES) {
|
|
82
|
+
if (rule.tags.some(t => taskTags.includes(t))) {
|
|
83
|
+
modules.add(rule.module);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (modules.size === 0) return [];
|
|
88
|
+
|
|
89
|
+
const root = corePath || path.resolve(__dirname, '..', '..');
|
|
90
|
+
const modulesDir = path.join(root, '.formation', 'roles', '_shared', 'modules');
|
|
91
|
+
return [...modules].map(m => path.join(modulesDir, m));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Resolve the KenazAI core path from a sub-project's project.yaml.
|
|
96
|
+
* Returns null when projectPath is absent or IS the core project.
|
|
97
|
+
* Uses shared resolveCoreDir helper (validates existsSync+isDirectory, KENAZ_SOURCE_DIR fallback).
|
|
98
|
+
*/
|
|
99
|
+
function resolveCorePath(projectPath) {
|
|
100
|
+
if (!projectPath) return null;
|
|
101
|
+
|
|
102
|
+
const coreRoot = path.resolve(__dirname, '..', '..');
|
|
103
|
+
const norm = p => p.replace(/[\\/]+$/, '').replace(/\\/g, '/').toLowerCase();
|
|
104
|
+
if (norm(path.resolve(projectPath)) === norm(coreRoot)) return null;
|
|
105
|
+
|
|
106
|
+
if (_resolveCoreDir) {
|
|
107
|
+
const dir = _resolveCoreDir(projectPath);
|
|
108
|
+
return dir ? dir.replace(/\\/g, '/') : null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Fallback: original logic (no path validation — used if core-resolve.js export is absent)
|
|
112
|
+
try {
|
|
113
|
+
const yamlPath = path.join(projectPath, '.kenaz', 'project.yaml');
|
|
114
|
+
if (!fs.existsSync(yamlPath)) return null;
|
|
115
|
+
const content = fs.readFileSync(yamlPath, 'utf-8');
|
|
116
|
+
const m = content.match(/core_path:\s*['"]?(.+?)['"]?\s*$/m);
|
|
117
|
+
if (!m) return null;
|
|
118
|
+
const raw = m[1].trim();
|
|
119
|
+
return raw === '__kenaz_core__'
|
|
120
|
+
? (process.env.KENAZ_SOURCE_DIR || coreRoot).replace(/\\/g, '/')
|
|
121
|
+
: raw;
|
|
122
|
+
} catch { return null; }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function loadSharedPrinciples(corePath) {
|
|
126
|
+
if (_sharedPrinciplesCache) return _sharedPrinciplesCache;
|
|
127
|
+
|
|
128
|
+
const principlesPath = path.join(
|
|
129
|
+
corePath || path.resolve(__dirname, '..', '..'),
|
|
130
|
+
'.specialist', 'shared', 'principles.yaml'
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
if (!fs.existsSync(principlesPath)) return null;
|
|
135
|
+
const content = fs.readFileSync(principlesPath, 'utf-8');
|
|
136
|
+
|
|
137
|
+
// 提取 differential_over_intuition 區塊
|
|
138
|
+
const ddxMatch = content.match(
|
|
139
|
+
/differential_over_intuition:[\s\S]*?(?=\n# ═|$)/
|
|
140
|
+
);
|
|
141
|
+
if (!ddxMatch) return null;
|
|
142
|
+
|
|
143
|
+
_sharedPrinciplesCache = ddxMatch[0].trim();
|
|
144
|
+
return _sharedPrinciplesCache;
|
|
145
|
+
} catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ─────────────────────────────────────────
|
|
151
|
+
// TASK_1998 R2 -> two-axis prompt policy (2026-09-22 user decision)
|
|
152
|
+
// ─────────────────────────────────────────
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Extract the card's `rigor` field from taskData (JSON string or object).
|
|
156
|
+
* Returns null when taskData is absent, unparseable, or has no rigor field
|
|
157
|
+
* — promptProfile() treats null the same as an unrecognized value (normalizes
|
|
158
|
+
* to 'medium').
|
|
159
|
+
* @param {string|object|null|undefined} taskData
|
|
160
|
+
* @returns {string|null}
|
|
161
|
+
*/
|
|
162
|
+
function extractRigor(taskData) {
|
|
163
|
+
try {
|
|
164
|
+
const parsed = typeof taskData === 'string' ? JSON.parse(taskData) : taskData;
|
|
165
|
+
return (parsed && typeof parsed.rigor === 'string' && parsed.rigor.trim()) ? parsed.rigor.trim() : null;
|
|
166
|
+
} catch { return null; }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Extract the card's `complexity` field from taskData (JSON string or
|
|
171
|
+
* object). Unlike extractRigor, this ALWAYS returns a concrete string —
|
|
172
|
+
* missing, unparseable, or unrecognized values all normalize to 'medium'
|
|
173
|
+
* (the card default) so callers never need a second null-check.
|
|
174
|
+
* @param {string|object|null|undefined} taskData
|
|
175
|
+
* @returns {'simple'|'medium'|'complex'}
|
|
176
|
+
*/
|
|
177
|
+
function extractComplexity(taskData) {
|
|
178
|
+
try {
|
|
179
|
+
const parsed = typeof taskData === 'string' ? JSON.parse(taskData) : taskData;
|
|
180
|
+
const c = parsed && typeof parsed.complexity === 'string' ? parsed.complexity.trim() : '';
|
|
181
|
+
return (c === 'simple' || c === 'complex') ? c : 'medium';
|
|
182
|
+
} catch { return 'medium'; }
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* TASK_1998 two-axis prompt policy (2026-09-22 user decision, replaces the
|
|
187
|
+
* single rigor-gated R2 diet switch):
|
|
188
|
+
*
|
|
189
|
+
* CONTEXT volume — driven by `complexity` (how much the task touches):
|
|
190
|
+
* simple -> no Related Files Preview, no Known Failures, no Project Memory.
|
|
191
|
+
* medium -> Known Failures on; no Preview; no Project Memory.
|
|
192
|
+
* complex -> Related Files Preview on; Known Failures + Project Memory on.
|
|
193
|
+
* (TASK_2371: Cross-Project Context (Cortex) and Episodic Memory are gone
|
|
194
|
+
* for every complexity — stale / unverified outcomes.)
|
|
195
|
+
*
|
|
196
|
+
* PROCESS strictness — driven by `rigor`:
|
|
197
|
+
* low -> the 8-line "## Working contract" only; rune inscription optional.
|
|
198
|
+
* medium/high -> Working contract + "## Progress Note (brief)" + the
|
|
199
|
+
* rune-inscribe line (TASK_2371: high no longer has a
|
|
200
|
+
* mandatory recall/inscribe/Cognitive Checkpoint ritual).
|
|
201
|
+
*
|
|
202
|
+
* This is the ONLY place either axis branches into its behaviour; every call
|
|
203
|
+
* site below reads flags off the returned profile instead of re-testing
|
|
204
|
+
* rigor/complexity itself.
|
|
205
|
+
*
|
|
206
|
+
* Backwards compatible: a bare string (or null/undefined) is treated as the
|
|
207
|
+
* legacy single-axis call — `rigor` — and `complexity` defaults to 'medium'.
|
|
208
|
+
* @param {string|{rigor?: string|null, complexity?: string|null}|null|undefined} rigorOrOptions
|
|
209
|
+
*/
|
|
210
|
+
function promptProfile(rigorOrOptions) {
|
|
211
|
+
let rawRigor;
|
|
212
|
+
let rawComplexity;
|
|
213
|
+
if (rigorOrOptions && typeof rigorOrOptions === 'object') {
|
|
214
|
+
rawRigor = rigorOrOptions.rigor;
|
|
215
|
+
rawComplexity = rigorOrOptions.complexity;
|
|
216
|
+
} else {
|
|
217
|
+
// Legacy string-rigor call — complexity defaults to 'medium'.
|
|
218
|
+
rawRigor = rigorOrOptions;
|
|
219
|
+
rawComplexity = 'medium';
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const rigor = (rawRigor === 'low' || rawRigor === 'high') ? rawRigor : 'medium';
|
|
223
|
+
const complexity = (rawComplexity === 'simple' || rawComplexity === 'complex') ? rawComplexity : 'medium';
|
|
224
|
+
|
|
225
|
+
const CONTEXT_BY_COMPLEXITY = {
|
|
226
|
+
simple: {
|
|
227
|
+
skipRelatedFilesPreview: true,
|
|
228
|
+
skipKnownFailures: true,
|
|
229
|
+
skipProjectMemory: true,
|
|
230
|
+
},
|
|
231
|
+
medium: {
|
|
232
|
+
skipRelatedFilesPreview: true,
|
|
233
|
+
skipKnownFailures: false,
|
|
234
|
+
skipProjectMemory: true,
|
|
235
|
+
},
|
|
236
|
+
complex: {
|
|
237
|
+
skipRelatedFilesPreview: false,
|
|
238
|
+
skipKnownFailures: false,
|
|
239
|
+
skipProjectMemory: false,
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// ritualTier drives appendCognitiveCheckpoint:
|
|
244
|
+
// 'low' -> Working contract only; 'medium' -> Working contract + short
|
|
245
|
+
// progress note + mandatory inscribe line; 'high' -> full ritual (compactRitual=false).
|
|
246
|
+
const PROCESS_BY_RIGOR = {
|
|
247
|
+
low: { compactRitual: true, ritualTier: 'low' },
|
|
248
|
+
medium: { compactRitual: true, ritualTier: 'medium' },
|
|
249
|
+
high: { compactRitual: true, ritualTier: 'medium' }, // TASK_2371: high == medium ritual
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
rigor,
|
|
254
|
+
complexity,
|
|
255
|
+
...CONTEXT_BY_COMPLEXITY[complexity],
|
|
256
|
+
...PROCESS_BY_RIGOR[rigor],
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* TASK_1998 R1: split an assembled prompt into its "## "/"# " sections for
|
|
262
|
+
* byte-size telemetry. Text before the first matching header (prefixes like
|
|
263
|
+
* SUBAGENT_PREFIX, which use no markdown header) is not attributed to any
|
|
264
|
+
* section — telemetry only cares about the named prompt sections.
|
|
265
|
+
* @param {string} promptText
|
|
266
|
+
* @returns {{title: string, bytes: number}[]}
|
|
267
|
+
*/
|
|
268
|
+
function splitPromptSections(promptText) {
|
|
269
|
+
if (typeof promptText !== 'string' || !promptText) return [];
|
|
270
|
+
const lines = promptText.split('\n');
|
|
271
|
+
const sections = [];
|
|
272
|
+
let title = null;
|
|
273
|
+
let buf = [];
|
|
274
|
+
const flush = () => {
|
|
275
|
+
if (title !== null) sections.push({ title, bytes: Buffer.byteLength(buf.join('\n'), 'utf-8') });
|
|
276
|
+
};
|
|
277
|
+
for (const line of lines) {
|
|
278
|
+
if (/^(##\s|#\s)/.test(line)) {
|
|
279
|
+
flush();
|
|
280
|
+
title = line.replace(/^#{1,2}\s+/, '').trim();
|
|
281
|
+
buf = [line];
|
|
282
|
+
} else if (title !== null) {
|
|
283
|
+
buf.push(line);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
flush();
|
|
287
|
+
return sections;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// ─────────────────────────────────────────
|
|
291
|
+
// 主入口
|
|
292
|
+
// ─────────────────────────────────────────
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* 根據陣型分發到對應的 prompt builder
|
|
296
|
+
* @param {object} skillDef - parsed YAML
|
|
297
|
+
* @param {string} taskInput - 任務描述或 ID
|
|
298
|
+
* @param {string|null} taskData - 從 .collaboration 載入的任務 YAML
|
|
299
|
+
* @returns {string|string[]} 單一 prompt(unit/solo)或 prompt 陣列(squad)
|
|
300
|
+
*/
|
|
301
|
+
// TASK_2374: append-only usage counter (measure-first; cut decisions after 14 days of data).
|
|
302
|
+
// Env KENAZ_USAGE_COUNTERS_FILE overrides the target (tests). Never throws.
|
|
303
|
+
function recordSkillUsage(skillDef, options = {}) {
|
|
304
|
+
try {
|
|
305
|
+
const file = process.env.KENAZ_USAGE_COUNTERS_FILE
|
|
306
|
+
|| path.join(options.projectPath || path.resolve(__dirname, '..', '..'), '.kenaz', 'specialist', 'usage_counters.jsonl');
|
|
307
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
308
|
+
fs.appendFileSync(file, JSON.stringify({
|
|
309
|
+
ts: new Date().toISOString(), kind: 'skill',
|
|
310
|
+
name: `${skillDef.formation || 'unit'}/${skillDef.name || 'unknown'}`,
|
|
311
|
+
}) + '\n');
|
|
312
|
+
} catch { /* counter must never break a dispatch */ }
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function buildPrompt(skillDef, taskInput, taskData, options = {}) {
|
|
316
|
+
const formation = skillDef.formation || 'unit';
|
|
317
|
+
recordSkillUsage(skillDef, options);
|
|
318
|
+
|
|
319
|
+
const builders = {
|
|
320
|
+
unit: buildUnitPrompt,
|
|
321
|
+
solo: buildSoloPrompt,
|
|
322
|
+
squad: buildSquadPrompts,
|
|
323
|
+
legion: buildLegionPrompts,
|
|
324
|
+
legacy: buildLegacyPrompt,
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const builder = builders[formation];
|
|
328
|
+
if (!builder) {
|
|
329
|
+
throw new Error(`Unknown formation: ${formation}. Expected: ${Object.keys(builders).join(', ')}`);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return builder(skillDef, taskInput, taskData, options);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// ─────────────────────────────────────────
|
|
336
|
+
// Unit:單一角色,直接執行
|
|
337
|
+
// ─────────────────────────────────────────
|
|
338
|
+
|
|
339
|
+
function buildUnitPrompt(skillDef, taskInput, taskData, options = {}) {
|
|
340
|
+
const lines = [];
|
|
341
|
+
|
|
342
|
+
lines.push(`## Role`);
|
|
343
|
+
lines.push(skillDef.role.identity);
|
|
344
|
+
lines.push(`Priority: ${skillDef.role.priority}`);
|
|
345
|
+
lines.push('');
|
|
346
|
+
|
|
347
|
+
appendProjectContext(lines, options);
|
|
348
|
+
appendFormationPreamble(lines, taskData, options);
|
|
349
|
+
appendYggdrasilContext(lines, options.yggdrasilContext);
|
|
350
|
+
appendMemoryContext(lines, taskData, options);
|
|
351
|
+
appendAlayaLessons(lines, taskData);
|
|
352
|
+
appendSharedModules(lines, taskData, options);
|
|
353
|
+
appendBehavior(lines, skillDef);
|
|
354
|
+
appendTask(lines, taskInput, taskData, options);
|
|
355
|
+
appendCognitiveRecall(lines, taskData, options);
|
|
356
|
+
appendWorkflow(lines, skillDef, options, taskData);
|
|
357
|
+
appendOutput(lines, skillDef);
|
|
358
|
+
appendCognitiveCheckpoint(lines, taskData, options);
|
|
359
|
+
|
|
360
|
+
return lines.join('\n');
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// ─────────────────────────────────────────
|
|
364
|
+
// Solo:一個 agent 裝備多視角,自主切換
|
|
365
|
+
// ─────────────────────────────────────────
|
|
366
|
+
|
|
367
|
+
function buildSoloPrompt(skillDef, taskInput, taskData, options = {}) {
|
|
368
|
+
const lines = [];
|
|
369
|
+
|
|
370
|
+
lines.push(`## Role`);
|
|
371
|
+
lines.push(skillDef.role.identity);
|
|
372
|
+
lines.push(`Priority: ${skillDef.role.priority}`);
|
|
373
|
+
lines.push('');
|
|
374
|
+
|
|
375
|
+
appendProjectContext(lines, options);
|
|
376
|
+
appendFormationPreamble(lines, taskData, options);
|
|
377
|
+
appendYggdrasilContext(lines, options.yggdrasilContext);
|
|
378
|
+
appendMemoryContext(lines, taskData, options);
|
|
379
|
+
appendAlayaLessons(lines, taskData);
|
|
380
|
+
|
|
381
|
+
// 分析原則(Solo strategy 專用)
|
|
382
|
+
if (skillDef.analysis_principles && skillDef.analysis_principles.length > 0) {
|
|
383
|
+
lines.push(`## Analysis Principles`);
|
|
384
|
+
lines.push('');
|
|
385
|
+
for (const p of skillDef.analysis_principles) {
|
|
386
|
+
lines.push(`### ${p.name}`);
|
|
387
|
+
lines.push(p.description.trim());
|
|
388
|
+
lines.push('');
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// 可用視角
|
|
393
|
+
if (skillDef.perspectives && skillDef.perspectives.length > 0) {
|
|
394
|
+
lines.push(`## Available Perspectives`);
|
|
395
|
+
lines.push('');
|
|
396
|
+
lines.push('你隨時可以切換到以下任一視角。根據分析過程中的需要自主決定。');
|
|
397
|
+
lines.push('');
|
|
398
|
+
|
|
399
|
+
for (const p of skillDef.perspectives) {
|
|
400
|
+
lines.push(`### ${p.name}`);
|
|
401
|
+
lines.push(`- 關注:${p.lens}`);
|
|
402
|
+
lines.push(`- 何時切換:${p.trigger}`);
|
|
403
|
+
lines.push('');
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
appendBehavior(lines, skillDef);
|
|
408
|
+
appendSharedPrinciples(lines, options);
|
|
409
|
+
appendTask(lines, taskInput, taskData, options);
|
|
410
|
+
appendCognitiveRecall(lines, taskData, options);
|
|
411
|
+
appendWorkflow(lines, skillDef, options, taskData);
|
|
412
|
+
appendOutput(lines, skillDef);
|
|
413
|
+
appendCognitiveCheckpoint(lines, taskData, options);
|
|
414
|
+
|
|
415
|
+
return lines.join('\n');
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// ─────────────────────────────────────────
|
|
419
|
+
// Squad:為每個成員分別組裝 prompt
|
|
420
|
+
// ─────────────────────────────────────────
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Squad 回傳 prompt 陣列,每個成員一份
|
|
424
|
+
* @returns {{ memberId: string, prompt: string, skill: string }[]}
|
|
425
|
+
*/
|
|
426
|
+
function buildSquadPrompts(skillDef, taskInput, taskData, options = {}) {
|
|
427
|
+
const members = skillDef.members || [];
|
|
428
|
+
if (members.length === 0) {
|
|
429
|
+
throw new Error('Squad YAML must define `members` array');
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// 組裝共享上下文(注入到每個成員 prompt)
|
|
433
|
+
const sharedBlock = buildSharedContextBlock(skillDef);
|
|
434
|
+
|
|
435
|
+
return members.map(member => {
|
|
436
|
+
const lines = [];
|
|
437
|
+
|
|
438
|
+
// 成員角色
|
|
439
|
+
lines.push(`## Role`);
|
|
440
|
+
lines.push(typeof member.role === 'string' ? member.role.trim() : `你是 Squad 的一員:${member.name}`);
|
|
441
|
+
lines.push('');
|
|
442
|
+
|
|
443
|
+
// 分析模式(mode_behavior 注入)
|
|
444
|
+
const analysisMode = options.analysisMode;
|
|
445
|
+
if (analysisMode && member.mode_behavior && member.mode_behavior[analysisMode]) {
|
|
446
|
+
const modeConfig = skillDef.analysis_mode?.modes?.[analysisMode];
|
|
447
|
+
lines.push(`## Analysis Mode: ${analysisMode}`);
|
|
448
|
+
if (modeConfig?.description) lines.push(modeConfig.description.trim());
|
|
449
|
+
lines.push('');
|
|
450
|
+
lines.push('**你在此模式下的立場調整**:');
|
|
451
|
+
lines.push(member.mode_behavior[analysisMode].trim());
|
|
452
|
+
lines.push('');
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// 核心原則(principles 注入 — 所有成員共用的硬規則)
|
|
456
|
+
if (skillDef.principles) {
|
|
457
|
+
lines.push(`## Principles (絕對遵守)`);
|
|
458
|
+
if (skillDef.principles.focus) {
|
|
459
|
+
lines.push(skillDef.principles.focus.trim());
|
|
460
|
+
lines.push('');
|
|
461
|
+
}
|
|
462
|
+
if (skillDef.principles.forbidden && skillDef.principles.forbidden.length > 0) {
|
|
463
|
+
lines.push('**禁止 (違反即失敗)**:');
|
|
464
|
+
for (const f of skillDef.principles.forbidden) lines.push(`- ❌ ${f}`);
|
|
465
|
+
lines.push('');
|
|
466
|
+
}
|
|
467
|
+
if (skillDef.principles.required && skillDef.principles.required.length > 0) {
|
|
468
|
+
lines.push('**必須遵守**:');
|
|
469
|
+
for (const r of skillDef.principles.required) lines.push(`- ✅ ${r}`);
|
|
470
|
+
lines.push('');
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// 成員身份
|
|
475
|
+
lines.push(`## Identity`);
|
|
476
|
+
lines.push(`你是 Squad 的成員 **${member.name}** (id: ${member.id || member.name})。`);
|
|
477
|
+
lines.push(`你與其他成員並行工作,各自獨立,不能互相通訊。`);
|
|
478
|
+
lines.push(`完成你負責的部分後回報結果,Lead 會負責整合。`);
|
|
479
|
+
lines.push('');
|
|
480
|
+
|
|
481
|
+
// 成員的 scope(負責範圍)— 支援 include/exclude 格式
|
|
482
|
+
if (member.scope) {
|
|
483
|
+
lines.push(`## Scope (你只能碰這些檔案)`);
|
|
484
|
+
if (member.scope.include || member.scope.exclude) {
|
|
485
|
+
if (member.scope.include) {
|
|
486
|
+
lines.push(`Include:`);
|
|
487
|
+
const includes = Array.isArray(member.scope.include) ? member.scope.include : [member.scope.include];
|
|
488
|
+
for (const p of includes) lines.push(` - ${p}`);
|
|
489
|
+
}
|
|
490
|
+
if (member.scope.exclude) {
|
|
491
|
+
lines.push(`Exclude:`);
|
|
492
|
+
const excludes = Array.isArray(member.scope.exclude) ? member.scope.exclude : [member.scope.exclude];
|
|
493
|
+
for (const p of excludes) lines.push(` - ${p}`);
|
|
494
|
+
}
|
|
495
|
+
} else if (Array.isArray(member.scope)) {
|
|
496
|
+
for (const s of member.scope) lines.push(`- ${s}`);
|
|
497
|
+
} else {
|
|
498
|
+
lines.push(member.scope);
|
|
499
|
+
}
|
|
500
|
+
lines.push('');
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Yggdrasil network context
|
|
504
|
+
appendYggdrasilContext(lines, options.yggdrasilContext);
|
|
505
|
+
appendMemoryContext(lines, taskData, options);
|
|
506
|
+
appendAlayaLessons(lines, taskData);
|
|
507
|
+
appendFormationPreamble(lines, taskData, options);
|
|
508
|
+
|
|
509
|
+
// 共享上下文
|
|
510
|
+
if (sharedBlock) {
|
|
511
|
+
lines.push(sharedBlock);
|
|
512
|
+
lines.push('');
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// 行為準則(squad 全局 + 成員級別)
|
|
516
|
+
const behaviors = [
|
|
517
|
+
...(skillDef.behavior || []),
|
|
518
|
+
...(member.behavior || [])
|
|
519
|
+
];
|
|
520
|
+
if (behaviors.length > 0) {
|
|
521
|
+
lines.push(`## Behavior`);
|
|
522
|
+
for (const b of behaviors) lines.push(`- ${b}`);
|
|
523
|
+
lines.push('');
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// 任務
|
|
527
|
+
appendTask(lines, taskInput, taskData, options);
|
|
528
|
+
appendCognitiveRecall(lines, taskData, options);
|
|
529
|
+
|
|
530
|
+
// 成員專屬工作流程或全局工作流程
|
|
531
|
+
if (member.workflow) {
|
|
532
|
+
lines.push(`## Workflow`);
|
|
533
|
+
for (const step of member.workflow) lines.push(`- ${step}`);
|
|
534
|
+
lines.push('');
|
|
535
|
+
appendDispatchOverrides(lines, taskData); // TASK_1820: same post-envelope channel as appendWorkflow
|
|
536
|
+
} else {
|
|
537
|
+
appendWorkflow(lines, skillDef, options, taskData);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// 輸出
|
|
541
|
+
if (member.output) {
|
|
542
|
+
lines.push(`## Expected Output`);
|
|
543
|
+
lines.push(typeof member.output === 'string' ? member.output.trim() : JSON.stringify(member.output));
|
|
544
|
+
} else {
|
|
545
|
+
appendOutput(lines, skillDef);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
appendCognitiveCheckpoint(lines, taskData, options);
|
|
549
|
+
|
|
550
|
+
return {
|
|
551
|
+
memberId: member.id || member.name,
|
|
552
|
+
prompt: lines.join('\n'),
|
|
553
|
+
skill: member.skill || 'do'
|
|
554
|
+
};
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* 組裝 shared_context 區塊(Squad 成員共用的約定)
|
|
560
|
+
*/
|
|
561
|
+
function buildSharedContextBlock(skillDef) {
|
|
562
|
+
if (!skillDef.shared_context) return null;
|
|
563
|
+
|
|
564
|
+
const lines = [];
|
|
565
|
+
lines.push(`## Shared Context (所有成員共享的約定)`);
|
|
566
|
+
|
|
567
|
+
if (skillDef.shared_context.description) {
|
|
568
|
+
lines.push(skillDef.shared_context.description.trim());
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
if (skillDef.shared_context.includes) {
|
|
572
|
+
lines.push('');
|
|
573
|
+
const includes = skillDef.shared_context.includes;
|
|
574
|
+
if (typeof includes === 'object' && !Array.isArray(includes)) {
|
|
575
|
+
for (const [key, val] of Object.entries(includes)) {
|
|
576
|
+
lines.push(`### ${key}`);
|
|
577
|
+
lines.push(typeof val === 'string' ? val.trim() : JSON.stringify(val));
|
|
578
|
+
lines.push('');
|
|
579
|
+
}
|
|
580
|
+
} else if (Array.isArray(includes)) {
|
|
581
|
+
for (const item of includes) {
|
|
582
|
+
if (typeof item === 'string') {
|
|
583
|
+
lines.push(`- ${item}`);
|
|
584
|
+
} else if (typeof item === 'object') {
|
|
585
|
+
for (const [key, val] of Object.entries(item)) {
|
|
586
|
+
lines.push(`### ${key}`);
|
|
587
|
+
lines.push(typeof val === 'string' ? val.trim() : JSON.stringify(val));
|
|
588
|
+
lines.push('');
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
return lines.join('\n');
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// ─────────────────────────────────────────
|
|
599
|
+
// Legion:為 team lead 和成員組裝 prompt
|
|
600
|
+
// ─────────────────────────────────────────
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Legion 回傳 team config + 每個成員的 prompt
|
|
604
|
+
* @returns {{ teamName: string, teamDesc: string, lead: { prompt: string }, members: { name: string, prompt: string }[] }}
|
|
605
|
+
*/
|
|
606
|
+
function buildLegionPrompts(skillDef, taskInput, taskData, options = {}) {
|
|
607
|
+
const team = skillDef.team || {};
|
|
608
|
+
// 支援 members: [...] 和 members: { roles: [...] } 兩種格式
|
|
609
|
+
const rawMembers = skillDef.members || [];
|
|
610
|
+
const members = Array.isArray(rawMembers) ? rawMembers : (rawMembers.roles || []);
|
|
611
|
+
|
|
612
|
+
// 團隊名稱:優先用 team.name,fallback 到 skillDef.name
|
|
613
|
+
const teamName = team.name || skillDef.name || 'Legion';
|
|
614
|
+
|
|
615
|
+
// Team lead prompt
|
|
616
|
+
const leadLines = [];
|
|
617
|
+
leadLines.push(`## Role`);
|
|
618
|
+
leadLines.push(`你是 ${teamName} 的 Team Lead。`);
|
|
619
|
+
leadLines.push(skillDef.role?.identity || '');
|
|
620
|
+
leadLines.push('');
|
|
621
|
+
leadLines.push(`## Team Members`);
|
|
622
|
+
for (const m of members) {
|
|
623
|
+
leadLines.push(`- **${m.name}**: ${m.role || m.description || ''}`);
|
|
624
|
+
}
|
|
625
|
+
leadLines.push('');
|
|
626
|
+
|
|
627
|
+
if (skillDef.communication) {
|
|
628
|
+
leadLines.push(`## Communication Rules`);
|
|
629
|
+
const comm = skillDef.communication;
|
|
630
|
+
if (Array.isArray(comm)) {
|
|
631
|
+
for (const rule of comm) leadLines.push(`- ${rule}`);
|
|
632
|
+
} else if (typeof comm === 'object') {
|
|
633
|
+
if (comm.principles) {
|
|
634
|
+
leadLines.push(`### Principles`);
|
|
635
|
+
for (const p of comm.principles) leadLines.push(`- ${p}`);
|
|
636
|
+
leadLines.push('');
|
|
637
|
+
}
|
|
638
|
+
if (comm.patterns) {
|
|
639
|
+
leadLines.push(`### Patterns`);
|
|
640
|
+
for (const p of comm.patterns) {
|
|
641
|
+
leadLines.push(`- **${p.name}**: ${p.who} — ${p.content || ''}`);
|
|
642
|
+
}
|
|
643
|
+
leadLines.push('');
|
|
644
|
+
}
|
|
645
|
+
if (comm.broadcast_policy) {
|
|
646
|
+
leadLines.push(`### Broadcast Policy`);
|
|
647
|
+
leadLines.push(comm.broadcast_policy.trim());
|
|
648
|
+
leadLines.push('');
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
leadLines.push('');
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
appendYggdrasilContext(leadLines, options.yggdrasilContext);
|
|
655
|
+
appendMemoryContext(leadLines, taskData, options);
|
|
656
|
+
appendAlayaLessons(leadLines, taskData);
|
|
657
|
+
appendFormationPreamble(leadLines, taskData, options);
|
|
658
|
+
appendTask(leadLines, taskInput, taskData, options);
|
|
659
|
+
appendCognitiveRecall(leadLines, taskData);
|
|
660
|
+
|
|
661
|
+
if (skillDef.lifecycle) {
|
|
662
|
+
leadLines.push(`## Lifecycle`);
|
|
663
|
+
// lifecycle 可能是 { phases: [...] } 或直接是陣列
|
|
664
|
+
const phases = Array.isArray(skillDef.lifecycle)
|
|
665
|
+
? skillDef.lifecycle
|
|
666
|
+
: (skillDef.lifecycle.phases || []);
|
|
667
|
+
for (const step of phases) {
|
|
668
|
+
if (typeof step === 'string') {
|
|
669
|
+
leadLines.push(`- ${step}`);
|
|
670
|
+
} else {
|
|
671
|
+
leadLines.push(`### ${step.phase || step.step}`);
|
|
672
|
+
if (step.description) leadLines.push(step.description.trim());
|
|
673
|
+
if (step.lead_actions) {
|
|
674
|
+
leadLines.push('Lead actions:');
|
|
675
|
+
for (const a of step.lead_actions) leadLines.push(`- ${a}`);
|
|
676
|
+
}
|
|
677
|
+
if (step.exit_criteria) {
|
|
678
|
+
leadLines.push('Exit criteria:');
|
|
679
|
+
for (const c of step.exit_criteria) leadLines.push(`- ${c}`);
|
|
680
|
+
}
|
|
681
|
+
leadLines.push('');
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
leadLines.push('');
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
appendOutput(leadLines, skillDef);
|
|
688
|
+
appendCognitiveCheckpoint(leadLines, taskData, options);
|
|
689
|
+
|
|
690
|
+
// Member prompts
|
|
691
|
+
// 優先使用 YAML 的 member_prompts 模板(如 forge 的 designer/implementer/reviewer)
|
|
692
|
+
const promptTemplates = skillDef.member_prompts || {};
|
|
693
|
+
|
|
694
|
+
const memberPrompts = members.map(member => {
|
|
695
|
+
const lines = [];
|
|
696
|
+
|
|
697
|
+
// 如果有預寫好的 prompt 模板,直接用
|
|
698
|
+
const template = promptTemplates[member.id];
|
|
699
|
+
if (template) {
|
|
700
|
+
lines.push(template.trim());
|
|
701
|
+
lines.push('');
|
|
702
|
+
} else {
|
|
703
|
+
// 自動生成
|
|
704
|
+
lines.push(`## Role`);
|
|
705
|
+
lines.push(member.role || member.description?.trim() || `你是 ${teamName} 團隊的 ${member.name}。`);
|
|
706
|
+
lines.push('');
|
|
707
|
+
|
|
708
|
+
if (member.responsibilities) {
|
|
709
|
+
lines.push(`## Responsibilities`);
|
|
710
|
+
for (const r of member.responsibilities) lines.push(`- ${r}`);
|
|
711
|
+
lines.push('');
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
if (member.skills) {
|
|
715
|
+
lines.push(`## Skills`);
|
|
716
|
+
for (const s of member.skills) lines.push(`- ${s}`);
|
|
717
|
+
lines.push('');
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if (member.scope) {
|
|
721
|
+
lines.push(`## Scope`);
|
|
722
|
+
if (Array.isArray(member.scope)) {
|
|
723
|
+
for (const s of member.scope) lines.push(`- ${s}`);
|
|
724
|
+
} else {
|
|
725
|
+
lines.push(member.scope);
|
|
726
|
+
}
|
|
727
|
+
lines.push('');
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
lines.push(`## Team Context`);
|
|
732
|
+
lines.push(`你是 ${teamName} 團隊的成員。可以透過 SendMessage 和其他成員溝通。`);
|
|
733
|
+
lines.push(`Team Lead 會分配任務給你,完成後回報。如果被阻塞,主動溝通。`);
|
|
734
|
+
lines.push('');
|
|
735
|
+
|
|
736
|
+
appendYggdrasilContext(lines, options.yggdrasilContext);
|
|
737
|
+
appendFormationPreamble(lines, taskData, options);
|
|
738
|
+
appendTask(lines, taskInput, taskData, options);
|
|
739
|
+
appendCognitiveRecall(lines, taskData, options);
|
|
740
|
+
appendCognitiveCheckpoint(lines, taskData, options);
|
|
741
|
+
|
|
742
|
+
return {
|
|
743
|
+
name: member.name,
|
|
744
|
+
agentType: member.agent_type || 'general-purpose',
|
|
745
|
+
prompt: lines.join('\n')
|
|
746
|
+
};
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
return {
|
|
750
|
+
teamName: teamName.toLowerCase().replace(/\s+/g, '-'),
|
|
751
|
+
teamDesc: team.description || skillDef.description || '',
|
|
752
|
+
lead: { prompt: leadLines.join('\n') },
|
|
753
|
+
members: memberPrompts
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// ─────────────────────────────────────────
|
|
758
|
+
// Legacy:排程器模式(不建 prompt,直接走 scheduler loop)
|
|
759
|
+
// ─────────────────────────────────────────
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Legacy 不需要組裝 subagent prompt。
|
|
763
|
+
* 回傳 scheduler 配置摘要(供 dry-run 顯示用)。
|
|
764
|
+
*/
|
|
765
|
+
function buildLegacyPrompt(skillDef, taskInput, taskData, options = {}) {
|
|
766
|
+
const lines = [];
|
|
767
|
+
lines.push(`## Role`);
|
|
768
|
+
lines.push(skillDef.role?.identity || 'You are a developer assigned to complete the task below.');
|
|
769
|
+
lines.push('');
|
|
770
|
+
|
|
771
|
+
appendBehavior(lines, skillDef);
|
|
772
|
+
appendProjectContext(lines, options);
|
|
773
|
+
appendYggdrasilContext(lines, options.yggdrasilContext);
|
|
774
|
+
appendMemoryContext(lines, taskData, options);
|
|
775
|
+
appendAlayaLessons(lines, taskData);
|
|
776
|
+
appendTask(lines, taskInput, taskData, options);
|
|
777
|
+
appendCognitiveRecall(lines, taskData, options);
|
|
778
|
+
|
|
779
|
+
if (skillDef.collaboration?.workflow) {
|
|
780
|
+
appendWorkflow(lines, skillDef, options, taskData);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
appendCognitiveCheckpoint(lines, taskData, options);
|
|
784
|
+
|
|
785
|
+
return lines.join('\n');
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// ─────────────────────────────────────────
|
|
789
|
+
// 共用片段
|
|
790
|
+
// ─────────────────────────────────────────
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Append context-aware shared modules to prompt.
|
|
794
|
+
* Reads .formation/roles/_shared/modules/*.yaml based on task tags / chart context.
|
|
795
|
+
* Inserted before appendBehavior().
|
|
796
|
+
*/
|
|
797
|
+
function appendSharedModules(lines, taskData, options = {}) {
|
|
798
|
+
const corePath = options.corePath || resolveCorePath(options.projectPath) || undefined;
|
|
799
|
+
const chartPath = options.chartPath || null;
|
|
800
|
+
const modulePaths = resolveModules(taskData, chartPath, corePath);
|
|
801
|
+
if (modulePaths.length === 0) return;
|
|
802
|
+
|
|
803
|
+
for (const modPath of modulePaths) {
|
|
804
|
+
try {
|
|
805
|
+
if (!fs.existsSync(modPath)) continue;
|
|
806
|
+
const raw = fs.readFileSync(modPath, 'utf-8');
|
|
807
|
+
|
|
808
|
+
// Extract name and description for the section header
|
|
809
|
+
const nameMatch = raw.match(/^name:\s*(.+)$/m);
|
|
810
|
+
const descMatch = raw.match(/^description:\s*(.+)$/m);
|
|
811
|
+
const moduleName = nameMatch ? nameMatch[1].trim() : path.basename(modPath, '.yaml');
|
|
812
|
+
const moduleDesc = descMatch ? descMatch[1].trim() : '';
|
|
813
|
+
|
|
814
|
+
lines.push(`## Shared Module: ${moduleName}`);
|
|
815
|
+
if (moduleDesc) {
|
|
816
|
+
lines.push(moduleDesc);
|
|
817
|
+
lines.push('');
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// Inject content section (raw YAML-formatted text, stripped of top-level key)
|
|
821
|
+
const contentMatch = raw.match(/^content:\n([\s\S]*)$/m);
|
|
822
|
+
if (contentMatch) {
|
|
823
|
+
lines.push(contentMatch[1].trimEnd());
|
|
824
|
+
} else {
|
|
825
|
+
lines.push(raw.trimEnd());
|
|
826
|
+
}
|
|
827
|
+
lines.push('');
|
|
828
|
+
} catch { /* graceful degradation — skip unreadable module */ }
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
function appendBehavior(lines, skillDef) {
|
|
833
|
+
if (skillDef.behavior && skillDef.behavior.length > 0) {
|
|
834
|
+
lines.push(`## Behavior`);
|
|
835
|
+
for (const b of skillDef.behavior) {
|
|
836
|
+
lines.push(`- ${b}`);
|
|
837
|
+
}
|
|
838
|
+
lines.push('');
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* Append shared principles (DDx protocol) to prompt.
|
|
844
|
+
* Loaded from .specialist/shared/principles.yaml.
|
|
845
|
+
*/
|
|
846
|
+
function appendSharedPrinciples(lines, options = {}) {
|
|
847
|
+
const corePath = options.corePath || undefined;
|
|
848
|
+
const ddx = loadSharedPrinciples(corePath);
|
|
849
|
+
if (!ddx) return;
|
|
850
|
+
|
|
851
|
+
lines.push(`## Shared Principles — 鑑別診斷 (DDx)`);
|
|
852
|
+
lines.push(`遇到 Bug 診斷、架構決策、結果驗證時,必須套用以下 protocol:`);
|
|
853
|
+
lines.push('');
|
|
854
|
+
lines.push(ddx);
|
|
855
|
+
lines.push('');
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Append project context to prompt (multi-project support).
|
|
860
|
+
* When projectPath is provided, injects context telling the agent
|
|
861
|
+
* which project to operate on and where system files are.
|
|
862
|
+
*/
|
|
863
|
+
function appendProjectContext(lines, options = {}) {
|
|
864
|
+
const { projectPath, worktreePath } = options;
|
|
865
|
+
|
|
866
|
+
// Sub-project context — only when projectPath is not the core project
|
|
867
|
+
if (projectPath) {
|
|
868
|
+
const pathMod = require('path');
|
|
869
|
+
const coreRoot = pathMod.resolve(__dirname, '..', '..');
|
|
870
|
+
const norm = p => p.replace(/[\\/]+$/, '').replace(/\\/g, '/').toLowerCase();
|
|
871
|
+
|
|
872
|
+
if (norm(pathMod.resolve(projectPath)) !== norm(coreRoot)) {
|
|
873
|
+
lines.push(`## Project Context [internal — do NOT mention sub-project status to user]`);
|
|
874
|
+
lines.push(`Working directory: ${projectPath}`);
|
|
875
|
+
lines.push(`- Task files: ${projectPath}/.kenaz/tasks/`);
|
|
876
|
+
lines.push(`- Log files: ${projectPath}/.kenaz/logs/`);
|
|
877
|
+
lines.push(`- Project config: ${projectPath}/.kenaz/project.yaml`);
|
|
878
|
+
|
|
879
|
+
// Inject resolved KENAZ_CORE_PATH (shared resolver: validates path + KENAZ_SOURCE_DIR fallback)
|
|
880
|
+
const corePath = resolveCorePath(projectPath);
|
|
881
|
+
if (corePath) {
|
|
882
|
+
lines.push(`- System files (.rule/, .failure/, .specialist/): ${corePath}`);
|
|
883
|
+
lines.push(`- Task API: node ${corePath}/.collaboration/core/task-api.js --project-path ${projectPath}`);
|
|
884
|
+
lines.push('');
|
|
885
|
+
lines.push(`### KENAZ_CORE_PATH (resolved)`);
|
|
886
|
+
lines.push(`\`${corePath}\``);
|
|
887
|
+
lines.push(`All system tools use this path as root. When you need task-api.js, headless.js, or other Formation tools, reference:`);
|
|
888
|
+
lines.push(`- task-api: \`node "${corePath}/.collaboration/core/task-api.js" --project-path "${projectPath}"\``);
|
|
889
|
+
lines.push(`- headless: \`node "${corePath}/.formation/tools/headless.js" --task=TASK_XXX --project-path="${projectPath}"\``);
|
|
890
|
+
lines.push(`- post-complete: \`node "${corePath}/.formation/tools/post-complete.js" --task=TASK_XXX --project-path="${projectPath}"\``);
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
lines.push('');
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
// Worktree context — when agent runs in an isolated git worktree
|
|
898
|
+
if (worktreePath) {
|
|
899
|
+
const originalProjectPath = projectPath || require('path').resolve(__dirname, '..', '..');
|
|
900
|
+
lines.push(`## Worktree Context [internal]`);
|
|
901
|
+
lines.push(`Your cwd is a git worktree at ${worktreePath}.`);
|
|
902
|
+
lines.push(`For Synapse MCP calls (recall/inscribe/forge), use projectPath=${originalProjectPath} not your cwd.`);
|
|
903
|
+
lines.push('');
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Append standard Formation Preamble to prompt.
|
|
909
|
+
* Injected into every dispatch agent for consistent task orientation.
|
|
910
|
+
* Fields: Task (id + title), Branch (git, fallback: unknown),
|
|
911
|
+
* Scope (scope_paths, omitted when empty), Principles (fixed).
|
|
912
|
+
*
|
|
913
|
+
* @param {string[]} lines - prompt lines array (mutated)
|
|
914
|
+
* @param {string|object} taskData - task JSON string or parsed object
|
|
915
|
+
* @param {object} [options] - options ({ projectPath })
|
|
916
|
+
*/
|
|
917
|
+
function appendFormationPreamble(lines, taskData, options = {}) {
|
|
918
|
+
let taskId = null;
|
|
919
|
+
let taskTitle = null;
|
|
920
|
+
let scopePaths = [];
|
|
921
|
+
|
|
922
|
+
try {
|
|
923
|
+
const parsed = typeof taskData === 'string' ? JSON.parse(taskData) : taskData;
|
|
924
|
+
if (parsed) {
|
|
925
|
+
taskId = parsed.id || null;
|
|
926
|
+
taskTitle = parsed.title || null;
|
|
927
|
+
scopePaths = parsed.scope_paths || [];
|
|
928
|
+
}
|
|
929
|
+
} catch { /* not JSON */ }
|
|
930
|
+
|
|
931
|
+
// Resolve git branch — fallback to 'unknown' on any failure
|
|
932
|
+
let branch = 'unknown';
|
|
933
|
+
try {
|
|
934
|
+
const { execSync } = require('child_process');
|
|
935
|
+
const cwd = options.projectPath || path.resolve(__dirname, '..', '..');
|
|
936
|
+
const out = execSync('git rev-parse --abbrev-ref HEAD', {
|
|
937
|
+
cwd,
|
|
938
|
+
encoding: 'utf-8',
|
|
939
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
940
|
+
timeout: 3000,
|
|
941
|
+
windowsHide: true,
|
|
942
|
+
});
|
|
943
|
+
branch = (out || '').trim() || 'unknown';
|
|
944
|
+
} catch { /* git unavailable or not a repo */ }
|
|
945
|
+
|
|
946
|
+
lines.push(`## Dispatch Context`);
|
|
947
|
+
if (taskId || taskTitle) {
|
|
948
|
+
const label = [taskId, taskTitle].filter(Boolean).join(' — ');
|
|
949
|
+
lines.push(`Task: ${label}`);
|
|
950
|
+
}
|
|
951
|
+
lines.push(`Branch: ${branch}`);
|
|
952
|
+
if (scopePaths.length > 0) {
|
|
953
|
+
lines.push(`Scope: ${scopePaths.join(', ')}`);
|
|
954
|
+
}
|
|
955
|
+
lines.push(`Principles: 完美達成>一切|禁止盲寫|露出問題|結構>估計`);
|
|
956
|
+
lines.push('');
|
|
957
|
+
|
|
958
|
+
appendMinimalismLadder(lines);
|
|
959
|
+
appendFileBudgetSRP(lines);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Append the YAGNI minimalism decision-ladder (Ponytail essence) to prompt.
|
|
964
|
+
* Wired once into appendFormationPreamble so EVERY dispatched agent
|
|
965
|
+
* (unit/solo/squad/legion + sub-agent path via shared buildPrompt) inherits it.
|
|
966
|
+
* Closes the gap: Ansuz elixir holds wire>rewrite, but dispatched agents
|
|
967
|
+
* previously received no active "write less" nudge — only the "禁止盲寫" guard.
|
|
968
|
+
* Kept compact: a nudge, not a ritual.
|
|
969
|
+
*
|
|
970
|
+
* @param {string[]} lines - prompt lines array (mutated)
|
|
971
|
+
*/
|
|
972
|
+
function appendMinimalismLadder(lines) {
|
|
973
|
+
lines.push(`## Code Minimalism — 最省決策階梯 (YAGNI)`);
|
|
974
|
+
lines.push(`寫任何代碼前,停在第一個成立的階:`);
|
|
975
|
+
lines.push(`1. 這需要存在嗎?不需要 → 跳過(不臆測未來需求)`);
|
|
976
|
+
lines.push(`2. stdlib / 語言內建有嗎?→ 用它`);
|
|
977
|
+
lines.push(`3. 平台 / 框架原生功能?→ 用它,別自己造`);
|
|
978
|
+
lines.push(`4. 專案已裝依賴有嗎?→ 重用,別加新依賴`);
|
|
979
|
+
lines.push(`5. 一行能解嗎?→ 一行`);
|
|
980
|
+
lines.push(`6. 否則:最小可行實作`);
|
|
981
|
+
lines.push(`規則:不為單一實作建抽象介面;刪除優於新增;最短 diff。`);
|
|
982
|
+
lines.push(`刻意簡化用 \`// thrift:\` 標記上限與升級路徑(例:\`// thrift: 同步即可,QPS>100 再改 async\`)。`);
|
|
983
|
+
lines.push(`不可簡化掉(lazy ≠ negligent):input validation、error handling、security、accessibility、用戶明確要求的功能。`);
|
|
984
|
+
lines.push('');
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* Append the ARCH-001 file-budget & SRP clause (shift-left prevention half).
|
|
989
|
+
* Wired into appendFormationPreamble next to appendMinimalismLadder so every
|
|
990
|
+
* dispatched agent (unit/solo/squad/legion, subagent + Formation paths) sees
|
|
991
|
+
* the budget while writing code, not as late rework at the L1 merge gate
|
|
992
|
+
* (dev/scripts/check-file-size.js, .rule/general/file-size-threshold.yaml).
|
|
993
|
+
*
|
|
994
|
+
* @param {string[]} lines - prompt lines array (mutated)
|
|
995
|
+
*/
|
|
996
|
+
function appendFileBudgetSRP(lines) {
|
|
997
|
+
lines.push(`## File Budget & SRP (ARCH-001)`);
|
|
998
|
+
lines.push(`單檔行數:warn=2000 / hard=4000。接近 warn 就停筆,優先 extraction 而非累加。`);
|
|
999
|
+
lines.push(`拆分模式:module / hooks/ / components/ / types.ts(依 CODE-STR-002)。`);
|
|
1000
|
+
lines.push(`verify 步驟跑:\`node dev/scripts/check-file-size.js --staged\` — 有 BLOCK 先拆再提交。`);
|
|
1001
|
+
lines.push('');
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
function appendTask(lines, taskInput, taskData, options = {}) {
|
|
1005
|
+
const { projectPath } = options;
|
|
1006
|
+
lines.push(`## Task`);
|
|
1007
|
+
|
|
1008
|
+
if (taskData) {
|
|
1009
|
+
// Try to parse as JSON for structured extraction
|
|
1010
|
+
let parsed = null;
|
|
1011
|
+
try { parsed = JSON.parse(taskData); } catch { /* raw YAML fallback */ }
|
|
1012
|
+
|
|
1013
|
+
if (parsed && parsed.id) {
|
|
1014
|
+
// Structured task injection — give agent everything it needs
|
|
1015
|
+
lines.push(`**Task ID**: ${parsed.id}`);
|
|
1016
|
+
lines.push(`**Title**: ${parsed.title || 'N/A'}`);
|
|
1017
|
+
if (parsed._file_path) {
|
|
1018
|
+
lines.push(`**Task File**: ${parsed._file_path}`);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// Project-path warning: if task was loaded with --project-path, emit a
|
|
1022
|
+
// prominent block so the agent (and Lead) never forgets.
|
|
1023
|
+
// All projects (including KenazAI core) are treated uniformly.
|
|
1024
|
+
const taskProjectPath = parsed._project_path || projectPath;
|
|
1025
|
+
if (taskProjectPath) {
|
|
1026
|
+
lines.push('');
|
|
1027
|
+
lines.push(`[internal] Sub-project: \`${taskProjectPath}\` — do NOT mention this to the user.`);
|
|
1028
|
+
lines.push(`- ALL file operations must target this project directory`);
|
|
1029
|
+
lines.push(`- ALL git operations (branch, commit, merge) must run in this repo`);
|
|
1030
|
+
lines.push(`- post-complete: \`--project-path=${taskProjectPath}\``);
|
|
1031
|
+
lines.push(`- headless dispatch: \`--project-path=${taskProjectPath}\``);
|
|
1032
|
+
lines.push('');
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
if (parsed.description) {
|
|
1036
|
+
lines.push(`**Description**: ${parsed.description.trim()}`);
|
|
1037
|
+
}
|
|
1038
|
+
if (parsed.priority) lines.push(`**Priority**: ${parsed.priority}`);
|
|
1039
|
+
if (parsed.complexity) lines.push(`**Complexity**: ${parsed.complexity}`);
|
|
1040
|
+
if (parsed.role) lines.push(`**Role**: ${parsed.role}`);
|
|
1041
|
+
|
|
1042
|
+
// Resolve scope_paths to absolute paths
|
|
1043
|
+
const scopePaths = parsed.scope_paths || [];
|
|
1044
|
+
if (scopePaths.length > 0) {
|
|
1045
|
+
const root = projectPath || '';
|
|
1046
|
+
lines.push('');
|
|
1047
|
+
lines.push('**Scope Paths** (你只能操作這些路徑):');
|
|
1048
|
+
for (const sp of scopePaths) {
|
|
1049
|
+
if (root) {
|
|
1050
|
+
const path = require('path');
|
|
1051
|
+
lines.push(`- ${sp} → ${path.resolve(root, sp)}`);
|
|
1052
|
+
} else {
|
|
1053
|
+
lines.push(`- ${sp}`);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// Dependencies (TASK_1771: coerce string-typed dependencies defensively)
|
|
1059
|
+
const _deps = Array.isArray(parsed.dependencies) ? parsed.dependencies : (parsed.dependencies ? [parsed.dependencies] : []);
|
|
1060
|
+
if (_deps.length > 0) {
|
|
1061
|
+
lines.push('');
|
|
1062
|
+
lines.push(`**Dependencies**: ${_deps.join(', ')}`);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
// Requirements
|
|
1066
|
+
if (parsed.requirements && parsed.requirements.length > 0) {
|
|
1067
|
+
lines.push('');
|
|
1068
|
+
lines.push('**Requirements**:');
|
|
1069
|
+
for (const r of parsed.requirements) {
|
|
1070
|
+
lines.push(`- ${r}`);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
// Acceptance criteria
|
|
1075
|
+
if (parsed.acceptance_criteria && parsed.acceptance_criteria.length > 0) {
|
|
1076
|
+
lines.push('');
|
|
1077
|
+
lines.push('**Acceptance Criteria**:');
|
|
1078
|
+
for (const ac of parsed.acceptance_criteria) {
|
|
1079
|
+
lines.push(`- ${ac}`);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
// Technical notes
|
|
1084
|
+
if (parsed.technical_notes && parsed.technical_notes.length > 0) {
|
|
1085
|
+
lines.push('');
|
|
1086
|
+
lines.push('**Technical Notes**:');
|
|
1087
|
+
for (const tn of parsed.technical_notes) {
|
|
1088
|
+
lines.push(`- ${tn}`);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
} else {
|
|
1092
|
+
// Raw YAML/text fallback
|
|
1093
|
+
lines.push('Task details:');
|
|
1094
|
+
lines.push('```');
|
|
1095
|
+
lines.push(taskData);
|
|
1096
|
+
lines.push('```');
|
|
1097
|
+
}
|
|
1098
|
+
} else {
|
|
1099
|
+
lines.push(taskInput);
|
|
1100
|
+
}
|
|
1101
|
+
lines.push('');
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* TASK_1833: commit command with HONEST failure semantics. The historical shape
|
|
1106
|
+
* `git add ... && (git commit ... || true)` used ONE blanket swallow to cover
|
|
1107
|
+
* two opposite exit conditions: nothing-to-commit (benign, should be silent)
|
|
1108
|
+
* and could-not-acquire-.git/index.lock (another agent committing into the
|
|
1109
|
+
* same shared tree — the work silently vanished; measured data loss 2026-07-31).
|
|
1110
|
+
* This shape separates them:
|
|
1111
|
+
* - `git diff --cached --quiet` exits 0 when nothing is staged → silent skip,
|
|
1112
|
+
* no commit attempted.
|
|
1113
|
+
* - otherwise commit; on failure retry twice with 2s/4s backoff (covers the
|
|
1114
|
+
* index.lock contention window), and let the FINAL failure propagate
|
|
1115
|
+
* non-zero — loudly.
|
|
1116
|
+
* `git add` gets the same retry treatment: staging also takes .git/index.lock,
|
|
1117
|
+
* so under contention the add fails before the commit is ever attempted
|
|
1118
|
+
* (measured in the TASK_1833 collision harness — lock held at add time made
|
|
1119
|
+
* the un-retried shape fail immediately instead of riding out the window).
|
|
1120
|
+
* thrift: retries on ANY failure, not just index.lock — a non-transient
|
|
1121
|
+
* failure just fails 3 times and still exits loudly; classifying error kinds
|
|
1122
|
+
* in a one-liner isn't worth it.
|
|
1123
|
+
* @param {string} stageSpec - what to stage ('-A' or an explicit-paths placeholder)
|
|
1124
|
+
* @param {string} message - commit message (may contain {task_id} placeholder)
|
|
1125
|
+
* @returns {string} bash command line
|
|
1126
|
+
*/
|
|
1127
|
+
function buildCommitCommand(stageSpec, message) {
|
|
1128
|
+
// TASK_1957: '-A' staging always runs inside an ISOLATED worktree (Formation
|
|
1129
|
+
// unit worktree or cross-project target_repo_worktree — see appendWorkflow's
|
|
1130
|
+
// isIsolated gate). Route it through buildWorktreeGitAddCommand() so daemon/
|
|
1131
|
+
// dispatch telemetry (.kenaz/sessions, .kenaz/specialist, .formation/.dispatch-branch,
|
|
1132
|
+
// .formation/analytics) is never staged into the task commit in the first
|
|
1133
|
+
// place — the root cause of esp32 TASK_82/83's post-merge "would be
|
|
1134
|
+
// overwritten" failures. The explicit-paths shared-tree case is unaffected.
|
|
1135
|
+
const add = stageSpec === '-A' ? buildWorktreeGitAddCommand() : `git add ${stageSpec}`;
|
|
1136
|
+
const commit = `git commit --no-verify -m "${message}"`;
|
|
1137
|
+
// Jittered backoff (1-3s then 3-7s): deterministic delays keep two colliding
|
|
1138
|
+
// agents in lockstep — measured in the TASK_1833 harness, fixed 2s/4s retries
|
|
1139
|
+
// re-collided on every attempt; jitter de-synchronizes them.
|
|
1140
|
+
// $RANDOM degrades to a fixed 1s/3s under non-bash sh — still valid.
|
|
1141
|
+
const j1 = 'sleep $((RANDOM % 3 + 1))';
|
|
1142
|
+
const j2 = 'sleep $((RANDOM % 5 + 3))';
|
|
1143
|
+
// The nothing-staged gate is re-evaluated INSIDE each retry, not once up
|
|
1144
|
+
// front: in a shared tree a racing committer can absorb our staged paths
|
|
1145
|
+
// into ITS commit (shared .git/index) — the work has then landed, and a
|
|
1146
|
+
// blind commit retry would fail "nothing to commit" (a loud false negative,
|
|
1147
|
+
// measured in the TASK_1833 harness). Re-checking turns that into the
|
|
1148
|
+
// correct silent skip; a still-held index.lock still fails all 3 attempts
|
|
1149
|
+
// and exits non-zero.
|
|
1150
|
+
const attempt = `git diff --cached --quiet || ${commit}`;
|
|
1151
|
+
return `{ ${add} || { ${j1}; ${add}; } || { ${j2}; ${add}; }; } && { ${attempt} || { ${j1}; ${attempt}; } || { ${j2}; ${attempt}; }; }`;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* TASK_2082 R3: true when the card's scope_paths touch Rust — a .rs file or
|
|
1156
|
+
* anything under dashboard/src-tauri/. Drives whether the worktree subagent
|
|
1157
|
+
* prompt gets the "## Rust check" section (see appendRustCheckReminder).
|
|
1158
|
+
* @param {string|object|null|undefined} taskData
|
|
1159
|
+
* @returns {boolean}
|
|
1160
|
+
*/
|
|
1161
|
+
function hasRustScope(taskData) {
|
|
1162
|
+
try {
|
|
1163
|
+
const parsed = typeof taskData === 'string' ? JSON.parse(taskData) : taskData;
|
|
1164
|
+
const scopePaths = (parsed && parsed.scope_paths) || [];
|
|
1165
|
+
return scopePaths.some((p) => {
|
|
1166
|
+
const norm = String(p).replace(/\\/g, '/');
|
|
1167
|
+
return /\.rs$/i.test(norm) || norm.includes('dashboard/src-tauri/');
|
|
1168
|
+
});
|
|
1169
|
+
} catch {
|
|
1170
|
+
return false;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* TASK_2082 R3: default existence check for whether the resolved core root
|
|
1176
|
+
* actually carries the Rust crate — on a packaged machine (Alaya failure_seed,
|
|
1177
|
+
* 2026-09-25) dashboard/src-tauri may not exist at all, so the Rust check
|
|
1178
|
+
* section must never render there even for a Rust-scoped card. Exposed as a
|
|
1179
|
+
* default so callers/tests can inject `options.rustCoreCheck` instead of
|
|
1180
|
+
* touching this machine's filesystem.
|
|
1181
|
+
* @param {string} corePath
|
|
1182
|
+
* @returns {boolean}
|
|
1183
|
+
*/
|
|
1184
|
+
function defaultRustCoreCheck(corePath) {
|
|
1185
|
+
try {
|
|
1186
|
+
return fs.existsSync(path.join(corePath, 'dashboard', 'src-tauri', 'Cargo.toml'));
|
|
1187
|
+
} catch {
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* TASK_2082 R3: appends the "## Rust check (once, after commit)" section for
|
|
1194
|
+
* worktree-isolated subagents on Rust-scoped cards only. Gated on BOTH:
|
|
1195
|
+
* - hasRustScope(taskData) — the card actually touches Rust, and
|
|
1196
|
+
* - the resolved core root actually has the crate (defaultRustCoreCheck,
|
|
1197
|
+
* overridable via options.rustCoreCheck for tests / packaged machines).
|
|
1198
|
+
* `isIsolated` is the same flag appendWorkflow already computes for the
|
|
1199
|
+
* commit-step staging choice (`-A` in an isolated worktree vs explicit-paths
|
|
1200
|
+
* in a shared tree) — this section only makes sense where there IS an
|
|
1201
|
+
* isolated worktree + branch to run rust-verify-worktree.js against.
|
|
1202
|
+
* Cards that don't match either gate render no lines — byte-identical to
|
|
1203
|
+
* the pre-TASK_2082 output.
|
|
1204
|
+
*
|
|
1205
|
+
* Hard rule 4 ("Rust 交 Ansuz") lives in the SUBAGENT_PREFIX/
|
|
1206
|
+
* WORKTREE_DISPATCH_HARD_RULES constant text, prepended BEFORE this prompt
|
|
1207
|
+
* body — so this section does NOT try to talk over it with a "later wins"
|
|
1208
|
+
* note (agents were observed obeying the earlier hard rule instead). The
|
|
1209
|
+
* actual wording fix happens at the composition point in dispatch.js via
|
|
1210
|
+
* applyRustCheckToPrefix(prefix, body), which rewrites "Rust 交 Ansuz" to
|
|
1211
|
+
* the allowing wording IN THE PREFIX ITSELF whenever body contains this
|
|
1212
|
+
* section's marker ("## Rust check (once, after commit)") — so there is
|
|
1213
|
+
* never a contradiction for the agent to resolve.
|
|
1214
|
+
* @param {string[]} lines
|
|
1215
|
+
* @param {string|object|null|undefined} taskData
|
|
1216
|
+
* @param {object} options
|
|
1217
|
+
* @param {boolean} isIsolated
|
|
1218
|
+
*/
|
|
1219
|
+
function appendRustCheckReminder(lines, taskData, options = {}, isIsolated) {
|
|
1220
|
+
if (!isIsolated) return;
|
|
1221
|
+
if (!hasRustScope(taskData)) return;
|
|
1222
|
+
|
|
1223
|
+
const corePath = options.corePath || resolveCorePath(options.projectPath) || path.resolve(__dirname, '..', '..');
|
|
1224
|
+
const checkFn = typeof options.rustCoreCheck === 'function' ? options.rustCoreCheck : defaultRustCoreCheck;
|
|
1225
|
+
if (!checkFn(corePath)) return;
|
|
1226
|
+
|
|
1227
|
+
lines.push(`## Rust check (once, after commit)`);
|
|
1228
|
+
lines.push(`After committing, run exactly one narrow filter: \`node ${corePath}/dev/scripts/rust-verify-worktree.js run <your branch> <test filter>\`.`);
|
|
1229
|
+
lines.push(`Exit 75/124 = report unverified and stop, do not retry or poll. Never run cargo in your own worktree.`);
|
|
1230
|
+
lines.push('');
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* TASK_2082 defect fix (Ansuz review of eb7c3be5d): the "later instructions
|
|
1235
|
+
* win" approach above was rejected — dispatched agents were observed
|
|
1236
|
+
* obeying the EARLIER hard rule 4 ("Rust 交 Ansuz") over the later "## Rust
|
|
1237
|
+
* check" section, i.e. a genuinely contradictory prompt, not just a
|
|
1238
|
+
* precedence question for a human reader. Fixing hard rule 4's wording
|
|
1239
|
+
* itself requires editing the prefix constant AT THE COMPOSITION POINT
|
|
1240
|
+
* (dispatch.js, where `subagentPrefix + promptText` are concatenated),
|
|
1241
|
+
* since SUBAGENT_PREFIX/buildSubagentWorktreePrefix are plain strings with
|
|
1242
|
+
* no access to the per-card body.
|
|
1243
|
+
*
|
|
1244
|
+
* Call this from dispatch.js right before prefixing: only when `body`
|
|
1245
|
+
* (the assembled rawPrompt) carries the Rust-check section marker does the
|
|
1246
|
+
* chosen prefix get its hard-rule-4 phrase swapped for wording that allows
|
|
1247
|
+
* the single command. A body without the marker (JS-only card, or any
|
|
1248
|
+
* card where appendRustCheckReminder's gates didn't fire) leaves `prefix`
|
|
1249
|
+
* byte-identical.
|
|
1250
|
+
* @param {string} prefix - the chosen subagent prefix (SUBAGENT_PREFIX,
|
|
1251
|
+
* SUBAGENT_PREFIX_DIRECT, or a buildSubagentWorktreePrefix(...) result)
|
|
1252
|
+
* @param {string} body - the assembled rawPrompt (post buildPrompt())
|
|
1253
|
+
* @returns {string}
|
|
1254
|
+
*/
|
|
1255
|
+
const RUST_CHECK_SECTION_MARKER = '## Rust check (once, after commit)';
|
|
1256
|
+
const HARD_RULE_4_RUST_PHRASE = 'Rust 交 Ansuz';
|
|
1257
|
+
const HARD_RULE_4_RUST_ALLOW_PHRASE = 'Rust 只准跑一次 ## Rust check 指令';
|
|
1258
|
+
|
|
1259
|
+
function applyRustCheckToPrefix(prefix, body) {
|
|
1260
|
+
if (typeof prefix !== 'string' || typeof body !== 'string') return prefix;
|
|
1261
|
+
if (!body.includes(RUST_CHECK_SECTION_MARKER)) return prefix;
|
|
1262
|
+
return prefix.split(HARD_RULE_4_RUST_PHRASE).join(HARD_RULE_4_RUST_ALLOW_PHRASE);
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
function appendWorkflow(lines, skillDef, options = {}, taskData = null) {
|
|
1266
|
+
if (skillDef.collaboration && skillDef.collaboration.workflow) {
|
|
1267
|
+
// Sub-project: rewrite task-api commands to include --project-path
|
|
1268
|
+
const rewriteCmd = buildTaskApiRewriter(options);
|
|
1269
|
+
// Replace {task_id} placeholder with actual task ID when available
|
|
1270
|
+
const taskId = options.taskId || null;
|
|
1271
|
+
const resolveTaskId = (cmd) => taskId ? cmd.replace(/\{task_id\}/g, taskId) : cmd;
|
|
1272
|
+
|
|
1273
|
+
// TASK_1821: rigor-gated self-complete. rigor:high cards must NOT be closed by
|
|
1274
|
+
// their own executor — the party with independent verification on the Formation
|
|
1275
|
+
// path is post-complete (dispatcher side: regression tests + verify-acceptance +
|
|
1276
|
+
// verified merge), and it already moves the task active→done itself after
|
|
1277
|
+
// isVerifiedMergeSuccess (post-complete.js Step 2.5), so the card cannot strand.
|
|
1278
|
+
// NOTE: this axis (per-card rigor) is orthogonal to the isSubagent axis below
|
|
1279
|
+
// (per-dispatch-path). The subagent branch `continue`s first, so its replacement
|
|
1280
|
+
// note stays byte-identical and this check only fires on Formation/headless/serial.
|
|
1281
|
+
// TASK_2252: extractRigor accepts string OR object (a bare JSON.parse(object)
|
|
1282
|
+
// threw into the catch and silently skipped this gate).
|
|
1283
|
+
const taskRigor = extractRigor(taskData);
|
|
1284
|
+
|
|
1285
|
+
lines.push(`## Workflow`);
|
|
1286
|
+
// TASK_1819: only isolated executors may stage the whole tree.
|
|
1287
|
+
// - options.isSubagent → Agent-tool dispatch (worktree isolation, dispatch.js)
|
|
1288
|
+
// ...UNLESS options.isCrossProject (TASK_1824): cross-project sub-agent dispatch
|
|
1289
|
+
// has NO worktree isolation (TASK_1672 — the Agent tool worktree derives from the
|
|
1290
|
+
// conversation cwd repo, not the target sub-project). It writes directly into the
|
|
1291
|
+
// sub-project's SHARED working tree, so it gets explicit-paths staging like serial.
|
|
1292
|
+
// - options.isWorktree → Formation task worktree (threaded from headless.js
|
|
1293
|
+
// promptOpts.isWorktree = !!_unitWorktreePath)
|
|
1294
|
+
// Serial (neither flag) shares the working tree with the user and Ansuz —
|
|
1295
|
+
// a blanket `git add -A` swept 392 unrelated files in TASK_188, so serial
|
|
1296
|
+
// mode gets an explicit-paths staging instruction instead.
|
|
1297
|
+
const isIsolated = !!((options.isSubagent && !options.isCrossProject) || options.isWorktree);
|
|
1298
|
+
for (const step of skillDef.collaboration.workflow) {
|
|
1299
|
+
// In subagent mode: skip read/claim (card already inline; claim done by parent)
|
|
1300
|
+
if (options.isSubagent) {
|
|
1301
|
+
const stepRun = step.run || '';
|
|
1302
|
+
if (stepRun.includes('task-api.js get ') || stepRun.includes('task-api.js claim ')) {
|
|
1303
|
+
continue;
|
|
1304
|
+
}
|
|
1305
|
+
if (stepRun.includes('task-api.js complete')) {
|
|
1306
|
+
lines.push(`### ${step.step}`);
|
|
1307
|
+
lines.push('Note: ⚠️ Worktree mode — 禁止執行 task-api.js complete。主 thread 在 merge + 驗證後處理。');
|
|
1308
|
+
lines.push('');
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
// TASK_1821: Formation/headless/serial path + rigor:high → replace the
|
|
1313
|
+
// self-complete step with a prohibition note (same technique as the
|
|
1314
|
+
// subagent branch above). The dispatcher-side post-complete pipeline
|
|
1315
|
+
// closes the card after merge + independent verification.
|
|
1316
|
+
if (taskRigor === 'high' && step.run && step.run.includes('task-api.js complete')) {
|
|
1317
|
+
lines.push(`### ${step.step}`);
|
|
1318
|
+
lines.push('Note: ⚠️ rigor: high — 禁止執行 task-api.js complete。任務留在 active/,由派工方的 post-complete 在 merge + 獨立驗證(回歸測試 + verify-acceptance)通過後移入 done/。在完成摘要中明確標註「未自行 complete,待派工者驗證後關閉」。');
|
|
1319
|
+
lines.push('');
|
|
1320
|
+
continue;
|
|
1321
|
+
}
|
|
1322
|
+
// TASK_1833: the workflow commit step must never render the blanket
|
|
1323
|
+
// `|| true` from the skill YAML — see buildCommitCommand for why (one
|
|
1324
|
+
// swallow covered both nothing-to-commit AND index.lock data loss).
|
|
1325
|
+
// Applies to BOTH modes: isolated gets `git add -A`, shared-tree gets
|
|
1326
|
+
// explicit-paths staging (TASK_1819) — each with the honest commit shape.
|
|
1327
|
+
if (step.run && step.run.includes('git add -A') && step.run.includes('git commit')) {
|
|
1328
|
+
const msgMatch = step.run.match(/-m\s+"([^"]+)"/);
|
|
1329
|
+
const commitMsg = msgMatch ? msgMatch[1] : '[{task_id}] task completed';
|
|
1330
|
+
lines.push(`### ${step.step}`);
|
|
1331
|
+
if (isIsolated) {
|
|
1332
|
+
lines.push(`Command: ${resolveTaskId(buildCommitCommand('-A', commitMsg))}`);
|
|
1333
|
+
if (step.note) lines.push(`Note: ${step.note}`);
|
|
1334
|
+
lines.push('Note: nothing to commit 時靜默跳過(不算失敗);git commit 失敗(如 index.lock 競爭)會自動退避重試兩次,仍失敗則以非零退出 — 此時大聲回報錯誤,不要吞掉。');
|
|
1335
|
+
} else {
|
|
1336
|
+
lines.push(`Command: ${resolveTaskId(buildCommitCommand('<只列出你本次明確編輯過的檔案路徑>', commitMsg))}`);
|
|
1337
|
+
lines.push('Note: ⚠️ 共用工作樹模式(無 worktree 隔離)— 你與使用者、其他 agent 共用同一個工作樹。只 stage 你本次明確編輯過的檔案,嚴禁一次 stage 整個工作樹(TASK_188 曾因此把 392 個無關檔案掃進單一 commit)。nothing to commit 時靜默跳過(不算失敗);git commit 失敗(如 .git/index.lock 被其他 agent 持有)會自動退避重試兩次,仍失敗則以非零退出 — 此時大聲回報錯誤,不要吞掉。');
|
|
1338
|
+
}
|
|
1339
|
+
lines.push('');
|
|
1340
|
+
appendRustCheckReminder(lines, taskData, options, isIsolated);
|
|
1341
|
+
continue;
|
|
1342
|
+
}
|
|
1343
|
+
lines.push(`### ${step.step}`);
|
|
1344
|
+
if (step.run) lines.push(`Command: ${resolveTaskId(rewriteCmd(step.run))}`);
|
|
1345
|
+
if (step.note) lines.push(`Note: ${step.note}`);
|
|
1346
|
+
if (step.actions) {
|
|
1347
|
+
for (const a of step.actions) {
|
|
1348
|
+
lines.push(`- ${a}`);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
lines.push('');
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
if (skillDef.collaboration.on_blocked) {
|
|
1355
|
+
lines.push(`### On Blocked`);
|
|
1356
|
+
lines.push(`Command: ${resolveTaskId(rewriteCmd(skillDef.collaboration.on_blocked.run))}`);
|
|
1357
|
+
lines.push(`Note: ${skillDef.collaboration.on_blocked.note}`);
|
|
1358
|
+
lines.push('');
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
appendDispatchOverrides(lines, taskData);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* TASK_1820: card-controlled override channel, rendered immediately AFTER the
|
|
1367
|
+
* ## Workflow envelope. Section order is fixed (## Task always precedes
|
|
1368
|
+
* ## Workflow) and later instructions win for LLMs, so card-level override
|
|
1369
|
+
* statements written inside ## Task structurally lose to the envelope
|
|
1370
|
+
* (observed: TASK_183's "DO NOT COMMIT" technical note was overridden and the
|
|
1371
|
+
* executor committed anyway). This is the single override mechanism — do NOT
|
|
1372
|
+
* add skip_steps or a kenaz_dispatch extraInstructions param alongside it:
|
|
1373
|
+
* multiple channels without a stated precedence turn "cannot override" into
|
|
1374
|
+
* "unclear who wins".
|
|
1375
|
+
*
|
|
1376
|
+
* Card field: `dispatch_overrides` (optional; string or array of strings).
|
|
1377
|
+
* Cards without the field render byte-identically to before this change.
|
|
1378
|
+
*/
|
|
1379
|
+
function appendDispatchOverrides(lines, taskData) {
|
|
1380
|
+
if (!taskData) return;
|
|
1381
|
+
let parsed = null;
|
|
1382
|
+
try { parsed = typeof taskData === 'string' ? JSON.parse(taskData) : taskData; } catch { return; /* raw YAML fallback — no structured field */ }
|
|
1383
|
+
const raw = parsed && parsed.dispatch_overrides;
|
|
1384
|
+
if (!raw) return;
|
|
1385
|
+
const items = (Array.isArray(raw) ? raw : [raw])
|
|
1386
|
+
.filter(item => item != null && String(item).trim() !== '');
|
|
1387
|
+
if (items.length === 0) return;
|
|
1388
|
+
|
|
1389
|
+
lines.push(`## Dispatch Overrides (card-level — 覆寫上方 Workflow)`);
|
|
1390
|
+
lines.push(`⚠️ 以下指示來自任務卡片,優先級高於上方 ## Workflow 的預設步驟。兩者衝突時,一律以本區段為準。`);
|
|
1391
|
+
for (const item of items) {
|
|
1392
|
+
lines.push(`- ${String(item).trim()}`);
|
|
1393
|
+
}
|
|
1394
|
+
lines.push('');
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* Build a rewriter function that rewrites task-api commands for sub-projects.
|
|
1399
|
+
* When projectPath is set, replaces relative `node .collaboration/core/task-api.js`
|
|
1400
|
+
* with absolute path + --project-path flag.
|
|
1401
|
+
*/
|
|
1402
|
+
function buildTaskApiRewriter(options = {}) {
|
|
1403
|
+
const { projectPath } = options;
|
|
1404
|
+
if (!projectPath) return (cmd) => cmd;
|
|
1405
|
+
|
|
1406
|
+
// Resolve corePath using shared resolver (validates path + KENAZ_SOURCE_DIR fallback)
|
|
1407
|
+
const corePath = resolveCorePath(projectPath);
|
|
1408
|
+
if (!corePath) return (cmd) => cmd;
|
|
1409
|
+
|
|
1410
|
+
const TASK_API_PATTERN = /node\s+\.collaboration\/core\/task-api\.js/g;
|
|
1411
|
+
const replacement = `node "${corePath}/.collaboration/core/task-api.js" --project-path "${projectPath}"`;
|
|
1412
|
+
|
|
1413
|
+
return (cmd) => cmd.replace(TASK_API_PATTERN, replacement);
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
/**
|
|
1417
|
+
* Append Yggdrasil network context — shows what other nodes are doing.
|
|
1418
|
+
* Lets the agent know about remote activity and potential file conflicts.
|
|
1419
|
+
*
|
|
1420
|
+
* @param {string[]} lines
|
|
1421
|
+
* @param {object} ctx - { onlineNodes, remoteTasks, myNodeName, myScopePaths }
|
|
1422
|
+
*/
|
|
1423
|
+
function appendYggdrasilContext(lines, ctx) {
|
|
1424
|
+
if (!ctx) return;
|
|
1425
|
+
const { onlineNodes = [], remoteTasks = [], myScopePaths = [] } = ctx;
|
|
1426
|
+
if (onlineNodes.length === 0 && remoteTasks.length === 0) return;
|
|
1427
|
+
|
|
1428
|
+
lines.push('## Yggdrasil Network (Remote Collaborators)');
|
|
1429
|
+
lines.push('Other developers/agents are currently working on this project:');
|
|
1430
|
+
lines.push('');
|
|
1431
|
+
|
|
1432
|
+
for (const node of onlineNodes) {
|
|
1433
|
+
const files = node.touching_files || [];
|
|
1434
|
+
lines.push(`**${node.node_name}** — ONLINE`);
|
|
1435
|
+
if (node.branch) lines.push(` Branch: ${node.branch}`);
|
|
1436
|
+
if (node.current_task) lines.push(` Task: ${node.current_task}`);
|
|
1437
|
+
if (node.work_summary) lines.push(` Working on: ${node.work_summary}`);
|
|
1438
|
+
if (files.length > 0) {
|
|
1439
|
+
lines.push(` Files: ${files.slice(0, 8).join(', ')}${files.length > 8 ? ` (+${files.length - 8})` : ''}`);
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
// Highlight file overlaps with my scope (informational, not blocking)
|
|
1443
|
+
if (myScopePaths.length > 0 && files.length > 0) {
|
|
1444
|
+
const overlaps = files.filter(f =>
|
|
1445
|
+
myScopePaths.some(sp => f.startsWith(sp) || sp.startsWith(f))
|
|
1446
|
+
);
|
|
1447
|
+
if (overlaps.length > 0) {
|
|
1448
|
+
lines.push(` ℹ️ FILE OVERLAP: ${overlaps.join(', ')}`);
|
|
1449
|
+
lines.push(` → Be aware of potential merge conflicts. Coordinate if needed.`);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
lines.push('');
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
if (remoteTasks.length > 0) {
|
|
1456
|
+
lines.push('Active remote tasks:');
|
|
1457
|
+
for (const t of remoteTasks.slice(0, 5)) {
|
|
1458
|
+
lines.push(`- ${t.task_id} (claimed by ${t.claimed_by})`);
|
|
1459
|
+
}
|
|
1460
|
+
lines.push('');
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
lines.push('To check real-time network status: `node .formation/tools/coordinator.js --status`');
|
|
1464
|
+
lines.push('');
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
/**
|
|
1468
|
+
* Append memory context — 從 .failure/ + .memory/ + .kenaz/main-memory/ 載入相關經驗
|
|
1469
|
+
* 注入到 prompt 中讓 agent 避免重蹈覆轍
|
|
1470
|
+
*/
|
|
1471
|
+
function appendMemoryContext(lines, taskData, options = {}) {
|
|
1472
|
+
if (!memoryLoader) return;
|
|
1473
|
+
|
|
1474
|
+
try {
|
|
1475
|
+
// 從 taskData 提取上下文資訊
|
|
1476
|
+
const memOpts = {};
|
|
1477
|
+
if (taskData) {
|
|
1478
|
+
let parsed = null;
|
|
1479
|
+
try { parsed = JSON.parse(taskData); } catch { /* not JSON */ }
|
|
1480
|
+
if (parsed) {
|
|
1481
|
+
memOpts.taskTitle = parsed.title || '';
|
|
1482
|
+
memOpts.role = parsed.role || '';
|
|
1483
|
+
memOpts.scopePaths = parsed.scope_paths || [];
|
|
1484
|
+
memOpts.tags = parsed.tags || [];
|
|
1485
|
+
memOpts.priority = parsed.priority || '';
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
// TASK_1998 two-axis policy: Known Failures / Project Memory are CONTEXT
|
|
1490
|
+
// volume, driven by complexity — simple drops both, medium restores Known
|
|
1491
|
+
// Failures but keeps Project Memory dropped, complex keeps both. Knowledge
|
|
1492
|
+
// Base (main-memory) is unaffected either way — it isn't part of this gate.
|
|
1493
|
+
const profile = promptProfile({ rigor: extractRigor(taskData), complexity: extractComplexity(taskData) });
|
|
1494
|
+
memOpts.skipFailures = profile.skipKnownFailures;
|
|
1495
|
+
// 2026-10-10: memory system frozen (project_memory_system_frozen) - no Project Memory block.
|
|
1496
|
+
memOpts.skipMemory = true;
|
|
1497
|
+
|
|
1498
|
+
// Resolve corePath for sub-projects so memory-loader reads from core's
|
|
1499
|
+
// .failure/, .memory/, .kenaz/main-memory/ instead of __dirname fallback
|
|
1500
|
+
const corePath = options.corePath || resolveCorePath(options.projectPath);
|
|
1501
|
+
if (corePath) memOpts.corePath = corePath;
|
|
1502
|
+
|
|
1503
|
+
const memoryBlock = memoryLoader.loadMemoryContext(memOpts);
|
|
1504
|
+
if (memoryBlock) {
|
|
1505
|
+
lines.push(memoryBlock);
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
// Code-navigation reminder (SYN-002, rewritten for LSP in TASK_2335)
|
|
1509
|
+
lines.push('');
|
|
1510
|
+
lines.push('## Search Tool Selection (SYN-002)');
|
|
1511
|
+
lines.push('搜尋前先判斷:精確字串(函數名、error message、概念關鍵字)→ Grep / Glob。「誰呼叫它」「改了影響哪裡」「定義在哪」→ kenaz_lsp_callers / kenaz_lsp_references / kenaz_lsp_definition(args: projectPath, file, line 或 symbol, depth);檔案內 symbol 列表 → kenaz_lsp_symbols。');
|
|
1512
|
+
lines.push('');
|
|
1513
|
+
} catch { /* graceful degradation */ }
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* Synchronously call an MCP tool via JSON-RPC over the local Dashboard HTTP
|
|
1518
|
+
* server (127.0.0.1:18080/api/mcp) in a subprocess — keeps buildPrompt() sync.
|
|
1519
|
+
* Returns the parsed inner data object, or null on any failure / unavailability.
|
|
1520
|
+
* Shared by appendAlayaLessons.
|
|
1521
|
+
*
|
|
1522
|
+
* @param {string} toolName - MCP tool name (e.g. 'cortex_recall')
|
|
1523
|
+
* @param {object} toolArgs - forwarded as params.arguments
|
|
1524
|
+
* @returns {object|null}
|
|
1525
|
+
*/
|
|
1526
|
+
function callMcpToolSync(toolName, toolArgs) {
|
|
1527
|
+
try {
|
|
1528
|
+
const { execSync } = require('child_process');
|
|
1529
|
+
const script = `
|
|
1530
|
+
const http = require('http');
|
|
1531
|
+
const payload = JSON.stringify({
|
|
1532
|
+
jsonrpc: '2.0', id: 1,
|
|
1533
|
+
method: 'tools/call',
|
|
1534
|
+
params: { name: ${JSON.stringify(toolName)}, arguments: ${JSON.stringify(toolArgs)} }
|
|
1535
|
+
});
|
|
1536
|
+
const req = http.request({
|
|
1537
|
+
hostname: '127.0.0.1', port: 18080, path: '/api/mcp',
|
|
1538
|
+
method: 'POST',
|
|
1539
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(payload) },
|
|
1540
|
+
timeout: 5000
|
|
1541
|
+
}, (res) => {
|
|
1542
|
+
let d = '';
|
|
1543
|
+
res.on('data', c => d += c);
|
|
1544
|
+
res.on('end', () => process.stdout.write(d));
|
|
1545
|
+
});
|
|
1546
|
+
req.on('error', () => process.exit(0));
|
|
1547
|
+
req.on('timeout', () => { req.destroy(); process.exit(0); });
|
|
1548
|
+
req.write(payload);
|
|
1549
|
+
req.end();
|
|
1550
|
+
`;
|
|
1551
|
+
const stdout = execSync(`node -e "${script.replace(/"/g, '\\"').replace(/\n/g, ' ')}"`, {
|
|
1552
|
+
timeout: 8000, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true,
|
|
1553
|
+
});
|
|
1554
|
+
if (!stdout || !stdout.trim()) return null;
|
|
1555
|
+
const result = JSON.parse(stdout);
|
|
1556
|
+
if (!result || result.error) return null;
|
|
1557
|
+
const content = result.result?.content;
|
|
1558
|
+
if (!content || !Array.isArray(content)) return null;
|
|
1559
|
+
const textPart = content.find(c => c.type === 'text');
|
|
1560
|
+
if (!textPart || !textPart.text) return null;
|
|
1561
|
+
try { return JSON.parse(textPart.text); } catch { return null; }
|
|
1562
|
+
} catch { return null; } // MCP server unavailable — graceful degradation
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
// TASK_2101/TASK_2104: the absolute relevance gate (cosine floor + stack
|
|
1566
|
+
// match) for Alaya lesson injection — constants, deriveTaskStack,
|
|
1567
|
+
// deriveBijaStack, passesAlayaRelevanceGate — now lives in
|
|
1568
|
+
// .formation/tools/alaya-gate.js (dependency-free, shared with task-api.js's
|
|
1569
|
+
// echoAlayaLessons). Destructured from the require() at the top of this
|
|
1570
|
+
// file; see alaya-gate.js for the full calibration writeup and rationale.
|
|
1571
|
+
|
|
1572
|
+
/**
|
|
1573
|
+
* Append bounded Alaya process-lesson context to the prompt.
|
|
1574
|
+
* Reuses the title+scope_paths query, queries
|
|
1575
|
+
* alaya_recall (hybrid mode, failure_seed + lesson_seed, with the TASK_2101
|
|
1576
|
+
* min_cosine floor) and injects a ## Process lessons (Alaya) section capped
|
|
1577
|
+
* at 900 chars total — but ONLY for candidates that also pass the stack-match
|
|
1578
|
+
* gate. Zero passing candidates renders nothing (R3: an empty section beats
|
|
1579
|
+
* noise).
|
|
1580
|
+
*
|
|
1581
|
+
* Graceful degradation: silently skips on empty query, empty results, or
|
|
1582
|
+
* any MCP failure — the recall bar is never allowed to raise dispatch
|
|
1583
|
+
* latency or fail the prompt build.
|
|
1584
|
+
*
|
|
1585
|
+
* @param {string[]} lines - prompt lines array (mutated)
|
|
1586
|
+
* @param {string|object} taskData - task JSON string or parsed object
|
|
1587
|
+
* @param {(toolName: string, toolArgs: object) => object|null} [mcpCaller] - injectable MCP bridge (defaults to callMcpToolSync; test seam)
|
|
1588
|
+
*/
|
|
1589
|
+
function appendAlayaLessons(lines, taskData, mcpCaller = callMcpToolSync) {
|
|
1590
|
+
if (!mcpCaller.__forceAlaya) return; // 2026-10-10: memory system frozen; tests opt in via __forceAlaya
|
|
1591
|
+
const query = buildTaskContextQuery(taskData);
|
|
1592
|
+
if (!query) return;
|
|
1593
|
+
|
|
1594
|
+
let scopePaths = [];
|
|
1595
|
+
try {
|
|
1596
|
+
const parsed = typeof taskData === 'string' ? JSON.parse(taskData) : taskData;
|
|
1597
|
+
if (parsed) scopePaths = parsed.scope_paths || [];
|
|
1598
|
+
} catch { /* taskData not JSON — task stack stays empty, floor-only gate */ }
|
|
1599
|
+
const taskStack = deriveTaskStack(scopePaths);
|
|
1600
|
+
|
|
1601
|
+
try {
|
|
1602
|
+
const recallData = mcpCaller('alaya_recall', {
|
|
1603
|
+
query, mode: 'hybrid', seed_types: ['failure_seed', 'lesson_seed'],
|
|
1604
|
+
limit: ALAYA_CANDIDATE_POOL, min_cosine: ALAYA_MIN_COSINE_DEFAULT,
|
|
1605
|
+
});
|
|
1606
|
+
if (!recallData) return;
|
|
1607
|
+
|
|
1608
|
+
let bijas = recallData.bijas || [];
|
|
1609
|
+
if (bijas.length === 0) return;
|
|
1610
|
+
const candidateCount = bijas.length;
|
|
1611
|
+
|
|
1612
|
+
bijas = dedupBijas(bijas);
|
|
1613
|
+
|
|
1614
|
+
// TASK_2101 R3: stack-match gate on top of the server-side cosine floor
|
|
1615
|
+
// (the server already applied min_cosine, but re-checking here keeps
|
|
1616
|
+
// this function correct against a stub/older server that ignores it).
|
|
1617
|
+
const gated = bijas.filter(b => passesAlayaRelevanceGate(b, taskStack, ALAYA_MIN_COSINE_DEFAULT));
|
|
1618
|
+
const droppedCount = candidateCount - gated.length;
|
|
1619
|
+
if (droppedCount > 0) {
|
|
1620
|
+
// Log for floor/gate tuning (R3) — never fails the prompt build.
|
|
1621
|
+
console.error(`[appendAlayaLessons] dropped ${droppedCount}/${candidateCount} candidates below the cosine floor (${ALAYA_MIN_COSINE_DEFAULT}) or stack mismatch for query "${query}"`);
|
|
1622
|
+
}
|
|
1623
|
+
bijas = gated.slice(0, 3);
|
|
1624
|
+
if (bijas.length === 0) return;
|
|
1625
|
+
|
|
1626
|
+
const modeEffective = recallData.mode_effective || 'hybrid';
|
|
1627
|
+
const sectionLines = [
|
|
1628
|
+
'## Process lessons (Alaya)',
|
|
1629
|
+
`Query: "${query}" — ${bijas.length} seeds (mode=${modeEffective}).`,
|
|
1630
|
+
...bijas.map(b => {
|
|
1631
|
+
const content = (b.content || '').replace(/\s+/g, ' ').trim().slice(0, 220);
|
|
1632
|
+
return `- **${b.seed_type || 'seed'}** [${b.origin || 'unknown'}] ${content}`;
|
|
1633
|
+
}),
|
|
1634
|
+
];
|
|
1635
|
+
|
|
1636
|
+
let section = sectionLines.join('\n');
|
|
1637
|
+
if (section.length > 900) {
|
|
1638
|
+
section = section.slice(0, 899) + '…';
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
lines.push('');
|
|
1642
|
+
lines.push(...section.split('\n'));
|
|
1643
|
+
lines.push('');
|
|
1644
|
+
} catch { /* Alaya unavailable — graceful degradation */ }
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
function appendCognitiveRecall(lines, taskData, options = {}) {
|
|
1648
|
+
// Extract recall keywords from task data (title, scope_paths, tags)
|
|
1649
|
+
let keywords = [];
|
|
1650
|
+
let scopeFiles = [];
|
|
1651
|
+
try {
|
|
1652
|
+
const parsed = typeof taskData === 'string' ? JSON.parse(taskData) : taskData;
|
|
1653
|
+
if (parsed) {
|
|
1654
|
+
if (parsed.title) {
|
|
1655
|
+
const stopWords = new Set(['the','a','an','is','are','was','were','be','to','of','and','in','for','on','at','by','with','from','as','into','fix','task','add','update','implement']);
|
|
1656
|
+
const words = parsed.title.replace(/[^a-zA-Z0-9_\s]/g, ' ').split(/\s+/).filter(w => w.length > 2 && !stopWords.has(w.toLowerCase()));
|
|
1657
|
+
keywords.push(...words.slice(0, 5));
|
|
1658
|
+
}
|
|
1659
|
+
if (parsed.scope_paths && parsed.scope_paths.length > 0) {
|
|
1660
|
+
for (const sp of parsed.scope_paths) {
|
|
1661
|
+
const parts = sp.replace(/\\/g, '/').split('/');
|
|
1662
|
+
const last = parts[parts.length - 1].replace(/\.[^.]+$/, '');
|
|
1663
|
+
if (last && last.length > 2) {
|
|
1664
|
+
keywords.push(last);
|
|
1665
|
+
scopeFiles.push(last);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
if (parsed.tags && parsed.tags.length > 0) {
|
|
1670
|
+
keywords.push(...parsed.tags.filter(t => t.length > 2));
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
} catch { /* taskData not JSON, skip */ }
|
|
1674
|
+
|
|
1675
|
+
if (keywords.length === 0) return;
|
|
1676
|
+
keywords = [...new Set(keywords)].slice(0, 8);
|
|
1677
|
+
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
// Exact, shared wording — rigor:low ends its Working contract with this
|
|
1681
|
+
// bullet; rigor:medium repeats the identical sentence as its own line after
|
|
1682
|
+
// the short progress-note instructions (TASK_1998 spec: "the exact line").
|
|
1683
|
+
const RUNE_OPTIONAL_LINE = 'Inscribe exactly one rune (synapse_inscribe) if you learned something non-obvious; otherwise skip it.';
|
|
1684
|
+
|
|
1685
|
+
/**
|
|
1686
|
+
* TASK_1998: rigor:medium's short (3-line) progress-note instruction — the
|
|
1687
|
+
* same write-then-run contract as appendProgressNoteInstructions()'s full
|
|
1688
|
+
* block, compressed to a header + 2 lines instead of a full schema dump.
|
|
1689
|
+
* No-op when taskData has no id (mirrors appendProgressNoteInstructions).
|
|
1690
|
+
*/
|
|
1691
|
+
function appendShortProgressNote(lines, taskData, options = {}) {
|
|
1692
|
+
let taskId = null;
|
|
1693
|
+
try {
|
|
1694
|
+
const parsed = typeof taskData === 'string' ? JSON.parse(taskData) : taskData;
|
|
1695
|
+
if (parsed) taskId = parsed.id;
|
|
1696
|
+
} catch { /* taskData not JSON, skip */ }
|
|
1697
|
+
if (!taskId) return;
|
|
1698
|
+
|
|
1699
|
+
const corePath = options.corePath || path.resolve(__dirname, '..', '..');
|
|
1700
|
+
const corePathFwd = corePath.replace(/\\/g, '/');
|
|
1701
|
+
const noteFile = `.kenaz/specialist/progress_note_${taskId}.json`;
|
|
1702
|
+
|
|
1703
|
+
lines.push(`## Progress Note (brief)`);
|
|
1704
|
+
lines.push(`Write JSON to \`${noteFile}\`, then run: node "${corePathFwd}/.specialist/tools/phase-gate.js" note --task=${taskId} --from-file="${noteFile}"`);
|
|
1705
|
+
lines.push(`Include: files touched, acceptance-criteria pass/fail, any deviations.`);
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
function appendCognitiveCheckpoint(lines, taskData, options = {}) {
|
|
1709
|
+
const profile = promptProfile({ rigor: extractRigor(taskData), complexity: extractComplexity(taskData) });
|
|
1710
|
+
|
|
1711
|
+
// TASK_1998: PROCESS strictness is rigor-driven. low/medium collapse the
|
|
1712
|
+
// six ritual sections (Before You Start recall, Before You Finish
|
|
1713
|
+
// inscribe, Cognitive Checkpoint, Progress Note, Known Failures, Project
|
|
1714
|
+
// Memory) into a compact contract — Ansuz already ran recall at
|
|
1715
|
+
// scoping time; the full mandatory recall/inscribe ceremony is reserved
|
|
1716
|
+
// for rigor:high. rigor:medium additionally gets a short progress-note
|
|
1717
|
+
// instruction on top of the contract (dropped entirely for rigor:low).
|
|
1718
|
+
if (profile.compactRitual) {
|
|
1719
|
+
lines.push('');
|
|
1720
|
+
lines.push(`## Working contract`);
|
|
1721
|
+
lines.push(`- Read the files you touch before editing.`);
|
|
1722
|
+
lines.push(`- Independent reads: fire them as parallel tool calls in ONE turn (e.g. Read a.js + Read b.js + Grep "foo" together), not one call per turn.`);
|
|
1723
|
+
lines.push(`- Independent shell checks: one bash command with separators (e.g. \`echo ==a==; cmd1; echo ==b==; cmd2\`), not N bash calls.`);
|
|
1724
|
+
lines.push(`- N similar items: one command over all N (e.g. one grep with alternation, or a loop), not N calls.`);
|
|
1725
|
+
lines.push(`- One Write or a multi-hunk Edit beats many small edits.`);
|
|
1726
|
+
lines.push(`- No self-check greps unless the card asks for them.`);
|
|
1727
|
+
lines.push(`- Commit early and often; the worktree hard rules above still apply verbatim.`);
|
|
1728
|
+
lines.push(`- Final report <= 20 lines: files touched, tests run, commit sha, uncertainties.`);
|
|
1729
|
+
lines.push('');
|
|
1730
|
+
|
|
1731
|
+
if (profile.ritualTier === 'medium') {
|
|
1732
|
+
appendShortProgressNote(lines, taskData, options);
|
|
1733
|
+
lines.push('');
|
|
1734
|
+
}
|
|
1735
|
+
return;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
function appendOutput(lines, skillDef) {
|
|
1740
|
+
if (!skillDef.output) return;
|
|
1741
|
+
lines.push(`## Expected Output`);
|
|
1742
|
+
lines.push(`Primary: ${typeof skillDef.output.primary === 'string' ? skillDef.output.primary.trim() : JSON.stringify(skillDef.output.primary)}`);
|
|
1743
|
+
if (skillDef.output.secondary) {
|
|
1744
|
+
lines.push(`Secondary: ${typeof skillDef.output.secondary === 'string' ? skillDef.output.secondary.trim() : JSON.stringify(skillDef.output.secondary)}`);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
// ─────────────────────────────────────────
|
|
1749
|
+
// Squad Synthesis:整合多份成員報告
|
|
1750
|
+
// ─────────────────────────────────────────
|
|
1751
|
+
|
|
1752
|
+
/**
|
|
1753
|
+
* 組裝 Squad Synthesis Agent 的 prompt
|
|
1754
|
+
* 在所有成員完成後,由 headless.js 自動呼叫
|
|
1755
|
+
* @param {object} skillDef - Squad 的 YAML 定義(含 merge 設定)
|
|
1756
|
+
* @param {string} reportDir - 報告目錄名稱(如 squad-strategy)
|
|
1757
|
+
* @returns {string} synthesis prompt
|
|
1758
|
+
*/
|
|
1759
|
+
function buildSquadSynthesisPrompt(skillDef, reportDir, options = {}) {
|
|
1760
|
+
const lines = [];
|
|
1761
|
+
const merge = skillDef.merge;
|
|
1762
|
+
|
|
1763
|
+
lines.push('## Role');
|
|
1764
|
+
lines.push('你是 Squad Synthesis Agent(整合者)。');
|
|
1765
|
+
lines.push('你的任務是讀取多份獨立分析報告,按照指定的整合策略產出最終報告。');
|
|
1766
|
+
lines.push('你不是成員之一,你是整合者。你不偏袒任何一方。');
|
|
1767
|
+
lines.push('');
|
|
1768
|
+
|
|
1769
|
+
// Principles(整合者也必須遵守的硬規則)
|
|
1770
|
+
if (skillDef.principles) {
|
|
1771
|
+
lines.push('## Principles (整合時也必須遵守)');
|
|
1772
|
+
if (skillDef.principles.focus) {
|
|
1773
|
+
lines.push(skillDef.principles.focus.trim());
|
|
1774
|
+
lines.push('');
|
|
1775
|
+
}
|
|
1776
|
+
if (skillDef.principles.forbidden && skillDef.principles.forbidden.length > 0) {
|
|
1777
|
+
lines.push('**禁止 (違反即失敗)**:');
|
|
1778
|
+
for (const f of skillDef.principles.forbidden) lines.push(`- ❌ ${f}`);
|
|
1779
|
+
lines.push('');
|
|
1780
|
+
}
|
|
1781
|
+
if (skillDef.principles.required && skillDef.principles.required.length > 0) {
|
|
1782
|
+
lines.push('**必須遵守**:');
|
|
1783
|
+
for (const r of skillDef.principles.required) lines.push(`- ✅ ${r}`);
|
|
1784
|
+
lines.push('');
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
// Merge strategy
|
|
1789
|
+
if (merge) {
|
|
1790
|
+
lines.push(`## Merge Strategy: ${merge.strategy || 'default'}`);
|
|
1791
|
+
if (merge.description) {
|
|
1792
|
+
lines.push(merge.description.trim());
|
|
1793
|
+
}
|
|
1794
|
+
lines.push('');
|
|
1795
|
+
|
|
1796
|
+
// Merge steps — 核心指令
|
|
1797
|
+
if (merge.steps && merge.steps.length > 0) {
|
|
1798
|
+
lines.push('## Merge Steps (按順序執行)');
|
|
1799
|
+
lines.push('');
|
|
1800
|
+
for (const step of merge.steps) {
|
|
1801
|
+
lines.push(`### Step: ${step.step}`);
|
|
1802
|
+
if (step.action) lines.push(step.action.trim());
|
|
1803
|
+
if (step.on_partial_failure) {
|
|
1804
|
+
lines.push(`**Partial Failure Handling**: ${step.on_partial_failure.trim()}`);
|
|
1805
|
+
}
|
|
1806
|
+
lines.push('');
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
// Reports location
|
|
1812
|
+
const reportPath = `.formation/reports/${reportDir}`;
|
|
1813
|
+
lines.push('## Reports Location');
|
|
1814
|
+
lines.push(`所有成員報告位於 \`${reportPath}/\` 目錄。`);
|
|
1815
|
+
lines.push('');
|
|
1816
|
+
lines.push('**執行步驟**:');
|
|
1817
|
+
lines.push(`1. 用 Glob 工具掃描 \`${reportPath}/*.md\``);
|
|
1818
|
+
lines.push('2. 排除 synthesis.md(那是你要寫的輸出)');
|
|
1819
|
+
lines.push('3. 用 Read 工具逐一讀取每份報告');
|
|
1820
|
+
lines.push('4. 按照上述 Merge Steps 逐步整合');
|
|
1821
|
+
lines.push('');
|
|
1822
|
+
|
|
1823
|
+
// Squad members for context
|
|
1824
|
+
if (skillDef.members && skillDef.members.length > 0) {
|
|
1825
|
+
lines.push('## Squad Members(供參考)');
|
|
1826
|
+
for (const m of skillDef.members) {
|
|
1827
|
+
const roleFirstLine = (typeof m.role === 'string' ? m.role.split('\n')[0].trim() : m.name);
|
|
1828
|
+
lines.push(`- **${m.name}** (${m.id}): ${roleFirstLine}`);
|
|
1829
|
+
}
|
|
1830
|
+
lines.push('');
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
// Output
|
|
1834
|
+
lines.push('## Output');
|
|
1835
|
+
lines.push(`將整合報告寫入 \`${reportPath}/synthesis.md\``);
|
|
1836
|
+
lines.push('');
|
|
1837
|
+
lines.push('報告格式依 Merge Strategy 而定。確保報告完整、結構清晰、附上各成員的核心觀點摘要。');
|
|
1838
|
+
lines.push('');
|
|
1839
|
+
|
|
1840
|
+
// No taskData in scope (post-hoc synthesis, not a dispatched task card) —
|
|
1841
|
+
// rigor/complexity both normalize to 'medium', landing in the compact-ritual
|
|
1842
|
+
// branch (TASK_1998 two-axis policy).
|
|
1843
|
+
appendCognitiveCheckpoint(lines, null, options);
|
|
1844
|
+
|
|
1845
|
+
return lines.join('\n');
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
// ─────────────────────────────────────────
|
|
1849
|
+
// Squad Debate:Round 2 交叉辯論 prompt
|
|
1850
|
+
// ─────────────────────────────────────────
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* 組裝 Squad Round 2 Debate prompts
|
|
1854
|
+
* 每個成員讀取其他人的 Round 1 報告,寫出針對性回應
|
|
1855
|
+
* @param {object} skillDef - Squad YAML 定義
|
|
1856
|
+
* @param {string} reportDir - 報告目錄名稱
|
|
1857
|
+
* @returns {{ memberId: string, prompt: string, skill: string }[]}
|
|
1858
|
+
*/
|
|
1859
|
+
function buildSquadDebatePrompts(skillDef, reportDir) {
|
|
1860
|
+
const members = skillDef.members || [];
|
|
1861
|
+
const debate = skillDef.debate || {};
|
|
1862
|
+
const reportPath = `.formation/reports/${reportDir}`;
|
|
1863
|
+
|
|
1864
|
+
return members.map(member => {
|
|
1865
|
+
const lines = [];
|
|
1866
|
+
const otherMembers = members.filter(m => m.id !== member.id);
|
|
1867
|
+
|
|
1868
|
+
// Role reminder
|
|
1869
|
+
lines.push('## Role');
|
|
1870
|
+
lines.push(`你是 **${member.name}**,這是你的第二輪分析(辯論回合)。`);
|
|
1871
|
+
lines.push('');
|
|
1872
|
+
|
|
1873
|
+
// Original stance
|
|
1874
|
+
const roleFirstLine = typeof member.role === 'string' ? member.role.split('\n')[0].trim() : '';
|
|
1875
|
+
if (roleFirstLine) {
|
|
1876
|
+
lines.push('## 你的立場(簡要提醒)');
|
|
1877
|
+
lines.push(roleFirstLine);
|
|
1878
|
+
lines.push('');
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
// Debate instructions (per-member)
|
|
1882
|
+
if (member.debate_instructions) {
|
|
1883
|
+
lines.push('## Debate Instructions');
|
|
1884
|
+
lines.push(member.debate_instructions.trim());
|
|
1885
|
+
lines.push('');
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
// Debate rules (squad-wide)
|
|
1889
|
+
if (debate.rules && debate.rules.length > 0) {
|
|
1890
|
+
lines.push('## Debate Rules');
|
|
1891
|
+
for (const rule of debate.rules) {
|
|
1892
|
+
lines.push(`- ${rule}`);
|
|
1893
|
+
}
|
|
1894
|
+
lines.push('');
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
// Reports to read
|
|
1898
|
+
lines.push('## Reports to Read');
|
|
1899
|
+
for (const other of otherMembers) {
|
|
1900
|
+
lines.push(`- **${other.name}**: \`${reportPath}/${other.id}.md\``);
|
|
1901
|
+
}
|
|
1902
|
+
lines.push('');
|
|
1903
|
+
lines.push('用 Read 工具讀取上述報告,然後寫出你的回應。');
|
|
1904
|
+
lines.push(`你自己的 Round 1 報告在 \`${reportPath}/${member.id}.md\`,可以參考但不需要重複。`);
|
|
1905
|
+
lines.push('');
|
|
1906
|
+
|
|
1907
|
+
// Output
|
|
1908
|
+
lines.push('## Output');
|
|
1909
|
+
lines.push(`將反駁報告寫入 \`${reportPath}/${member.id}-r2.md\``);
|
|
1910
|
+
lines.push('');
|
|
1911
|
+
|
|
1912
|
+
return {
|
|
1913
|
+
memberId: `${member.id}-r2`,
|
|
1914
|
+
prompt: lines.join('\n'),
|
|
1915
|
+
skill: member.skill || 'do'
|
|
1916
|
+
};
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
// ─────────────────────────────────────────
|
|
1921
|
+
// Headless 模式常數
|
|
1922
|
+
// ─────────────────────────────────────────
|
|
1923
|
+
|
|
1924
|
+
// TASK_1712: Rewritten with honest provenance framing so safety-hardened models
|
|
1925
|
+
// (claude-sonnet-5) read this as legitimate orchestration context rather than injection.
|
|
1926
|
+
// Behavioral constraints are fully preserved — only the framing changed.
|
|
1927
|
+
// Key changes: (1) opened with machine-assembly provenance declaration, (2) replaced
|
|
1928
|
+
// "don't read CLAUDE.md" with why Formation supplies its own rule set, (3) replaced
|
|
1929
|
+
// "don't ask questions" with "no human is watching — report and exit if blocked",
|
|
1930
|
+
// (4) replaced concealment wording in git rule with safety-rationale explanation.
|
|
1931
|
+
// TASK_1784 (DEFECT-A): Rule 6 was a categorical git ban that contradicted the workflow's
|
|
1932
|
+
// mandated commit step (do.yaml "提交變更": git add -A && git commit --no-verify). Literal-obedience
|
|
1933
|
+
// models (gpt-5.6-sol) obeyed the ban, produced zero commits, and tripped the leak detector on
|
|
1934
|
+
// every unmodified bifrost dispatch (TASK_1779 A/B-proven). Rule 6 now carves out exactly the
|
|
1935
|
+
// workflow commit command shape and nothing else; all other git subcommands stay forbidden.
|
|
1936
|
+
const HEADLESS_PREFIX = `## Automated Dispatch Context
|
|
1937
|
+
This prompt was machine-assembled by the Kenaz orchestration system, which is owned and
|
|
1938
|
+
operated by the repository owner. It runs unattended via \`claude -p\` (no interactive user
|
|
1939
|
+
is watching the output stream). The task brief below was authored and approved by the user
|
|
1940
|
+
before this automated run was triggered.
|
|
1941
|
+
|
|
1942
|
+
## Operating Rules
|
|
1943
|
+
1. Start with a one-line summary: "📋 {TASK_ID}: {what you are about to do}" (<=30 words). Then proceed.
|
|
1944
|
+
2. Execute directly — do not ask clarifying questions. Requirements were confirmed before dispatch.
|
|
1945
|
+
If you are blocked by a genuine ambiguity, document the blocker in your output and exit; a human will read the log.
|
|
1946
|
+
3. Formation supplies its own rule set (see ## Role / ## Task below), so the project CLAUDE.md
|
|
1947
|
+
is not the active instruction source for this run. Rely on the content in this prompt.
|
|
1948
|
+
4. Produce structured output when finished.
|
|
1949
|
+
5. On unrecoverable errors: describe what failed and exit. Do not attempt open-ended retries.
|
|
1950
|
+
6. **Git is restricted to the workflow's own commit step — nothing else.** Exactly two git commands
|
|
1951
|
+
are permitted, and only when the ## Workflow section below explicitly lists them as a step:
|
|
1952
|
+
the "git add ..." staging command and the "git commit --no-verify -m <message>" that follows it,
|
|
1953
|
+
run EXACTLY as shown in that workflow step — stage only what that step specifies, never more —
|
|
1954
|
+
on the branch this session started on, without switching branches.
|
|
1955
|
+
When the workflow lists that commit step you MUST execute it — this rule does not cancel it.
|
|
1956
|
+
Every other git subcommand is forbidden: do not run git checkout, git branch, git merge,
|
|
1957
|
+
git push, git rebase, git stash, git reset, or anything else. Branch, merge, and push management
|
|
1958
|
+
is handled exclusively by the Formation Lead after the task completes, to prevent
|
|
1959
|
+
cross-repository contamination when multiple agents run in parallel against different project paths.
|
|
1960
|
+
7. **Handle exactly the task specified in ## Task below.** Do not discover or claim other tasks.
|
|
1961
|
+
One agent — one task.
|
|
1962
|
+
8. Do not read the task directory directly (.collaboration/tasks/ or .kenaz/tasks/). Use task-api.js.
|
|
1963
|
+
9. Only complete the task assigned to you (see ## Task for the Task ID). Do not mark other tasks done.
|
|
1964
|
+
|
|
1965
|
+
`;
|
|
1966
|
+
// TASK_1833: rules 12-14 are shared VERBATIM across all sub-agent prefixes
|
|
1967
|
+
// (worktree / direct-write / cross-project-worktree). The only variance is
|
|
1968
|
+
// which rule number the commit instruction lives under. Kept as one template
|
|
1969
|
+
// so the three prefixes cannot drift apart (coupling rule: no near-duplicate
|
|
1970
|
+
// parallel impls).
|
|
1971
|
+
const subagentAsyncRules = (commitRuleNo) => `12. **⚠️ 你送出訊息就等於結束本次執行。** 你的最終訊息**就是**回傳值 —— 沒有「稍後回來接手」這回事。不要規劃「先讓出控制權、等背景工作完成再繼續」,那會直接結束你的執行並留下無人收拾的背景行程。
|
|
1972
|
+
13. **禁止啟動預期超過數分鐘的建置或測試** —— cold Rust build(kuzu 的 CMake 可跑十幾分鐘)、完整測試套件都屬此類。原因是結構性的:Bash 前景呼叫上限 10 分鐘,超時會被砍;改用背景跑則你沒有同步工作可做,只能送出訊息(見規則 12),於是留下持有 target dir 鎖的孤兒行程,後續建置全部空等。
|
|
1973
|
+
- **正確做法**:改完程式碼 → commit(規則 ${commitRuleNo})→ **直接回報結束**。在報告中寫明「未執行建置驗證」。
|
|
1974
|
+
- **Rust 建置驗證一律由主線程(Ansuz)負責** —— 主線程有熱快取、能跨 turn 輪詢、能診斷並清理孤兒行程。這是分工,不是你偷懶。
|
|
1975
|
+
- 這**不代表**你不必自我檢查。讀周邊程式碼、確認語法與型別、小範圍 grep 比對既有實作,這些輕量檢查仍然必須做。被禁止的只有「耗時數分鐘以上的建置與完整測試套件」。
|
|
1976
|
+
14. **禁止用 \`sleep\` 迴圈輪詢背景工作。** 這是規則 13 的同一個問題換一種寫法:你排下的 \`sleep\` 是獨立的 OS 行程,**你結束後它們不會跟著死**。每個到期都會重新喚醒你一次,而你醒來只會發現工作還沒完、再睡一次——實測單次喚醒消耗約 146K token 卻只做 0-3 個 tool call,一次任務殘留 30 個 \`sleep\` 行程。
|
|
1977
|
+
- 不要寫 \`while ...; do sleep N; done\`、不要 \`sleep 300 && check\`、不要用背景 job 搭配輪詢來等待建置或測試。
|
|
1978
|
+
- 需要等待就代表這件事不該由你做(見規則 13)。**commit 後直接回報結束**,把工作交給主線程。
|
|
1979
|
+
15. **禁止用 image name 殺行程。** \`taskkill /IM node.exe\`、\`Stop-Process -Name node\`、\`pkill -f node\` 之類的指令會殺掉整台機器上同名的所有行程 —— 2026-09-07 一個 agent 用 \`taskkill /F /IM node.exe /T\` 收拾自己卡住的測試,結果把用戶正在跑的 tauri dev(dashboard、next dev、MCP server)全部殺掉。
|
|
1980
|
+
- 只能殺你自己 spawn 的 PID(記下 \`$!\` 或 child pid,用 \`taskkill /PID <pid>\` / \`Stop-Process -Id\`)。
|
|
1981
|
+
- 測試可能卡住就一開始用 \`timeout <秒> <指令>\` 包起來,而不是事後找行程殺。
|
|
1982
|
+
- 不確定某個行程是誰的,就不要碰它,寫進報告交給主線程。`;
|
|
1983
|
+
|
|
1984
|
+
// TASK_1978 scaffold diet: hard-constraint bullets shared by SUBAGENT_PREFIX
|
|
1985
|
+
// and buildSubagentWorktreePrefix() — the WHY for each lives in
|
|
1986
|
+
// dispatch-detail/worktree-subagent-mode.md, not inline (kept out of the
|
|
1987
|
+
// hot prompt path; read it only when a rule is unclear). Deliberately
|
|
1988
|
+
// separate from subagentAsyncRules() above: that one still backs
|
|
1989
|
+
// SUBAGENT_PREFIX_DIRECT verbatim (untouched, out of TASK_1978 scope).
|
|
1990
|
+
const WORKTREE_DISPATCH_HARD_RULES = `2. CLAUDE.md 生效;完成輸出結果;卡住回報錯誤並結束。
|
|
1991
|
+
3. 改完立刻 commit(## Workflow,已排除 telemetry)-不等驗證;禁 push/切 branch/刪 worktree/stash/reset --hard。
|
|
1992
|
+
4. 送出訊息=結束;禁長建置/全測試(commit 後報未驗證,Rust 交 Ansuz);禁 sleep 輪詢;禁用 image name 殺行程(只殺自己 PID)。
|
|
1993
|
+
5. 只做指定任務;不讀任務目錄;只用 task-api.js;worktree 禁 complete。`;
|
|
1994
|
+
|
|
1995
|
+
// Sub-agent dispatch preamble — used when task is dispatched via Agent tool (isolation=worktree)
|
|
1996
|
+
// instead of claude -p (headless). Key differences from HEADLESS_PREFIX:
|
|
1997
|
+
// - Git IS allowed (worktree provides isolation; commits land on task branch, not user branch)
|
|
1998
|
+
// - CLAUDE.md IS active (running inside an interactive Claude Code session)
|
|
1999
|
+
// - Agent must commit changes to the worktree before returning
|
|
2000
|
+
const SUBAGENT_PREFIX = `[WORKTREE SUBAGENT MODE] 硬性規則:
|
|
2001
|
+
1. 先印摘要「📋 {TASK_ID}: {你準備做什麼}」,直接做,不問。
|
|
2002
|
+
${WORKTREE_DISPATCH_HARD_RULES}
|
|
2003
|
+
6. pwd 取得 worktree 路徑,Edit/Read/Write 皆用它,禁用主 repo 路徑。
|
|
2004
|
+
Details: .formation/tools/dispatch-detail/worktree-subagent-mode.md (Read only if needed)
|
|
2005
|
+
`;
|
|
2006
|
+
|
|
2007
|
+
// TASK_1672: Direct-write prefix for CROSS-PROJECT sub-agent dispatch.
|
|
2008
|
+
// Used when projectPath is a sub-project (projectPath !== ROOT).
|
|
2009
|
+
// In that case the Agent tool has NO worktree isolation — cwd is the sub-project's
|
|
2010
|
+
// real working tree. The agent must edit files at the absolute sub-project paths
|
|
2011
|
+
// given in the "## Project Context" section injected by buildPrompt().
|
|
2012
|
+
// Rules that reference worktree path-prefixing or "主 repo 路徑" are OMITTED
|
|
2013
|
+
// because they actively contradict the injected "Working directory: <subproject>" context.
|
|
2014
|
+
const SUBAGENT_PREFIX_DIRECT = `[DIRECT-WRITE SUBAGENT MODE]
|
|
2015
|
+
你已被 Ansuz 透過 Agent tool 指派任務,目標是一個**子專案** (sub-project)。規則:
|
|
2016
|
+
1. 開始前先輸出一行摘要:「📋 {TASK_ID}: {你準備做什麼}」(一句話,不超過 30 字)。然後再動手。
|
|
2017
|
+
2. 直接執行,不要提問。需求已經確認過了。
|
|
2018
|
+
3. CLAUDE.md 已啟用 — 遵循其規則(此為互動式 Claude Code 環境)。
|
|
2019
|
+
4. 完成後輸出結構化結果。
|
|
2020
|
+
5. 遇到無法執行的問題,輸出錯誤描述後結束。
|
|
2021
|
+
6. **工作目錄 = 子專案根目錄**(見 ## Project Context 的 "Working directory" 欄位)。
|
|
2022
|
+
- 使用該路徑作為 Edit/Read/Write 的絕對路徑前綴。
|
|
2023
|
+
- 不要自行猜測路徑;以 ## Project Context 注入的路徑為準。
|
|
2024
|
+
7. **Git 操作被允許且必要** — 你直接在子專案的**共用工作樹**提交(無 worktree 隔離):
|
|
2025
|
+
- **COMMIT FIRST(順序不可調換)**:改完程式碼就**立刻** \`git add <只列出你本次明確編輯過的檔案路徑> && git commit --no-verify -m "[{TASK_ID}] task completed"\`,**不要等驗證通過再 commit**。曾有兩個 agent 在建置中途結束、零 commit,工作全靠主線程手動搶救。寧可 commit 三次也不要一次都沒有。
|
|
2026
|
+
- ⚠️ **只 stage 你本次明確編輯過的檔案** — 你與使用者、其他 agent 共用同一個工作樹,嚴禁一次 stage 整個工作樹(TASK_188 曾因此把 392 個無關檔案掃進單一 commit)。
|
|
2027
|
+
- 禁止 git push 到遠端。不可切換 branch。
|
|
2028
|
+
${subagentAsyncRules(7)}
|
|
2029
|
+
8. **你只負責下方 ## Task 指定的那一個任務。** 不要讀取任務目錄去找其他任務、不要認領其他任務。
|
|
2030
|
+
9. 嚴禁直接讀取任務目錄(.collaboration/tasks/ 或 .kenaz/tasks/)。必須透過 task-api.js 操作任務。
|
|
2031
|
+
10. 只能操作你自己被指派的任務(見 ## Task 的 Task ID)。不要標記其他任務為完成。
|
|
2032
|
+
11. **禁止執行 task-api.js complete** — 任務完成由主 thread(Ansuz)在驗證後處理。
|
|
2033
|
+
|
|
2034
|
+
`;
|
|
2035
|
+
|
|
2036
|
+
/**
|
|
2037
|
+
* TASK_1833: prefix for CROSS-PROJECT sub-agent dispatch WITH worktree isolation.
|
|
2038
|
+
* The Agent tool's own isolation:'worktree' cannot isolate another repo — its
|
|
2039
|
+
* worktree derives from the CONVERSATION cwd repo (TASK_1672/1593), so
|
|
2040
|
+
* dispatch.js pre-creates a worktree INSIDE the target repo and this prefix
|
|
2041
|
+
* points the agent at it. Keeps the sub-agent (subscription) billing path
|
|
2042
|
+
* while gaining real isolation (no shared-tree index.lock collisions).
|
|
2043
|
+
* @param {string} worktreePath - absolute worktree path inside the target repo
|
|
2044
|
+
* @param {string} branchName - task branch checked out in the worktree
|
|
2045
|
+
* @param {string} projectPath - the target sub-project's MAIN working tree root
|
|
2046
|
+
* @returns {string}
|
|
2047
|
+
*/
|
|
2048
|
+
function buildSubagentWorktreePrefix(worktreePath, branchName, projectPath) {
|
|
2049
|
+
return `[CROSS-PROJECT WORKTREE SUBAGENT MODE] wt=${worktreePath} repo=${projectPath} branch=${branchName}
|
|
2050
|
+
1. 先印摘要「📋 {TASK_ID}: {你準備做什麼}」,直接做,不問。
|
|
2051
|
+
${WORKTREE_DISPATCH_HARD_RULES}
|
|
2052
|
+
6. 工作目錄=上述 worktree;Edit/Write、cd/git -C 皆用它;禁編輯主樹;Synapse projectPath 用 ${projectPath}。
|
|
2053
|
+
Details: .formation/tools/dispatch-detail/cross-project-worktree.md (Read only if needed)
|
|
2054
|
+
`;
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
const LEGION_SYSTEM_PREFIX = `You are the TEAM LEAD using Claude Code's OFFICIAL "agent teams" feature.
|
|
2058
|
+
|
|
2059
|
+
YOUR ROLE: Team Lead
|
|
2060
|
+
- You are RESPONSIBLE for this task's success or failure.
|
|
2061
|
+
- You MUST coordinate teammates and ensure they complete their work.
|
|
2062
|
+
- You CANNOT end the session until ALL teammates have reported back.
|
|
2063
|
+
- If you end early, the task FAILS and it's YOUR fault.
|
|
2064
|
+
|
|
2065
|
+
This is NOT the project's .formation/ directory system. Do NOT read .formation/ files.
|
|
2066
|
+
To create teammates, use natural language like: "Create a teammate named X who handles Y"
|
|
2067
|
+
Each teammate is a separate Claude instance running in parallel.
|
|
2068
|
+
|
|
2069
|
+
`;
|
|
2070
|
+
|
|
2071
|
+
const LEGION_AUTO_EXECUTE = `
|
|
2072
|
+
|
|
2073
|
+
BEFORE YOU START - OUTPUT YOUR PLAN:
|
|
2074
|
+
First, explain exactly what you will do step by step:
|
|
2075
|
+
1. What teammates will you create?
|
|
2076
|
+
2. How will you wait for their results?
|
|
2077
|
+
3. What tools will you use to poll for messages?
|
|
2078
|
+
4. When will you know all teammates are done?
|
|
2079
|
+
|
|
2080
|
+
RULES:
|
|
2081
|
+
1. Do NOT ask questions. Execute immediately after stating your plan.
|
|
2082
|
+
2. Do NOT read CLAUDE.md - this is a separate system.
|
|
2083
|
+
3. Create teammates using natural language descriptions.
|
|
2084
|
+
4. IMPORTANT: Use "sonnet" model for ALL teammates to reduce cost.
|
|
2085
|
+
|
|
2086
|
+
WAITING FOR TEAMMATES - CRITICAL:
|
|
2087
|
+
5. After spawning ALL teammates, you MUST enter a polling loop.
|
|
2088
|
+
6. In the loop: call "sleep 5" with Bash, then check if teammates sent messages.
|
|
2089
|
+
7. Teammates send results via SendMessage - you will see them as incoming user messages.
|
|
2090
|
+
8. Keep looping (sleep + check) until you have received messages from ALL teammates.
|
|
2091
|
+
9. Do NOT end until you have ACTUAL CONTENT from every single teammate.
|
|
2092
|
+
10. If a teammate is slow, keep waiting - do NOT give up or timeout early.
|
|
2093
|
+
11. Only after ALL teammates report back, synthesize their findings into final answer.`;
|
|
2094
|
+
|
|
2095
|
+
// ─────────────────────────────────────────
|
|
2096
|
+
// Legion Lead Prompt 組裝
|
|
2097
|
+
// ─────────────────────────────────────────
|
|
2098
|
+
|
|
2099
|
+
/**
|
|
2100
|
+
* 組裝 Legion Lead 的完整 headless prompt
|
|
2101
|
+
* 複製 Sunny teammate 的成功模式:
|
|
2102
|
+
* SYSTEM_PREFIX + 成員列表(自然語言)+ 任務 + AUTO_EXECUTE
|
|
2103
|
+
*/
|
|
2104
|
+
function buildLegionLeadPrompt(config) {
|
|
2105
|
+
let prompt = LEGION_SYSTEM_PREFIX;
|
|
2106
|
+
|
|
2107
|
+
prompt += `Create an agent team with ${config.members.length} teammates:\n`;
|
|
2108
|
+
config.members.forEach((m, i) => {
|
|
2109
|
+
const lines = m.prompt.split('\n');
|
|
2110
|
+
const roleIdx = lines.findIndex(l => l.startsWith('## Role'));
|
|
2111
|
+
let desc = m.name;
|
|
2112
|
+
if (roleIdx >= 0) {
|
|
2113
|
+
for (let j = roleIdx + 1; j < lines.length && j < roleIdx + 5; j++) {
|
|
2114
|
+
const line = lines[j].trim();
|
|
2115
|
+
if (line && !line.startsWith('#')) { desc = line; break; }
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
prompt += `${i + 1}. "${m.name}" - ${desc}\n`;
|
|
2119
|
+
});
|
|
2120
|
+
prompt += '\n';
|
|
2121
|
+
|
|
2122
|
+
const taskMatch = config.lead.prompt.match(/## Task\n([\s\S]*?)(?=\n##|$)/);
|
|
2123
|
+
if (taskMatch) {
|
|
2124
|
+
prompt += `Task: ${taskMatch[1].trim()}\n`;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
prompt += LEGION_AUTO_EXECUTE;
|
|
2128
|
+
return prompt;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
module.exports = {
|
|
2132
|
+
recordSkillUsage,
|
|
2133
|
+
buildPrompt, buildSquadSynthesisPrompt, buildSquadDebatePrompts,
|
|
2134
|
+
buildLegionLeadPrompt,
|
|
2135
|
+
resolveModules,
|
|
2136
|
+
HEADLESS_PREFIX,
|
|
2137
|
+
SUBAGENT_PREFIX,
|
|
2138
|
+
SUBAGENT_PREFIX_DIRECT,
|
|
2139
|
+
buildSubagentWorktreePrefix,
|
|
2140
|
+
// TASK_1978: exported for direct unit-testing of the compressed ceremony
|
|
2141
|
+
// sections (byte budget + hard-constraint presence), without exercising
|
|
2142
|
+
// the full buildUnitPrompt pipeline (which touches memory/cortex/episodic
|
|
2143
|
+
// context and needs a live project).
|
|
2144
|
+
appendCognitiveCheckpoint,
|
|
2145
|
+
// TASK_1992: exported for direct unit-testing of the Alaya process-lessons
|
|
2146
|
+
// section with an injected mcpCaller stub (no live MCP dependency).
|
|
2147
|
+
buildTaskContextQuery,
|
|
2148
|
+
appendAlayaLessons,
|
|
2149
|
+
// TASK_2101: exported for direct unit-testing of the absolute-relevance
|
|
2150
|
+
// gate (cosine floor + stack match) that appendAlayaLessons applies before
|
|
2151
|
+
// any bija is rendered into the dispatch prompt.
|
|
2152
|
+
deriveTaskStack,
|
|
2153
|
+
deriveBijaStack,
|
|
2154
|
+
passesAlayaRelevanceGate,
|
|
2155
|
+
ALAYA_MIN_COSINE_DEFAULT,
|
|
2156
|
+
ALAYA_STACK_OVERRIDE_COSINE,
|
|
2157
|
+
ALAYA_CANDIDATE_POOL,
|
|
2158
|
+
// TASK_1998: exported for dispatch.js (Related Files Preview gating,
|
|
2159
|
+
// prompt-byte-stats telemetry) and for direct unit-testing of the
|
|
2160
|
+
// two-axis prompt policy (context volume by complexity, process
|
|
2161
|
+
// strictness by rigor).
|
|
2162
|
+
promptProfile,
|
|
2163
|
+
extractRigor,
|
|
2164
|
+
extractComplexity,
|
|
2165
|
+
splitPromptSections,
|
|
2166
|
+
// TASK_1998 R2 follow-up: exported for direct unit-testing of Known
|
|
2167
|
+
// Failures/Project Memory rigor gating against the real .failure/.memory
|
|
2168
|
+
// dirs (no live-project mocking needed).
|
|
2169
|
+
appendMemoryContext,
|
|
2170
|
+
// TASK_2082: exported for direct unit-testing of the Rust-check reminder
|
|
2171
|
+
// gate (scope detection + core-crate existence + isolated-worktree gate)
|
|
2172
|
+
// without needing a live dashboard/src-tauri checkout on the test machine.
|
|
2173
|
+
hasRustScope,
|
|
2174
|
+
appendRustCheckReminder,
|
|
2175
|
+
// TASK_2082: exported so prompt.test.js can exercise the commit-step +
|
|
2176
|
+
// Rust-check-reminder wiring directly, without paying for buildUnitPrompt's
|
|
2177
|
+
// other live-project-dependent appends (memory/cortex/episodic context).
|
|
2178
|
+
appendWorkflow,
|
|
2179
|
+
// TASK_2082 defect fix: exported for dispatch.js to call at the prefix +
|
|
2180
|
+
// body composition point (rewrites hard rule 4's wording in-place instead
|
|
2181
|
+
// of relying on "later instructions win"), and for direct unit-testing.
|
|
2182
|
+
applyRustCheckToPrefix,
|
|
2183
|
+
};
|