@voybio/ace-swarm 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/LICENSE +186 -0
- package/README.md +229 -0
- package/assets/.agents/ACE/ACE-Init/AGENTS.md +210 -0
- package/assets/.agents/ACE/ACE-Init/instructions.md +118 -0
- package/assets/.agents/ACE/ACE_coders/AGENTS.md +154 -0
- package/assets/.agents/ACE/ACE_coders/INSTRUCTIONS.md +216 -0
- package/assets/.agents/ACE/AGENT_REGISTRY.md +70 -0
- package/assets/.agents/ACE/AGENT_REGISTRY_7.md +9 -0
- package/assets/.agents/ACE/DIRECTIVE_KERNEL.md +234 -0
- package/assets/.agents/ACE/UI/AGENTS.md +115 -0
- package/assets/.agents/ACE/UI/instructions.md +178 -0
- package/assets/.agents/ACE/VOS/ACE_VOS_MISSING_INFO_MATRIX.md +42 -0
- package/assets/.agents/ACE/VOS/AGENTS.md +72 -0
- package/assets/.agents/ACE/VOS/instructions.md +211 -0
- package/assets/.agents/ACE/agent-astgrep/AGENTS.md +123 -0
- package/assets/.agents/ACE/agent-astgrep/instructions.md +91 -0
- package/assets/.agents/ACE/agent-builder/AGENTS.md +172 -0
- package/assets/.agents/ACE/agent-builder/instructions.md +137 -0
- package/assets/.agents/ACE/agent-docs/AGENTS.md +159 -0
- package/assets/.agents/ACE/agent-docs/instructions.md +133 -0
- package/assets/.agents/ACE/agent-eval/AGENTS.md +46 -0
- package/assets/.agents/ACE/agent-eval/instructions.md +56 -0
- package/assets/.agents/ACE/agent-memory/AGENTS.md +49 -0
- package/assets/.agents/ACE/agent-memory/instructions.md +50 -0
- package/assets/.agents/ACE/agent-observability/AGENTS.md +46 -0
- package/assets/.agents/ACE/agent-observability/instructions.md +50 -0
- package/assets/.agents/ACE/agent-ops/AGENTS.md +201 -0
- package/assets/.agents/ACE/agent-ops/instructions.md +136 -0
- package/assets/.agents/ACE/agent-qa/AGENTS.md +189 -0
- package/assets/.agents/ACE/agent-qa/instructions.md +121 -0
- package/assets/.agents/ACE/agent-release/AGENTS.md +48 -0
- package/assets/.agents/ACE/agent-release/instructions.md +49 -0
- package/assets/.agents/ACE/agent-research/AGENTS.md +160 -0
- package/assets/.agents/ACE/agent-research/instructions.md +118 -0
- package/assets/.agents/ACE/agent-security/AGENTS.md +48 -0
- package/assets/.agents/ACE/agent-security/instructions.md +50 -0
- package/assets/.agents/ACE/agent-skeptic/AGENTS.md +178 -0
- package/assets/.agents/ACE/agent-skeptic/instructions.md +196 -0
- package/assets/.agents/ACE/agent-spec/AGENTS.md +169 -0
- package/assets/.agents/ACE/agent-spec/instructions.md +116 -0
- package/assets/.agents/ACE/orchestrator/AGENTS.md +365 -0
- package/assets/.agents/ACE/orchestrator/instructions.md +231 -0
- package/assets/.agents/skills/ace-orchestrator/SKILL.md +63 -0
- package/assets/.agents/skills/ace-orchestrator/references/engineering-bootstrap-playbook.md +360 -0
- package/assets/.agents/skills/astgrep-index/SKILL.md +58 -0
- package/assets/.agents/skills/codemunch/SKILL.md +65 -0
- package/assets/.agents/skills/codemunch/references/ast-driven-protocol.md +543 -0
- package/assets/.agents/skills/codesnipe/SKILL.md +64 -0
- package/assets/.agents/skills/codesnipe/references/dual-codebase-playbook.md +671 -0
- package/assets/.agents/skills/eval-harness/SKILL.md +203 -0
- package/assets/.agents/skills/handoff-lint/SKILL.md +164 -0
- package/assets/.agents/skills/incident-commander/SKILL.md +174 -0
- package/assets/.agents/skills/landing-review-watcher/SKILL.md +68 -0
- package/assets/.agents/skills/memory-curator/SKILL.md +179 -0
- package/assets/.agents/skills/problem-triage/SKILL.md +57 -0
- package/assets/.agents/skills/problem-triage/agents/openai.yaml +3 -0
- package/assets/.agents/skills/release-sentry/SKILL.md +189 -0
- package/assets/.agents/skills/risk-quant/SKILL.md +190 -0
- package/assets/.agents/skills/schema-forge/SKILL.md +174 -0
- package/assets/.agents/skills/skill-auditor/SKILL.md +52 -0
- package/assets/.agents/skills/state-auditor/SKILL.md +182 -0
- package/assets/.github/hooks/ace-copilot.json +68 -0
- package/assets/agent-state/ACE_WORKFLOW.md +131 -0
- package/assets/agent-state/ARTIFACT_MANIFEST.json +5 -0
- package/assets/agent-state/AST_GREP_COMMANDS.md +121 -0
- package/assets/agent-state/AST_GREP_INDEX.json +13 -0
- package/assets/agent-state/AST_GREP_INDEX.md +15 -0
- package/assets/agent-state/DECISIONS.md +7 -0
- package/assets/agent-state/EVIDENCE_LOG.md +7 -0
- package/assets/agent-state/HANDOFF.json +24 -0
- package/assets/agent-state/INTERFACE_REGISTRY.md +75 -0
- package/assets/agent-state/MODULES/gates/gate-autonomy.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-completeness.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-correctness.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-evaluation.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-operability.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-security.json +7 -0
- package/assets/agent-state/MODULES/gates/gate-typescript-public-surface.json +7 -0
- package/assets/agent-state/MODULES/registry.json +41 -0
- package/assets/agent-state/MODULES/roles/capability-astgrep.json +49 -0
- package/assets/agent-state/MODULES/roles/capability-build.json +39 -0
- package/assets/agent-state/MODULES/roles/capability-docs.json +38 -0
- package/assets/agent-state/MODULES/roles/capability-eval.json +20 -0
- package/assets/agent-state/MODULES/roles/capability-memory.json +20 -0
- package/assets/agent-state/MODULES/roles/capability-observability.json +20 -0
- package/assets/agent-state/MODULES/roles/capability-ops.json +45 -0
- package/assets/agent-state/MODULES/roles/capability-qa.json +40 -0
- package/assets/agent-state/MODULES/roles/capability-release.json +21 -0
- package/assets/agent-state/MODULES/roles/capability-research.json +44 -0
- package/assets/agent-state/MODULES/roles/capability-security.json +21 -0
- package/assets/agent-state/MODULES/roles/capability-skeptic.json +48 -0
- package/assets/agent-state/MODULES/roles/capability-spec.json +42 -0
- package/assets/agent-state/MODULES/schemas/ACE_RUNTIME_PROFILE.schema.json +289 -0
- package/assets/agent-state/MODULES/schemas/ARTIFACT_MANIFEST.schema.json +185 -0
- package/assets/agent-state/MODULES/schemas/HANDOFF.agent-state.schema.json +124 -0
- package/assets/agent-state/MODULES/schemas/HANDOFF.schema.json +55 -0
- package/assets/agent-state/MODULES/schemas/RUNTIME_EXECUTOR_SESSION_REGISTRY.schema.json +290 -0
- package/assets/agent-state/MODULES/schemas/RUNTIME_TOOL_SPEC_REGISTRY.schema.json +144 -0
- package/assets/agent-state/MODULES/schemas/STATUS_EVENT.schema.json +84 -0
- package/assets/agent-state/MODULES/schemas/SWARM_HANDOFF.schema.json +138 -0
- package/assets/agent-state/MODULES/schemas/TRACKER_SNAPSHOT.schema.json +134 -0
- package/assets/agent-state/MODULES/schemas/VERICIFY_BRIDGE_SNAPSHOT.schema.json +157 -0
- package/assets/agent-state/MODULES/schemas/VERICIFY_PROCESS_POST_LOG.schema.json +93 -0
- package/assets/agent-state/MODULES/schemas/WORKSPACE_SESSION_REGISTRY.schema.json +133 -0
- package/assets/agent-state/PROVENANCE_LOG.md +28 -0
- package/assets/agent-state/QUALITY_GATES.md +15 -0
- package/assets/agent-state/RISKS.md +8 -0
- package/assets/agent-state/SCOPE.md +20 -0
- package/assets/agent-state/SKILL_CATALOG.md +48 -0
- package/assets/agent-state/STATUS.md +8 -0
- package/assets/agent-state/STATUS_EVENTS.ndjson +1 -0
- package/assets/agent-state/TASK.md +18 -0
- package/assets/agent-state/TEAL_CONFIG.md +117 -0
- package/assets/agent-state/handoff-registry.json +5 -0
- package/assets/agent-state/index-fingerprints.json +7 -0
- package/assets/agent-state/index.json +32 -0
- package/assets/agent-state/run-ledger.json +5 -0
- package/assets/agent-state/runtime-executor-sessions.json +5 -0
- package/assets/agent-state/runtime-tool-specs.json +5 -0
- package/assets/agent-state/runtime-workspaces.json +5 -0
- package/assets/agent-state/todo-state.json +7 -0
- package/assets/agent-state/tracker-snapshot.json +7 -0
- package/assets/agent-state/vericify/ace-bridge.json +60 -0
- package/assets/agent-state/vericify/process-posts.json +5 -0
- package/assets/instructions/ACE.instructions.md +187 -0
- package/assets/instructions/ACE_Coder.instructions.md +146 -0
- package/assets/instructions/ACE_UI.instructions.md +178 -0
- package/assets/instructions/ACE_VOS.instructions.md +211 -0
- package/assets/scripts/ace-hook-dispatch.mjs +538 -0
- package/assets/scripts/bootstrap-workspace.sh +27 -0
- package/assets/scripts/copilot-hook-dispatch.mjs +3 -0
- package/assets/scripts/eval-harness.sh +68 -0
- package/assets/scripts/render-mcp-configs.sh +396 -0
- package/assets/tasks/README.md +48 -0
- package/assets/tasks/SWARM_HANDOFF.example.json +53 -0
- package/assets/tasks/SWARM_HANDOFF.example_ui_to_coders.json +55 -0
- package/assets/tasks/SWARM_HANDOFF.example_vos_to_ui.json +55 -0
- package/assets/tasks/SWARM_HANDOFF.template.json +52 -0
- package/assets/tasks/cli_work_split.md +22 -0
- package/assets/tasks/lessons.md +17 -0
- package/assets/tasks/role_tasks.md +206 -0
- package/assets/tasks/todo.md +23 -0
- package/dist/ace-autonomy.d.ts +137 -0
- package/dist/ace-autonomy.js +472 -0
- package/dist/ace-context.d.ts +29 -0
- package/dist/ace-context.js +240 -0
- package/dist/ace-internal-tools.d.ts +8 -0
- package/dist/ace-internal-tools.js +76 -0
- package/dist/ace-server-instructions.d.ts +12 -0
- package/dist/ace-server-instructions.js +324 -0
- package/dist/agent-runtime/role-adapters.d.ts +29 -0
- package/dist/agent-runtime/role-adapters.js +573 -0
- package/dist/astgrep-index.d.ts +24 -0
- package/dist/astgrep-index.js +476 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +591 -0
- package/dist/git-ops.d.ts +53 -0
- package/dist/git-ops.js +238 -0
- package/dist/handoff-registry.d.ts +71 -0
- package/dist/handoff-registry.js +422 -0
- package/dist/helpers.d.ts +126 -0
- package/dist/helpers.js +1687 -0
- package/dist/index-store.d.ts +51 -0
- package/dist/index-store.js +328 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/internal-tool-runtime.d.ts +21 -0
- package/dist/internal-tool-runtime.js +136 -0
- package/dist/job-scheduler.d.ts +175 -0
- package/dist/job-scheduler.js +1217 -0
- package/dist/kanban.d.ts +27 -0
- package/dist/kanban.js +339 -0
- package/dist/local-model-runtime.d.ts +40 -0
- package/dist/local-model-runtime.js +174 -0
- package/dist/model-bridge.d.ts +54 -0
- package/dist/model-bridge.js +587 -0
- package/dist/orchestrator-supervisor.d.ts +100 -0
- package/dist/orchestrator-supervisor.js +399 -0
- package/dist/problem-triage.d.ts +23 -0
- package/dist/problem-triage.js +448 -0
- package/dist/prompts.d.ts +7 -0
- package/dist/prompts.js +628 -0
- package/dist/public-surface.d.ts +30 -0
- package/dist/public-surface.js +316 -0
- package/dist/resources.d.ts +7 -0
- package/dist/resources.js +545 -0
- package/dist/run-ledger.d.ts +36 -0
- package/dist/run-ledger.js +257 -0
- package/dist/runtime-command.d.ts +18 -0
- package/dist/runtime-command.js +76 -0
- package/dist/runtime-executor.d.ts +104 -0
- package/dist/runtime-executor.js +985 -0
- package/dist/runtime-profile.d.ts +116 -0
- package/dist/runtime-profile.js +532 -0
- package/dist/runtime-tool-specs.d.ts +68 -0
- package/dist/runtime-tool-specs.js +527 -0
- package/dist/safe-edit.d.ts +52 -0
- package/dist/safe-edit.js +255 -0
- package/dist/schemas.d.ts +44 -0
- package/dist/schemas.js +830 -0
- package/dist/semantic-cache.d.ts +147 -0
- package/dist/semantic-cache.js +552 -0
- package/dist/semantic-hash.d.ts +83 -0
- package/dist/semantic-hash.js +346 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.js +46 -0
- package/dist/shared.d.ts +136 -0
- package/dist/shared.js +269 -0
- package/dist/skill-auditor.d.ts +26 -0
- package/dist/skill-auditor.js +184 -0
- package/dist/skill-catalog.d.ts +60 -0
- package/dist/skill-catalog.js +305 -0
- package/dist/status-events.d.ts +40 -0
- package/dist/status-events.js +269 -0
- package/dist/store/ace-packed-store.d.ts +69 -0
- package/dist/store/ace-packed-store.js +434 -0
- package/dist/store/bootstrap-store.d.ts +46 -0
- package/dist/store/bootstrap-store.js +242 -0
- package/dist/store/catalog-builder.d.ts +21 -0
- package/dist/store/catalog-builder.js +68 -0
- package/dist/store/importer.d.ts +19 -0
- package/dist/store/importer.js +157 -0
- package/dist/store/knowledge-bake.d.ts +59 -0
- package/dist/store/knowledge-bake.js +339 -0
- package/dist/store/materializers/hook-context-materializer.d.ts +25 -0
- package/dist/store/materializers/hook-context-materializer.js +100 -0
- package/dist/store/materializers/host-file-materializer.d.ts +37 -0
- package/dist/store/materializers/host-file-materializer.js +271 -0
- package/dist/store/materializers/todo-syncer.d.ts +30 -0
- package/dist/store/materializers/todo-syncer.js +140 -0
- package/dist/store/materializers/vericify-projector.d.ts +38 -0
- package/dist/store/materializers/vericify-projector.js +239 -0
- package/dist/store/repositories/discovery-repository.d.ts +24 -0
- package/dist/store/repositories/discovery-repository.js +58 -0
- package/dist/store/repositories/handoff-repository.d.ts +31 -0
- package/dist/store/repositories/handoff-repository.js +67 -0
- package/dist/store/repositories/ledger-repository.d.ts +26 -0
- package/dist/store/repositories/ledger-repository.js +49 -0
- package/dist/store/repositories/runtime-kv-repository.d.ts +16 -0
- package/dist/store/repositories/runtime-kv-repository.js +36 -0
- package/dist/store/repositories/scheduler-repository.d.ts +50 -0
- package/dist/store/repositories/scheduler-repository.js +123 -0
- package/dist/store/repositories/session-repository.d.ts +33 -0
- package/dist/store/repositories/session-repository.js +82 -0
- package/dist/store/repositories/todo-repository.d.ts +31 -0
- package/dist/store/repositories/todo-repository.js +77 -0
- package/dist/store/repositories/tracker-repository.d.ts +25 -0
- package/dist/store/repositories/tracker-repository.js +43 -0
- package/dist/store/repositories/vericify-repository.d.ts +32 -0
- package/dist/store/repositories/vericify-repository.js +58 -0
- package/dist/store/skills-install.d.ts +28 -0
- package/dist/store/skills-install.js +86 -0
- package/dist/store/state-reader.d.ts +49 -0
- package/dist/store/state-reader.js +111 -0
- package/dist/store/store-artifacts.d.ts +12 -0
- package/dist/store/store-artifacts.js +138 -0
- package/dist/store/store-snapshot.d.ts +19 -0
- package/dist/store/store-snapshot.js +140 -0
- package/dist/store/topology-bake.d.ts +15 -0
- package/dist/store/topology-bake.js +215 -0
- package/dist/store/types.d.ts +155 -0
- package/dist/store/types.js +35 -0
- package/dist/store/workspace-snapshot.d.ts +26 -0
- package/dist/store/workspace-snapshot.js +107 -0
- package/dist/store/write-queue.d.ts +7 -0
- package/dist/store/write-queue.js +26 -0
- package/dist/todo-state.d.ts +41 -0
- package/dist/todo-state.js +399 -0
- package/dist/tools-agent.d.ts +7 -0
- package/dist/tools-agent.js +1542 -0
- package/dist/tools-discovery.d.ts +6 -0
- package/dist/tools-discovery.js +178 -0
- package/dist/tools-drift.d.ts +13 -0
- package/dist/tools-drift.js +357 -0
- package/dist/tools-files.d.ts +6 -0
- package/dist/tools-files.js +679 -0
- package/dist/tools-framework.d.ts +7 -0
- package/dist/tools-framework.js +1414 -0
- package/dist/tools-git.d.ts +6 -0
- package/dist/tools-git.js +183 -0
- package/dist/tools-handoff.d.ts +32 -0
- package/dist/tools-handoff.js +489 -0
- package/dist/tools-lifecycle.d.ts +6 -0
- package/dist/tools-lifecycle.js +205 -0
- package/dist/tools-memory.d.ts +6 -0
- package/dist/tools-memory.js +260 -0
- package/dist/tools-scheduler.d.ts +6 -0
- package/dist/tools-scheduler.js +228 -0
- package/dist/tools-skills.d.ts +3 -0
- package/dist/tools-skills.js +104 -0
- package/dist/tools-todo.d.ts +6 -0
- package/dist/tools-todo.js +154 -0
- package/dist/tools.d.ts +9 -0
- package/dist/tools.js +33 -0
- package/dist/tracker-adapters.d.ts +74 -0
- package/dist/tracker-adapters.js +776 -0
- package/dist/tracker-sync.d.ts +10 -0
- package/dist/tracker-sync.js +84 -0
- package/dist/tui/agent-runner.d.ts +137 -0
- package/dist/tui/agent-runner.js +466 -0
- package/dist/tui/agent-worker.d.ts +10 -0
- package/dist/tui/agent-worker.js +347 -0
- package/dist/tui/chat.d.ts +84 -0
- package/dist/tui/chat.js +368 -0
- package/dist/tui/commands.d.ts +57 -0
- package/dist/tui/commands.js +432 -0
- package/dist/tui/dashboard.d.ts +24 -0
- package/dist/tui/dashboard.js +110 -0
- package/dist/tui/index.d.ts +114 -0
- package/dist/tui/index.js +1059 -0
- package/dist/tui/input.d.ts +49 -0
- package/dist/tui/input.js +336 -0
- package/dist/tui/layout.d.ts +116 -0
- package/dist/tui/layout.js +367 -0
- package/dist/tui/ollama.d.ts +116 -0
- package/dist/tui/ollama.js +192 -0
- package/dist/tui/openai-compatible.d.ts +63 -0
- package/dist/tui/openai-compatible.js +370 -0
- package/dist/tui/provider-discovery.d.ts +59 -0
- package/dist/tui/provider-discovery.js +530 -0
- package/dist/tui/renderer.d.ts +166 -0
- package/dist/tui/renderer.js +304 -0
- package/dist/tui/tabs.d.ts +70 -0
- package/dist/tui/tabs.js +208 -0
- package/dist/tui/telemetry.d.ts +56 -0
- package/dist/tui/telemetry.js +106 -0
- package/dist/vericify-bridge.d.ts +146 -0
- package/dist/vericify-bridge.js +571 -0
- package/dist/vericify-context.d.ts +10 -0
- package/dist/vericify-context.js +72 -0
- package/dist/workspace-manager.d.ts +107 -0
- package/dist/workspace-manager.js +636 -0
- package/package.json +83 -0
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
|
|
6
|
+
const DESTRUCTIVE_COMMAND_PATTERNS = [
|
|
7
|
+
/\brm\s+-rf\b/i,
|
|
8
|
+
/\bgit\s+reset\s+--hard\b/i,
|
|
9
|
+
/\bgit\s+checkout\s+--\b/i,
|
|
10
|
+
/\bgit\s+clean\s+-fdx\b/i,
|
|
11
|
+
/\bdel\s+\/s\s+\/q\b/i,
|
|
12
|
+
/\bdrop\s+table\b/i,
|
|
13
|
+
/\btruncate\s+table\b/i,
|
|
14
|
+
/\bmkfs\b/i,
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const ACE_ROOT = ".agents/ACE";
|
|
18
|
+
const ACE_STATE_DIRS = [
|
|
19
|
+
"agent-state",
|
|
20
|
+
"global-state",
|
|
21
|
+
"venture-state",
|
|
22
|
+
"brand-state",
|
|
23
|
+
"engineering-state",
|
|
24
|
+
];
|
|
25
|
+
const ACE_CORE_FILES = [
|
|
26
|
+
"agent-state/TASK.md",
|
|
27
|
+
"agent-state/STATUS.md",
|
|
28
|
+
"agent-state/SCOPE.md",
|
|
29
|
+
"agent-state/EVIDENCE_LOG.md",
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const PROTECTED_PATH_FRAGMENTS = [
|
|
33
|
+
".github/hooks/",
|
|
34
|
+
".github\\hooks\\",
|
|
35
|
+
".agents/ACE/scripts/ace/ace-hook-dispatch.mjs",
|
|
36
|
+
".agents\\ACE\\scripts\\ace\\ace-hook-dispatch.mjs",
|
|
37
|
+
".agents/ACE/scripts/ace/copilot-hook-dispatch.mjs",
|
|
38
|
+
".agents\\ACE\\scripts\\ace\\copilot-hook-dispatch.mjs",
|
|
39
|
+
"scripts/ace/ace-hook-dispatch.mjs",
|
|
40
|
+
"scripts\\ace\\ace-hook-dispatch.mjs",
|
|
41
|
+
"scripts/ace/copilot-hook-dispatch.mjs",
|
|
42
|
+
"scripts\\ace\\copilot-hook-dispatch.mjs",
|
|
43
|
+
".vscode/settings.json",
|
|
44
|
+
".vscode\\settings.json",
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const ROLE_TOOL_HINTS = {
|
|
48
|
+
orchestrator: ["recall_context", "route_task", "create_handoff", "execute_gates", "emit_status_event"],
|
|
49
|
+
coders: ["read_workspace_file", "safe_edit_file", "run_tests", "git_diff", "execute_gates"],
|
|
50
|
+
qa: ["read_workspace_file", "run_tests", "execute_gates", "git_diff", "append_vericify_process_post"],
|
|
51
|
+
docs: ["read_workspace_file", "write_workspace_file", "git_diff", "append_vericify_process_post"],
|
|
52
|
+
research: ["recall_context", "read_workspace_file", "build_continuity_packet", "append_vericify_process_post"],
|
|
53
|
+
spec: ["read_workspace_file", "write_workspace_file", "execute_gates", "append_vericify_process_post"],
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function readStdin() {
|
|
57
|
+
return new Promise((resolveStdin, reject) => {
|
|
58
|
+
let input = "";
|
|
59
|
+
process.stdin.setEncoding("utf8");
|
|
60
|
+
process.stdin.on("data", (chunk) => {
|
|
61
|
+
input += chunk;
|
|
62
|
+
});
|
|
63
|
+
process.stdin.on("end", () => resolveStdin(input));
|
|
64
|
+
process.stdin.on("error", reject);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function writeJson(payload) {
|
|
69
|
+
process.stdout.write(JSON.stringify(payload));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function toLowerText(value) {
|
|
73
|
+
return typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function safeJson(value) {
|
|
77
|
+
try {
|
|
78
|
+
return JSON.stringify(value ?? {});
|
|
79
|
+
} catch {
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function resolveWorkspaceRoot(payload) {
|
|
85
|
+
const cwd =
|
|
86
|
+
typeof payload.cwd === "string" && payload.cwd.trim() ? payload.cwd.trim() : process.cwd();
|
|
87
|
+
return resolve(cwd);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function mapAceRelativePath(relativePath) {
|
|
91
|
+
if (!relativePath) return relativePath;
|
|
92
|
+
const normalized = String(relativePath).replace(/\\/g, "/").replace(/^\.?\//, "");
|
|
93
|
+
if (!normalized) return normalized;
|
|
94
|
+
if (normalized === ACE_ROOT || normalized.startsWith(`${ACE_ROOT}/`)) {
|
|
95
|
+
return normalized;
|
|
96
|
+
}
|
|
97
|
+
for (const prefix of ["agent-state", "global-state", "venture-state", "brand-state", "engineering-state"]) {
|
|
98
|
+
if (normalized === prefix || normalized.startsWith(`${prefix}/`)) {
|
|
99
|
+
return `${ACE_ROOT}/${normalized}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return normalized;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function resolveAcePath(workspaceRoot, relativePath) {
|
|
106
|
+
const canonical = resolve(workspaceRoot, mapAceRelativePath(relativePath));
|
|
107
|
+
const normalized = String(relativePath).replace(/\\/g, "/").replace(/^\.?\//, "");
|
|
108
|
+
if (normalized && normalized !== mapAceRelativePath(relativePath)) {
|
|
109
|
+
const legacy = resolve(workspaceRoot, normalized);
|
|
110
|
+
if (!existsSync(canonical) && existsSync(legacy)) {
|
|
111
|
+
return legacy;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return canonical;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function readIfPresent(workspaceRoot, relativePath) {
|
|
118
|
+
const absolute = resolveAcePath(workspaceRoot, relativePath);
|
|
119
|
+
if (!existsSync(absolute)) return undefined;
|
|
120
|
+
try {
|
|
121
|
+
return readFileSync(absolute, "utf8");
|
|
122
|
+
} catch {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function oneLine(value) {
|
|
128
|
+
return String(value ?? "")
|
|
129
|
+
.replace(/\s+/g, " ")
|
|
130
|
+
.trim();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function truncate(value, max = 160) {
|
|
134
|
+
const text = oneLine(value);
|
|
135
|
+
if (text.length <= max) return text;
|
|
136
|
+
return `${text.slice(0, Math.max(0, max - 1)).trimEnd()}…`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function extractTaskObjective(workspaceRoot) {
|
|
140
|
+
const raw = readIfPresent(workspaceRoot, "agent-state/TASK.md");
|
|
141
|
+
if (!raw) return undefined;
|
|
142
|
+
const match = raw.match(/## Objective\s+([\s\S]*?)(?:\n## |\n# |$)/);
|
|
143
|
+
if (match?.[1]) {
|
|
144
|
+
return truncate(match[1]);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const bodyLine = raw
|
|
148
|
+
.split(/\r?\n/)
|
|
149
|
+
.map((line) => line.trim())
|
|
150
|
+
.find((line) => line && !line.startsWith("#"));
|
|
151
|
+
if (bodyLine) {
|
|
152
|
+
return truncate(bodyLine);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const heading = raw.match(/^#\s+(.+)$/m)?.[1];
|
|
156
|
+
return heading ? truncate(heading) : undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function extractStatusLine(workspaceRoot, label) {
|
|
160
|
+
const raw = readIfPresent(workspaceRoot, "agent-state/STATUS.md");
|
|
161
|
+
if (!raw) return undefined;
|
|
162
|
+
const pattern = new RegExp(`^- ${label}:\\s*(.+)$`, "m");
|
|
163
|
+
const match = raw.match(pattern);
|
|
164
|
+
return match?.[1] ? truncate(match[1]) : undefined;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function extractScopeReminder(workspaceRoot) {
|
|
168
|
+
const raw = readIfPresent(workspaceRoot, "agent-state/SCOPE.md");
|
|
169
|
+
if (!raw) return undefined;
|
|
170
|
+
const lines = raw
|
|
171
|
+
.split(/\r?\n/)
|
|
172
|
+
.map((line) => line.trim())
|
|
173
|
+
.filter(Boolean)
|
|
174
|
+
.filter((line) => !line.startsWith("#"));
|
|
175
|
+
if (lines.length === 0) {
|
|
176
|
+
return `ACE scope reminder: review ${ACE_ROOT}/agent-state/SCOPE.md before mutating files or state.`;
|
|
177
|
+
}
|
|
178
|
+
return `ACE scope reminder: ${truncate(lines.slice(0, 4).join(" "), 220)}`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function extractRoleHint(payload) {
|
|
182
|
+
const candidates = [
|
|
183
|
+
payload.role,
|
|
184
|
+
payload.agentRole,
|
|
185
|
+
payload.agent_role,
|
|
186
|
+
payload.subagentRole,
|
|
187
|
+
payload.subagent_role,
|
|
188
|
+
payload?.subagent?.role,
|
|
189
|
+
payload?.tool_input?.role,
|
|
190
|
+
];
|
|
191
|
+
for (const candidate of candidates) {
|
|
192
|
+
if (typeof candidate !== "string") continue;
|
|
193
|
+
const normalized = candidate.trim().toLowerCase().replace(/^agent-/, "");
|
|
194
|
+
if (normalized) return normalized;
|
|
195
|
+
}
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function buildRoleToolHint(role) {
|
|
200
|
+
const tools = ROLE_TOOL_HINTS[role];
|
|
201
|
+
if (!tools || tools.length === 0) return undefined;
|
|
202
|
+
return `Suggested ACE tools for ${role}: ${tools.join(", ")}.`;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Try to read the store-materialized hook context snapshot.
|
|
207
|
+
* Returns the parsed snapshot or undefined if not present / unreadable.
|
|
208
|
+
* When present this is the single authoritative source; the dispatcher
|
|
209
|
+
* never needs to open the .zarr store directly.
|
|
210
|
+
*/
|
|
211
|
+
function tryReadHookContextSnapshot(workspaceRoot) {
|
|
212
|
+
const snapshotPath = resolve(workspaceRoot, ACE_ROOT, "ace-hook-context.json");
|
|
213
|
+
if (!existsSync(snapshotPath)) return undefined;
|
|
214
|
+
try {
|
|
215
|
+
const raw = readFileSync(snapshotPath, "utf8");
|
|
216
|
+
const parsed = JSON.parse(raw);
|
|
217
|
+
if (parsed?.schema_version !== 1) return undefined;
|
|
218
|
+
return parsed;
|
|
219
|
+
} catch {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function aceContext(workspaceRoot) {
|
|
225
|
+
// ── Fast path: store-materialized snapshot ──────────────────────────────
|
|
226
|
+
const snapshot = tryReadHookContextSnapshot(workspaceRoot);
|
|
227
|
+
if (snapshot) {
|
|
228
|
+
const taskObjective = snapshot.task?.content
|
|
229
|
+
? truncate(snapshot.task.content.split("\n").find((l) => l.trim() && !l.startsWith("#")) ?? snapshot.task.content)
|
|
230
|
+
: undefined;
|
|
231
|
+
const scopeContent = snapshot.scope?.content ?? "";
|
|
232
|
+
const scopeLines = scopeContent.split(/\r?\n/).map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
233
|
+
const scopeReminder = scopeLines.length
|
|
234
|
+
? `ACE scope reminder: ${truncate(scopeLines.slice(0, 4).join(" "), 220)}`
|
|
235
|
+
: undefined;
|
|
236
|
+
const hasAgentState = existsSync(resolve(workspaceRoot, ACE_ROOT, "agent-state"));
|
|
237
|
+
const hasSkills = existsSync(resolve(workspaceRoot, ACE_ROOT, "skills")) ||
|
|
238
|
+
existsSync(resolve(workspaceRoot, ".agents", "skills"));
|
|
239
|
+
return {
|
|
240
|
+
coreFiles: [],
|
|
241
|
+
stateDirs: [],
|
|
242
|
+
taskObjective,
|
|
243
|
+
currentPhase: undefined,
|
|
244
|
+
blockers: undefined,
|
|
245
|
+
hasSkills,
|
|
246
|
+
hasAgentState,
|
|
247
|
+
scopeReminder,
|
|
248
|
+
activeAgents: snapshot.active_agents ?? [],
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// ── Legacy path: read individual markdown files ─────────────────────────
|
|
253
|
+
const stateDirs = ACE_STATE_DIRS
|
|
254
|
+
.map((relPath) => `${ACE_ROOT}/${relPath}`)
|
|
255
|
+
.filter((relPath) => existsSync(resolveAcePath(workspaceRoot, relPath)));
|
|
256
|
+
const coreFiles = ACE_CORE_FILES
|
|
257
|
+
.map((relPath) => `${ACE_ROOT}/${relPath}`)
|
|
258
|
+
.filter((relPath) => existsSync(resolveAcePath(workspaceRoot, relPath)));
|
|
259
|
+
|
|
260
|
+
const taskObjective = extractTaskObjective(workspaceRoot);
|
|
261
|
+
const currentPhase = extractStatusLine(workspaceRoot, "Current phase");
|
|
262
|
+
const blockers = extractStatusLine(workspaceRoot, "Blockers");
|
|
263
|
+
const hasSkills =
|
|
264
|
+
existsSync(resolve(workspaceRoot, ".agents", "ACE", "skills")) ||
|
|
265
|
+
existsSync(resolve(workspaceRoot, ".agents", "skills"));
|
|
266
|
+
const hasAgentState =
|
|
267
|
+
existsSync(resolve(workspaceRoot, ".agents", "ACE", "agent-state")) ||
|
|
268
|
+
existsSync(resolve(workspaceRoot, "agent-state"));
|
|
269
|
+
const scopeReminder = extractScopeReminder(workspaceRoot);
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
coreFiles,
|
|
273
|
+
stateDirs,
|
|
274
|
+
taskObjective,
|
|
275
|
+
currentPhase,
|
|
276
|
+
blockers,
|
|
277
|
+
hasSkills,
|
|
278
|
+
hasAgentState,
|
|
279
|
+
scopeReminder,
|
|
280
|
+
activeAgents: [],
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function readAutonomyHint(workspaceRoot) {
|
|
285
|
+
const workflowPath = resolveAcePath(workspaceRoot, "agent-state/ACE_WORKFLOW.md");
|
|
286
|
+
const defaultHint =
|
|
287
|
+
"Runtime autonomy defaults are active: orchestrator preflight, context recall.";
|
|
288
|
+
if (!existsSync(workflowPath)) return defaultHint;
|
|
289
|
+
|
|
290
|
+
let raw = "";
|
|
291
|
+
try {
|
|
292
|
+
raw = readFileSync(workflowPath, "utf8");
|
|
293
|
+
} catch {
|
|
294
|
+
return defaultHint;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const signals = [];
|
|
298
|
+
if (/^\s*orchestrator_preflight:\s*true\s*$/m.test(raw)) {
|
|
299
|
+
signals.push("orchestrator preflight");
|
|
300
|
+
}
|
|
301
|
+
if (/^\s*recall_context:\s*true\s*$/m.test(raw)) {
|
|
302
|
+
signals.push("context recall");
|
|
303
|
+
}
|
|
304
|
+
const reviewMode = raw.match(/^\s*review_mode:\s*["']?([A-Za-z0-9_-]+)["']?\s*$/m)?.[1];
|
|
305
|
+
if (reviewMode) {
|
|
306
|
+
signals.push(`review mode ${reviewMode}`);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return signals.length > 0
|
|
310
|
+
? `Runtime autonomy policy is active in ${ACE_ROOT}/agent-state/ACE_WORKFLOW.md: ${signals.join(", ")}.`
|
|
311
|
+
: defaultHint;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function buildAceMessage(workspaceRoot, options = {}) {
|
|
315
|
+
const context = aceContext(workspaceRoot);
|
|
316
|
+
if (!context.hasAgentState && !context.hasSkills) return "";
|
|
317
|
+
|
|
318
|
+
const parts = [];
|
|
319
|
+
if (context.coreFiles.length > 0) {
|
|
320
|
+
parts.push(`ACE workspace detected. Ground truth lives in ${context.coreFiles.join(", ")}.`);
|
|
321
|
+
} else if (context.hasAgentState) {
|
|
322
|
+
parts.push(`ACE workspace detected. Ground truth lives in ${ACE_ROOT}/agent-state/*.`);
|
|
323
|
+
}
|
|
324
|
+
if (context.taskObjective) {
|
|
325
|
+
parts.push(`Current task: ${context.taskObjective}.`);
|
|
326
|
+
}
|
|
327
|
+
if (context.currentPhase) {
|
|
328
|
+
parts.push(`Current phase: ${context.currentPhase}.`);
|
|
329
|
+
}
|
|
330
|
+
if (context.blockers) {
|
|
331
|
+
parts.push(`Blockers: ${context.blockers}.`);
|
|
332
|
+
}
|
|
333
|
+
if (context.stateDirs.length > 0) {
|
|
334
|
+
parts.push(
|
|
335
|
+
`Persist durable artifacts under ${context.stateDirs.map((dir) => `${dir}/`).join(", ")} rather than editor session caches such as workspaceStorage/.../chat-session-resources/.`
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
parts.push(
|
|
339
|
+
"Before major edits, read task, scope, and status artifacts rather than relying on chat history."
|
|
340
|
+
);
|
|
341
|
+
if (context.scopeReminder) {
|
|
342
|
+
parts.push(context.scopeReminder);
|
|
343
|
+
}
|
|
344
|
+
if (context.hasSkills) {
|
|
345
|
+
parts.push(`Workspace skills are available under ${ACE_ROOT}/skills/.`);
|
|
346
|
+
}
|
|
347
|
+
const autonomyHint = readAutonomyHint(workspaceRoot);
|
|
348
|
+
if (autonomyHint) {
|
|
349
|
+
parts.push(autonomyHint);
|
|
350
|
+
}
|
|
351
|
+
const roleHint = extractRoleHint(options.payload ?? {});
|
|
352
|
+
if (roleHint && (options.eventName === "SubagentStart" || options.eventName === "UserPromptSubmit")) {
|
|
353
|
+
parts.push(`Assigned ACE role: ${roleHint}.`);
|
|
354
|
+
const toolHint = buildRoleToolHint(roleHint);
|
|
355
|
+
if (toolHint) {
|
|
356
|
+
parts.push(toolHint);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
const promptText =
|
|
360
|
+
typeof options.payload?.prompt === "string" ? options.payload.prompt.trim() : "";
|
|
361
|
+
if (promptText && options.eventName === "UserPromptSubmit") {
|
|
362
|
+
parts.push(`Latest prompt: ${truncate(promptText, 180)}.`);
|
|
363
|
+
}
|
|
364
|
+
parts.push(
|
|
365
|
+
`ACE hook policy protects ${ACE_ROOT}/.github/hooks, ${ACE_ROOT}/.vscode/settings.json, and ${ACE_ROOT}/scripts/ace/*hook-dispatch.mjs from silent self-modification.`
|
|
366
|
+
);
|
|
367
|
+
return parts.join(" ");
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function isCommandTool(toolName) {
|
|
371
|
+
return ["terminal", "shell", "bash", "command", "execute", "run"].some((token) =>
|
|
372
|
+
toolName.includes(token)
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function isMutationTool(toolName) {
|
|
377
|
+
return [
|
|
378
|
+
"edit",
|
|
379
|
+
"write",
|
|
380
|
+
"create",
|
|
381
|
+
"replace",
|
|
382
|
+
"delete",
|
|
383
|
+
"rename",
|
|
384
|
+
"move",
|
|
385
|
+
"file",
|
|
386
|
+
"commit",
|
|
387
|
+
"dispatch",
|
|
388
|
+
"update",
|
|
389
|
+
"append",
|
|
390
|
+
].some((token) => toolName.includes(token));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function containsProtectedPath(text) {
|
|
394
|
+
const normalized = toLowerText(text);
|
|
395
|
+
return PROTECTED_PATH_FRAGMENTS.some((fragment) => normalized.includes(fragment.toLowerCase()));
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function containsDestructiveCommand(text) {
|
|
399
|
+
return DESTRUCTIVE_COMMAND_PATTERNS.some((pattern) => pattern.test(text));
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function resolvePreToolUse(payload, workspaceRoot) {
|
|
403
|
+
const toolName = toLowerText(payload.tool_name);
|
|
404
|
+
const serializedInput = safeJson(payload.tool_input);
|
|
405
|
+
|
|
406
|
+
if (isCommandTool(toolName) && containsDestructiveCommand(serializedInput)) {
|
|
407
|
+
return {
|
|
408
|
+
continue: true,
|
|
409
|
+
hookSpecificOutput: {
|
|
410
|
+
hookEventName: "PreToolUse",
|
|
411
|
+
permissionDecision: "deny",
|
|
412
|
+
permissionDecisionReason:
|
|
413
|
+
"Blocked by ACE hook policy: destructive shell command detected.",
|
|
414
|
+
additionalContext:
|
|
415
|
+
"Use a non-destructive alternative or ask for explicit confirmation before destructive terminal actions.",
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (isMutationTool(toolName) && containsProtectedPath(serializedInput)) {
|
|
421
|
+
return {
|
|
422
|
+
continue: true,
|
|
423
|
+
hookSpecificOutput: {
|
|
424
|
+
hookEventName: "PreToolUse",
|
|
425
|
+
permissionDecision: "ask",
|
|
426
|
+
permissionDecisionReason:
|
|
427
|
+
"Editing hook or control-plane files requires confirmation.",
|
|
428
|
+
additionalContext:
|
|
429
|
+
"This workspace treats hook files, dispatcher scripts, and VS Code settings as protected control-plane artifacts.",
|
|
430
|
+
},
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const message = buildAceMessage(workspaceRoot, {
|
|
435
|
+
payload,
|
|
436
|
+
eventName: "PreToolUse",
|
|
437
|
+
});
|
|
438
|
+
if (isMutationTool(toolName) && message) {
|
|
439
|
+
return {
|
|
440
|
+
continue: true,
|
|
441
|
+
hookSpecificOutput: {
|
|
442
|
+
hookEventName: "PreToolUse",
|
|
443
|
+
permissionDecision: "allow",
|
|
444
|
+
additionalContext: `${message} Confirm the target stays within scope before mutating files or state, and persist evidence after the change.`,
|
|
445
|
+
},
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return { continue: true };
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function resolvePostToolUse(payload, workspaceRoot) {
|
|
453
|
+
const toolName = toLowerText(payload.tool_name);
|
|
454
|
+
if (!isMutationTool(toolName)) {
|
|
455
|
+
return { continue: true };
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
const message = buildAceMessage(workspaceRoot, {
|
|
459
|
+
payload,
|
|
460
|
+
eventName: "PostToolUse",
|
|
461
|
+
});
|
|
462
|
+
return {
|
|
463
|
+
continue: true,
|
|
464
|
+
hookSpecificOutput: {
|
|
465
|
+
hookEventName: "PostToolUse",
|
|
466
|
+
additionalContext: message
|
|
467
|
+
? `${message} If project files or state changed, reconcile evidence, run the smallest relevant verification, and call execute_gates before concluding.`
|
|
468
|
+
: "If project files or state changed, run the smallest relevant verification and call execute_gates before concluding.",
|
|
469
|
+
},
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function resolveSessionContext(payload, workspaceRoot, eventName) {
|
|
474
|
+
const message = buildAceMessage(workspaceRoot, {
|
|
475
|
+
payload,
|
|
476
|
+
eventName,
|
|
477
|
+
});
|
|
478
|
+
if (!message) return { continue: true };
|
|
479
|
+
|
|
480
|
+
return {
|
|
481
|
+
continue: true,
|
|
482
|
+
hookSpecificOutput: {
|
|
483
|
+
hookEventName: eventName,
|
|
484
|
+
additionalContext: message,
|
|
485
|
+
},
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function resolveHook(payload) {
|
|
490
|
+
const eventName = toLowerText(payload.hookEventName);
|
|
491
|
+
const workspaceRoot = resolveWorkspaceRoot(payload);
|
|
492
|
+
|
|
493
|
+
if (eventName === "sessionstart") {
|
|
494
|
+
return resolveSessionContext(payload, workspaceRoot, "SessionStart");
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if (eventName === "subagentstart") {
|
|
498
|
+
return resolveSessionContext(payload, workspaceRoot, "SubagentStart");
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
if (eventName === "userpromptsubmit") {
|
|
502
|
+
return resolveSessionContext(payload, workspaceRoot, "UserPromptSubmit");
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
if (eventName === "pretooluse") {
|
|
506
|
+
return resolvePreToolUse(payload, workspaceRoot);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if (eventName === "posttooluse") {
|
|
510
|
+
return resolvePostToolUse(payload, workspaceRoot);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (eventName === "precompact") {
|
|
514
|
+
return resolveSessionContext(payload, workspaceRoot, "PreCompact");
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (eventName === "subagentstop" || eventName === "stop") {
|
|
518
|
+
return { continue: true };
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return { continue: true };
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
async function main() {
|
|
525
|
+
try {
|
|
526
|
+
const raw = await readStdin();
|
|
527
|
+
const payload = raw.trim() ? JSON.parse(raw) : {};
|
|
528
|
+
writeJson(resolveHook(payload));
|
|
529
|
+
} catch (error) {
|
|
530
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
531
|
+
writeJson({
|
|
532
|
+
continue: true,
|
|
533
|
+
systemMessage: `ACE hook warning: ${message}`,
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
main();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
LEGACY_ROOT="$(cd -- "${SCRIPT_DIR}/../.." && pwd)"
|
|
6
|
+
CANONICAL_ROOT="$(cd -- "${SCRIPT_DIR}/../../../.." && pwd)"
|
|
7
|
+
if [ -d "${CANONICAL_ROOT}/.agents/ACE" ] || [ ! -d "${LEGACY_ROOT}/.agents/ACE" ]; then
|
|
8
|
+
WORKSPACE_ROOT="${CANONICAL_ROOT}"
|
|
9
|
+
else
|
|
10
|
+
WORKSPACE_ROOT="${LEGACY_ROOT}"
|
|
11
|
+
fi
|
|
12
|
+
PROJECT_NAME="${1:-ACE Project}"
|
|
13
|
+
|
|
14
|
+
export ACE_WORKSPACE_ROOT="${WORKSPACE_ROOT}"
|
|
15
|
+
cd "${WORKSPACE_ROOT}"
|
|
16
|
+
|
|
17
|
+
if command -v ace >/dev/null 2>&1; then
|
|
18
|
+
ace init --project "$PROJECT_NAME"
|
|
19
|
+
exit 0
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
if command -v ace-swarm >/dev/null 2>&1; then
|
|
23
|
+
ace-swarm init --project "$PROJECT_NAME"
|
|
24
|
+
exit 0
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
npx -y ace-swarm init --project "$PROJECT_NAME"
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
ROOT="${ACE_WORKSPACE_ROOT:-$PWD}"
|
|
5
|
+
STAMP="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
|
6
|
+
OUT="$ROOT/.agents/ACE/agent-state/EVAL_REPORT.md"
|
|
7
|
+
|
|
8
|
+
mkdir -p "$ROOT/agent-state"
|
|
9
|
+
|
|
10
|
+
pass_count=0
|
|
11
|
+
fail_count=0
|
|
12
|
+
|
|
13
|
+
run_check() {
|
|
14
|
+
local name="$1"
|
|
15
|
+
shift
|
|
16
|
+
if "$@" >/tmp/ace_eval_last.out 2>/tmp/ace_eval_last.err; then
|
|
17
|
+
echo "- PASS: $name" >>"$OUT"
|
|
18
|
+
pass_count=$((pass_count + 1))
|
|
19
|
+
else
|
|
20
|
+
echo "- FAIL: $name" >>"$OUT"
|
|
21
|
+
echo " - stderr: $(tr '\n' ' ' </tmp/ace_eval_last.err | sed 's/ */ /g')" >>"$OUT"
|
|
22
|
+
fail_count=$((fail_count + 1))
|
|
23
|
+
fi
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
{
|
|
27
|
+
echo "# EVAL_REPORT"
|
|
28
|
+
echo
|
|
29
|
+
echo "Generated: $STAMP"
|
|
30
|
+
echo
|
|
31
|
+
echo "## Checks"
|
|
32
|
+
} >"$OUT"
|
|
33
|
+
|
|
34
|
+
# Resolve ace-swarm runtime: prefer local monorepo, fall back to npx-installed package
|
|
35
|
+
if [ -f "$ROOT/ace-mcp-server/dist/cli.js" ]; then
|
|
36
|
+
ACE_CLI="node $ROOT/ace-mcp-server/dist/cli.js"
|
|
37
|
+
ACE_IMPORT_PREFIX="./ace-mcp-server/dist"
|
|
38
|
+
elif command -v ace >/dev/null 2>&1; then
|
|
39
|
+
ACE_CLI="ace"
|
|
40
|
+
ACE_PKG_DIR="$(node -e "console.log(require.resolve('ace-swarm/package.json').replace('/package.json',''))")"
|
|
41
|
+
ACE_IMPORT_PREFIX="$ACE_PKG_DIR/dist"
|
|
42
|
+
else
|
|
43
|
+
ACE_CLI="npx --yes ace-swarm"
|
|
44
|
+
ACE_PKG_DIR="$(npx --yes ace-swarm paths 2>/dev/null | grep PACKAGE_ROOT | cut -d= -f2)"
|
|
45
|
+
ACE_IMPORT_PREFIX="$ACE_PKG_DIR/dist"
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
run_check "cli_paths" $ACE_CLI paths
|
|
49
|
+
run_check "schema_validation_smoke" node --input-type=module -e "import('${ACE_IMPORT_PREFIX}/schemas.js').then((m)=>{ const ok=m.validateStatusEventPayload({schema_version:'1.0.0',event_id:'evt-12345',trace_id:'trace-12345',timestamp:new Date().toISOString(),source_module:'capability-ops',event_type:'SMOKE',status:'pass',payload:{summary:'smoke'}}); if(!ok.ok) throw new Error(ok.errors.join('; ')); })"
|
|
50
|
+
run_check "index_delta_smoke" node --input-type=module -e "import('${ACE_IMPORT_PREFIX}/index-store.js').then((m)=>{ const r=m.scanWorkspaceDelta({path:'.',depth:2,max_files:500,file_entry_cap:0}); if(typeof r.snapshot.file_count !== 'number') throw new Error('invalid file_count'); if(!r.fingerprint_path) throw new Error('missing fingerprint path'); })"
|
|
51
|
+
|
|
52
|
+
{
|
|
53
|
+
echo
|
|
54
|
+
echo "## Summary"
|
|
55
|
+
echo "- Passed: $pass_count"
|
|
56
|
+
echo "- Failed: $fail_count"
|
|
57
|
+
echo
|
|
58
|
+
if [ "$fail_count" -eq 0 ]; then
|
|
59
|
+
echo "Verdict: PASS"
|
|
60
|
+
else
|
|
61
|
+
echo "Verdict: FAIL"
|
|
62
|
+
fi
|
|
63
|
+
} >>"$OUT"
|
|
64
|
+
|
|
65
|
+
if [ "$fail_count" -eq 0 ]; then
|
|
66
|
+
exit 0
|
|
67
|
+
fi
|
|
68
|
+
exit 1
|