@ornexus/neocortex 4.65.1 → 4.66.1
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/dist/release-source.json +1 -1
- package/dist/sbom.cdx.json +1206 -1193
- package/install.ps1 +243 -77
- package/install.sh +221 -102
- package/package.json +2 -2
- package/packages/client/dist/adapters/platform-detector.js +1 -1
- package/packages/client/dist/agent/refresh-stubs.d.ts +50 -0
- package/packages/client/dist/agent/refresh-stubs.js +2 -2
- package/packages/client/dist/cli.js +5 -4
- package/packages/client/dist/commands/doctor.d.ts +26 -1
- package/packages/client/dist/commands/doctor.js +2 -2
- package/packages/client/dist/commands/invoke.d.ts +183 -5
- package/packages/client/dist/commands/invoke.js +94 -87
- package/packages/client/dist/commands/planning-qa.d.ts +64 -0
- package/packages/client/dist/commands/planning-qa.js +1 -0
- package/packages/client/dist/commands/refactor-control.js +3 -3
- package/packages/client/dist/commands/story-checkpoint.d.ts +3 -1
- package/packages/client/dist/commands/story-checkpoint.js +1 -1
- package/packages/client/dist/commands/story-worktree.d.ts +1 -1
- package/packages/client/dist/commands/story-worktree.js +1 -1
- package/packages/client/dist/git/direct-yolo-checkpoint.d.ts +64 -1
- package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -3
- package/packages/client/dist/git/epic-lifecycle-evidence.d.ts +184 -0
- package/packages/client/dist/git/epic-lifecycle-evidence.js +6 -0
- package/packages/client/dist/git/git-lifecycle-store.d.ts +23 -0
- package/packages/client/dist/git/git-lifecycle-store.js +9 -8
- package/packages/client/dist/git/governance-runtime-store.d.ts +172 -0
- package/packages/client/dist/git/governance-runtime-store.js +3 -0
- package/packages/client/dist/git/story-worktree-cleanup.js +1 -1
- package/packages/client/dist/git/story-worktree-integration.js +3 -3
- package/packages/client/dist/git/story-worktree-manager.d.ts +39 -0
- package/packages/client/dist/git/story-worktree-manager.js +3 -3
- package/packages/client/dist/git/story-write-set-extension.d.ts +62 -0
- package/packages/client/dist/git/story-write-set-extension.js +1 -1
- package/packages/client/dist/memory/shared-project-memory-types.d.ts +39 -2
- package/packages/client/dist/memory/shared-project-memory-types.js +2 -2
- package/packages/client/dist/policy/subagent-approval-policy.js +1 -1
- package/packages/client/dist/private-execution/codex-executor.d.ts +21 -1
- package/packages/client/dist/private-execution/codex-executor.js +4 -4
- package/packages/client/dist/private-execution/delivery.d.ts +17 -11
- package/packages/client/dist/private-execution/delivery.js +8 -6
- package/packages/client/dist/private-execution/diagnosis-root-review.d.ts +89 -0
- package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -2
- package/packages/client/dist/private-execution/frozen-handoff.js +3 -3
- package/packages/client/dist/private-execution/harness-adapters/antigravity.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/antigravity.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/claude-code.d.ts +8 -0
- package/packages/client/dist/private-execution/harness-adapters/claude-code.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/codex.d.ts +7 -0
- package/packages/client/dist/private-execution/harness-adapters/codex.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/copilot-cli.d.ts +8 -0
- package/packages/client/dist/private-execution/harness-adapters/copilot-cli.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/cursor.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/cursor.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/deepseek.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/deepseek.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/gemini.d.ts +8 -0
- package/packages/client/dist/private-execution/harness-adapters/gemini.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/grok.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/grok.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/index.d.ts +73 -0
- package/packages/client/dist/private-execution/harness-adapters/index.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/kimi.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/kimi.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/openclaw.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/openclaw.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/opencode.d.ts +7 -0
- package/packages/client/dist/private-execution/harness-adapters/opencode.js +1 -0
- package/packages/client/dist/private-execution/harness-ephemeral-home.d.ts +19 -0
- package/packages/client/dist/private-execution/harness-ephemeral-home.js +1 -0
- package/packages/client/dist/private-execution/harness-executor.d.ts +79 -0
- package/packages/client/dist/private-execution/harness-executor.js +1 -0
- package/packages/client/dist/private-execution/harness-process.d.ts +43 -0
- package/packages/client/dist/private-execution/harness-process.js +1 -0
- package/packages/client/dist/private-execution/isolated-admission.js +12 -12
- package/packages/client/dist/private-execution/isolated-workspace.d.ts +16 -1
- package/packages/client/dist/private-execution/isolated-workspace.js +1 -1
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.d.ts +75 -1
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -5
- package/packages/client/dist/private-execution/planning-generation-checkpoint.d.ts +9 -1
- package/packages/client/dist/private-execution/planning-generation-checkpoint.js +4 -4
- package/packages/client/dist/private-execution/planning-research-checkpoint.d.ts +9 -1
- package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -4
- package/packages/client/dist/private-execution/root-memory-request.d.ts +4 -1
- package/packages/client/dist/private-execution/root-memory-request.js +1 -1
- package/packages/client/dist/runner/epic-background-dispatcher.d.ts +3 -1
- package/packages/client/dist/runner/epic-background-dispatcher.js +1 -1
- package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -1
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.d.ts +1 -22
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +6 -10
- package/packages/client/dist/runner/headless/managed-profile.d.ts +20 -0
- package/packages/client/dist/runner/headless/managed-profile.js +1 -1
- package/packages/client/dist/runner/headless/opencode-adapter.js +2 -2
- package/packages/client/dist/runner/headless/run-yoloop.d.ts +40 -0
- package/packages/client/dist/runner/headless/run-yoloop.js +2 -2
- package/packages/client/dist/runner/headless/types.d.ts +20 -0
- package/packages/client/dist/runner/headless/types.js +2 -2
- package/packages/client/dist/state/project-state-snapshot.d.ts +10 -0
- package/packages/client/dist/state/project-state-snapshot.js +1 -1
- package/packages/client/dist/state/structural-dag-projection.d.ts +26 -0
- package/packages/client/dist/state/structural-dag-projection.js +1 -1
- package/packages/client/dist/yoloop/target-normalization.js +1 -1
- package/packages/client/dist/yoloop/yoloop-client-state-store.d.ts +67 -0
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1
- package/packages/shared/dist/compatibility/index.js +96 -0
- package/packages/shared/dist/planning/diagnosis-state.js +105 -1
- package/packages/shared/dist/project-memory-targets.js +36 -5
- package/targets-stubs/antigravity/README.md +1 -1
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/install-antigravity.sh +1 -1
- package/targets-stubs/antigravity/mcp-config.json +0 -3
- package/targets-stubs/antigravity/neocortex.md +25 -13
- package/targets-stubs/antigravity/skill/SKILL.md +4 -4
- package/targets-stubs/claude-code/.mcp.json +0 -4
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +2 -4
- package/targets-stubs/claude-code/neocortex-root.md +33 -43
- package/targets-stubs/claude-code/neocortex-sentinel.md +261 -0
- package/targets-stubs/claude-code/neocortex.agent.yaml +1 -3
- package/targets-stubs/claude-code/neocortex.md +61 -84
- package/targets-stubs/codex/AGENTS.md +19 -18
- package/targets-stubs/codex/README.md +1 -1
- package/targets-stubs/codex/config-mcp.toml +0 -3
- package/targets-stubs/codex/neocortex-sentinel.toml +87 -0
- package/targets-stubs/codex/neocortex.toml +23 -44
- package/targets-stubs/cursor/README.md +1 -1
- package/targets-stubs/cursor/agent.md +26 -15
- package/targets-stubs/cursor/mcp.json +0 -3
- package/targets-stubs/deepseek-harness/SKILL.md +11 -8
- package/targets-stubs/gemini-cli/README.md +1 -1
- package/targets-stubs/gemini-cli/agent.md +25 -12
- package/targets-stubs/gemini-cli/agents/neocortex-sentinel.md +75 -0
- package/targets-stubs/gemini-cli/agents/neocortex.md +280 -49
- package/targets-stubs/gemini-cli/settings-mcp.json +0 -3
- package/targets-stubs/grok/SKILL.md +13 -1
- package/targets-stubs/grok/agents/neocortex-sentinel.md +64 -0
- package/targets-stubs/grok/config-mcp.toml +0 -3
- package/targets-stubs/grok/install-grok.sh +51 -1
- package/targets-stubs/kimi/mcp.json +0 -6
- package/targets-stubs/kimi/neocortex.md +21 -8
- package/targets-stubs/lib/managed-config-merge.js +301 -6
- package/targets-stubs/lib/managed-profile.sh +12 -1
- package/targets-stubs/lib/mcp-merge.js +122 -8
- package/targets-stubs/openclaw/SKILL.md +33 -4
- package/targets-stubs/opencode/neocortex-root.md +41 -41
- package/targets-stubs/opencode/neocortex-sentinel.md +115 -0
- package/targets-stubs/opencode/neocortex.md +292 -67
- package/targets-stubs/opencode/opencode-mcp.json +0 -7
- package/targets-stubs/vscode/README.md +1 -1
- package/targets-stubs/vscode/mcp.json +0 -4
- package/targets-stubs/vscode/neocortex.agent.md +29 -18
package/install.sh
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Development Orchestrator
|
|
5
5
|
|
|
6
6
|
# Versao do instalador
|
|
7
|
-
VERSION="4.
|
|
7
|
+
VERSION="4.66.1"
|
|
8
8
|
|
|
9
9
|
# Flags
|
|
10
10
|
MIGRATION_DETECTED=false
|
|
@@ -471,7 +471,9 @@ managed_parse_result() {
|
|
|
471
471
|
managed_copy_file() {
|
|
472
472
|
# Optional 5th arg: "platform" for a platform-home base (resolved CODEX_HOME);
|
|
473
473
|
# any other value is project/HOME scope (C11).
|
|
474
|
-
|
|
474
|
+
# Optional 6th arg (P228.19 AM-04): nested legacy copy, removed by the
|
|
475
|
+
# helper only when its hash is a known managed hash.
|
|
476
|
+
local src="$1" dest="$2" managed_id="$3" base_dir="${4:-$HOME}" base_scope="${5:-project}" legacy_copy="${6:-}"
|
|
475
477
|
local helper manifest target_dest
|
|
476
478
|
helper="$(managed_helper_path)"
|
|
477
479
|
manifest="$(managed_manifest_path "$base_dir")"
|
|
@@ -501,6 +503,7 @@ managed_copy_file() {
|
|
|
501
503
|
if [ "$base_scope" = "platform" ] && [ -n "$real_base" ] && [ -n "$real_home" ] && [ "$real_base" != "$real_home" ]; then
|
|
502
504
|
args+=("--legacy-base=$HOME")
|
|
503
505
|
fi
|
|
506
|
+
[ -n "$legacy_copy" ] && [ -e "$legacy_copy" ] && args+=("--legacy-copy=$legacy_copy")
|
|
504
507
|
[ "$DRY_RUN" = true ] && args+=(--dry-run)
|
|
505
508
|
local output status
|
|
506
509
|
output=$(node "$helper" "${args[@]}" 2>&1)
|
|
@@ -512,7 +515,16 @@ managed_copy_file() {
|
|
|
512
515
|
case "$NEOCORTEX_MANAGED_ACTION" in
|
|
513
516
|
skipped)
|
|
514
517
|
warn "Mudancas locais preservadas em ${target_dest/#$HOME/\~} ($NEOCORTEX_MANAGED_REASON)"
|
|
515
|
-
|
|
518
|
+
case "$NEOCORTEX_MANAGED_REASON" in
|
|
519
|
+
agent-profile-migration-drift)
|
|
520
|
+
warn "Proximo passo: mova o arquivo de lado e rode o instalador de novo (backup em .neocortex/backups/managed-config/)" ;;
|
|
521
|
+
agent-profile-sentinel-missing)
|
|
522
|
+
warn "Proximo passo: instale o neocortex-sentinel deste escopo e rode o instalador de novo" ;;
|
|
523
|
+
agent-profile-name-collision)
|
|
524
|
+
warn "Proximo passo: renomeie o outro perfil com o mesmo name e rode o instalador de novo" ;;
|
|
525
|
+
*)
|
|
526
|
+
warn "Para receber a versao nova, mova o arquivo e rode o instalador de novo" ;;
|
|
527
|
+
esac
|
|
516
528
|
return 0 ;;
|
|
517
529
|
failed)
|
|
518
530
|
warn "Nao foi possivel instalar ${target_dest/#$HOME/\~} ($NEOCORTEX_MANAGED_REASON); arquivo existente preservado"
|
|
@@ -521,6 +533,124 @@ managed_copy_file() {
|
|
|
521
533
|
return 0
|
|
522
534
|
}
|
|
523
535
|
|
|
536
|
+
# P228.19 (P228-CON-MANIFEST-MIGRATION): managed id of an agent role file.
|
|
537
|
+
# Same table as AGENT_ROLE_TABLE in targets-stubs/lib/managed-config-merge.js.
|
|
538
|
+
agent_role_managed_id() {
|
|
539
|
+
local platform="$1" scope="$2" file="$3" prefix="profile"
|
|
540
|
+
[ "$scope" = "project" ] && prefix="project"
|
|
541
|
+
case "$platform:$file" in
|
|
542
|
+
claude-code:neocortex-sentinel.md) printf '%s\n' "$prefix-claude-neocortex-sentinel-agent" ;;
|
|
543
|
+
claude-code:neocortex.md) printf '%s\n' "$prefix-claude-neocortex-agent" ;;
|
|
544
|
+
claude-code:neocortex-root.md) [ "$scope" = "user" ] && printf '%s\n' "profile-claude-neocortex-root-agent" ;;
|
|
545
|
+
opencode:neocortex-sentinel.md) printf '%s\n' "$prefix-opencode-neocortex-sentinel" ;;
|
|
546
|
+
opencode:neocortex.md) printf '%s\n' "$prefix-opencode-neocortex" ;;
|
|
547
|
+
opencode:neocortex-root.md) printf '%s\n' "$prefix-opencode-neocortex-root" ;;
|
|
548
|
+
codex:neocortex-sentinel.toml) printf '%s\n' "$prefix-codex-neocortex-sentinel" ;;
|
|
549
|
+
codex:neocortex.toml) printf '%s\n' "$prefix-codex-neocortex" ;;
|
|
550
|
+
esac
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
# P228.19: write the role profiles of one scope in order sentinel ->
|
|
554
|
+
# orchestrator -> alias. The helper enforces CAS, backup, drift and the
|
|
555
|
+
# sentinel precondition; this only fixes the order and reports the plan.
|
|
556
|
+
# Usage: install_agent_role_profiles <platform> <source_dir> <agents_dir> <base_dir> <user|project> [legacy_dir] [platform]
|
|
557
|
+
# Sets AGENT_ROLE_ORCHESTRATOR_ACTION to the orchestrator outcome.
|
|
558
|
+
install_agent_role_profiles() {
|
|
559
|
+
local platform="$1" source_dir="$2" agents_dir="$3" base_dir="$4" scope="$5" legacy_dir="${6:-}" base_scope="${7:-project}"
|
|
560
|
+
local ext="md" errors=0 file id legacy_copy
|
|
561
|
+
[ "$platform" = "codex" ] && ext="toml"
|
|
562
|
+
AGENT_ROLE_ORCHESTRATOR_ACTION=""
|
|
563
|
+
for file in "neocortex-sentinel.$ext" "neocortex.$ext" "neocortex-root.$ext"; do
|
|
564
|
+
[ -f "$source_dir/$file" ] || continue
|
|
565
|
+
id="$(agent_role_managed_id "$platform" "$scope" "$file")"
|
|
566
|
+
[ -n "$id" ] || continue
|
|
567
|
+
legacy_copy=""
|
|
568
|
+
[ -n "$legacy_dir" ] && [ -f "$legacy_dir/$file" ] && legacy_copy="$legacy_dir/$file"
|
|
569
|
+
[ "$DRY_RUN" = true ] || mkdir -p "$agents_dir" 2>/dev/null
|
|
570
|
+
managed_copy_file "$source_dir/$file" "$agents_dir/$file" "$id" "$base_dir" "$base_scope" "$legacy_copy" || errors=$((errors + 1))
|
|
571
|
+
[ "$file" = "neocortex.$ext" ] && AGENT_ROLE_ORCHESTRATOR_ACTION="$NEOCORTEX_MANAGED_ACTION"
|
|
572
|
+
if [ "$DRY_RUN" = true ]; then
|
|
573
|
+
echo "[MIGRATION] $scope $id ${agents_dir/#$HOME/\~}/$file $NEOCORTEX_MANAGED_ACTION $NEOCORTEX_MANAGED_REASON"
|
|
574
|
+
fi
|
|
575
|
+
done
|
|
576
|
+
[ "$errors" -eq 0 ]
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
# P228.19 AM-05: migrate already-installed project role profiles of the
|
|
580
|
+
# current directory before any user-scope target (SRC-01: a project profile
|
|
581
|
+
# with the same name hides the user orchestrator). Never creates profiles.
|
|
582
|
+
migrate_existing_project_agent_roles() {
|
|
583
|
+
local project_dir="${1:-$PWD}" targets="${2:-$SELECTED_TARGETS}"
|
|
584
|
+
[ -d "$project_dir" ] || return 0
|
|
585
|
+
is_neocortex_source_project "$project_dir" && return 0
|
|
586
|
+
local real_project real_home
|
|
587
|
+
real_project=$(cd "$project_dir" 2>/dev/null && pwd -P) || return 0
|
|
588
|
+
real_home=$(cd "$HOME" 2>/dev/null && pwd -P) || return 0
|
|
589
|
+
[ "$real_project" = "$real_home" ] && return 0
|
|
590
|
+
[ -f "$project_dir/.neocortex/managed-config-manifest.json" ] || return 0
|
|
591
|
+
local target source_dir
|
|
592
|
+
for target in $(echo "$targets" | tr ',' ' '); do
|
|
593
|
+
case "$target" in
|
|
594
|
+
claude-code)
|
|
595
|
+
source_dir=$(resolve_target_dir "claude-code") || continue
|
|
596
|
+
if [ -f "$project_dir/.claude/agents/neocortex.md" ] || [ -f "$project_dir/.claude/agents/neocortex-sentinel.md" ]; then
|
|
597
|
+
install_agent_role_profiles claude-code "$source_dir" "$project_dir/.claude/agents" "$project_dir" project "$project_dir/.claude/agents/neocortex"
|
|
598
|
+
fi
|
|
599
|
+
;;
|
|
600
|
+
opencode)
|
|
601
|
+
source_dir="$SOURCE_DIR/targets-stubs/opencode"
|
|
602
|
+
if [ -f "$project_dir/.opencode/agents/neocortex.md" ] || [ -f "$project_dir/.opencode/agents/neocortex-sentinel.md" ]; then
|
|
603
|
+
install_agent_role_profiles opencode "$source_dir" "$project_dir/.opencode/agents" "$project_dir" project
|
|
604
|
+
fi
|
|
605
|
+
;;
|
|
606
|
+
esac
|
|
607
|
+
done
|
|
608
|
+
return 0
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
# P228.19 AM-06: Codex sentinel goes in before the adapter writes the
|
|
612
|
+
# orchestrator (targets-stubs/codex/install-codex.sh).
|
|
613
|
+
install_codex_sentinel() {
|
|
614
|
+
local dest_root="$1" scope="${2:-user}"
|
|
615
|
+
local codex_source="$SOURCE_DIR/targets-stubs/codex"
|
|
616
|
+
[ -f "$codex_source/neocortex-sentinel.toml" ] || return 0
|
|
617
|
+
if [ "$scope" = "project" ]; then
|
|
618
|
+
[ "$DRY_RUN" = true ] || mkdir -p "$dest_root/.codex/agents" 2>/dev/null
|
|
619
|
+
managed_copy_file "$codex_source/neocortex-sentinel.toml" "$dest_root/.codex/agents/neocortex-sentinel.toml" "project-codex-neocortex-sentinel" "$dest_root"
|
|
620
|
+
return $?
|
|
621
|
+
fi
|
|
622
|
+
local codex_home="$HOME/.codex"
|
|
623
|
+
[[ "${CODEX_HOME:-}" == /* ]] && codex_home="$CODEX_HOME"
|
|
624
|
+
local codex_base
|
|
625
|
+
codex_base="$(managed_platform_base "$codex_home")"
|
|
626
|
+
[ "$DRY_RUN" = true ] || mkdir -p "$codex_home/agents" 2>/dev/null
|
|
627
|
+
managed_copy_file "$codex_source/neocortex-sentinel.toml" "$codex_home/agents/neocortex-sentinel.toml" "profile-codex-neocortex-sentinel" "$codex_base" platform
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
# P228.19 AC3: dry-run plan of the role migration (no file is written).
|
|
631
|
+
plan_agent_role_migration() {
|
|
632
|
+
local targets="$1" target
|
|
633
|
+
[ "$DRY_RUN" = true ] || return 0
|
|
634
|
+
command -v node >/dev/null 2>&1 || return 0
|
|
635
|
+
migrate_existing_project_agent_roles "$PWD" "$targets"
|
|
636
|
+
for target in $(echo "$targets" | tr ',' ' '); do
|
|
637
|
+
case "$target" in
|
|
638
|
+
claude-code)
|
|
639
|
+
local claude_source
|
|
640
|
+
claude_source=$(resolve_target_dir "claude-code") || continue
|
|
641
|
+
[ -d "$HOME/.claude" ] || continue
|
|
642
|
+
install_agent_role_profiles claude-code "$claude_source" "$HOME/.claude/agents" "$HOME" user "$HOME/.claude/agents/neocortex"
|
|
643
|
+
;;
|
|
644
|
+
opencode)
|
|
645
|
+
local opencode_home="${OPENCODE_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}"
|
|
646
|
+
[ -d "$opencode_home" ] || continue
|
|
647
|
+
install_agent_role_profiles opencode "$SOURCE_DIR/targets-stubs/opencode" "$opencode_home/agents" "$(managed_platform_base "$opencode_home")" user
|
|
648
|
+
;;
|
|
649
|
+
esac
|
|
650
|
+
done
|
|
651
|
+
return 0
|
|
652
|
+
}
|
|
653
|
+
|
|
524
654
|
# Managed base for a platform home: $HOME when the home lives inside it, the
|
|
525
655
|
# platform home itself when redirected outside (env var or symlink).
|
|
526
656
|
managed_platform_base() {
|
|
@@ -934,30 +1064,31 @@ show_target_resolution_dry_run() {
|
|
|
934
1064
|
info "Dry-run target=$target adapter=$resolved scope=published-stub"
|
|
935
1065
|
case "$target" in
|
|
936
1066
|
cursor)
|
|
937
|
-
info "Dry-run MCP target=cursor file=${CURSOR_HOME:-$HOME/.cursor}/mcp.json root=mcpServers managed=playwright,
|
|
1067
|
+
info "Dry-run MCP target=cursor file=${CURSOR_HOME:-$HOME/.cursor}/mcp.json root=mcpServers managed=playwright,browser_use,figma,shadcn,chrome-devtools action=add-or-update-preserve-custom"
|
|
938
1068
|
;;
|
|
939
1069
|
vscode)
|
|
940
1070
|
local vscode_mcp
|
|
941
1071
|
if [ -n "$VSCODE_MCP_FILE" ]; then vscode_mcp="$VSCODE_MCP_FILE"; elif [ "$(uname -s 2>/dev/null)" = "Darwin" ]; then vscode_mcp="$HOME/Library/Application Support/Code/User/mcp.json"; else vscode_mcp="${XDG_CONFIG_HOME:-$HOME/.config}/Code/User/mcp.json"; fi
|
|
942
|
-
info "Dry-run MCP target=vscode file=$vscode_mcp root=servers managed=playwright,
|
|
1072
|
+
info "Dry-run MCP target=vscode file=$vscode_mcp root=servers managed=playwright,browser_use,figma,shadcn,chrome-devtools action=add-or-update-preserve-custom"
|
|
943
1073
|
;;
|
|
944
1074
|
gemini|gemini-cli)
|
|
945
|
-
info "Dry-run MCP target=gemini file=${GEMINI_HOME:-$HOME/.gemini}/settings.json root=mcpServers managed=playwright,
|
|
1075
|
+
info "Dry-run MCP target=gemini file=${GEMINI_HOME:-$HOME/.gemini}/settings.json root=mcpServers managed=playwright,browser_use,figma,shadcn,chrome-devtools action=add-or-update-preserve-custom"
|
|
946
1076
|
;;
|
|
947
1077
|
codex)
|
|
948
1078
|
local dry_codex_home="$HOME/.codex"
|
|
949
1079
|
[[ "${CODEX_HOME:-}" == /* ]] && dry_codex_home="$CODEX_HOME"
|
|
950
|
-
info "Dry-run MCP target=codex file=${dry_codex_home}/config.toml root=mcp_servers managed=playwright,
|
|
1080
|
+
info "Dry-run MCP target=codex file=${dry_codex_home}/config.toml root=mcp_servers managed=playwright,browser_use,figma,shadcn,chrome-devtools action=replace-managed-sections-preserve-unknown"
|
|
951
1081
|
;;
|
|
952
1082
|
grok)
|
|
953
1083
|
info "Dry-run Skill target=grok file=${GROK_HOME:-$HOME/.grok}/skills/neocortex/SKILL.md project=.grok/skills/neocortex/SKILL.md"
|
|
954
|
-
info "Dry-run
|
|
1084
|
+
info "Dry-run Agent target=grok file=${GROK_HOME:-$HOME/.grok}/agents/neocortex-sentinel.md project=.grok/agents/neocortex-sentinel.md action=managed-non-overwrite legacy=retire-if-managed-hash"
|
|
1085
|
+
info "Dry-run MCP target=grok file=${GROK_HOME:-$HOME/.grok}/config.toml root=mcp_servers managed=playwright,browser_use,figma,shadcn,chrome-devtools action=replace-managed-sections-preserve-unknown"
|
|
955
1086
|
;;
|
|
956
1087
|
opencode)
|
|
957
|
-
info "Dry-run MCP target=opencode file=${OPENCODE_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/opencode.json root=mcp managed=playwright,
|
|
1088
|
+
info "Dry-run MCP target=opencode file=${OPENCODE_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/opencode.json root=mcp managed=playwright,browser_use,figma,shadcn,chrome-devtools action=add-or-update-preserve-custom"
|
|
958
1089
|
;;
|
|
959
1090
|
kimi)
|
|
960
|
-
info "Dry-run MCP target=kimi file=${KIMI_HOME:-$HOME/.kimi}/mcp.json root=mcpServers managed=playwright,
|
|
1091
|
+
info "Dry-run MCP target=kimi file=${KIMI_HOME:-$HOME/.kimi}/mcp.json root=mcpServers managed=playwright,browser_use,figma,shadcn,chrome-devtools action=add-or-update-preserve-custom"
|
|
961
1092
|
;;
|
|
962
1093
|
openclaw)
|
|
963
1094
|
info "Dry-run Skill target=openclaw file=${OPENCLAW_HOME:-$HOME/.openclaw}/skills/neocortex/SKILL.md action=copy-skill-preserve-openclaw-json config=${OPENCLAW_HOME:-$HOME/.openclaw}/openclaw.json non-overwrite"
|
|
@@ -1234,16 +1365,14 @@ install_agent() {
|
|
|
1234
1365
|
# Tier 3 Stub-Only: copiar apenas 2 arquivos de interface (stubs minimos)
|
|
1235
1366
|
# Claude Code so descobre subagents em agents/*.md (top-level): o agente vai
|
|
1236
1367
|
# para $AGENTS_DIR/neocortex.md; .version e o yaml ficam em $DEST_DIR.
|
|
1237
|
-
|
|
1238
|
-
|
|
1368
|
+
# P228.19: sentinel -> orchestrator (neocortex.md) -> alias (neocortex-root.md,
|
|
1369
|
+
# owns *yoloop since 4.64.3) in one ordered, CAS-guarded pass. The nested
|
|
1370
|
+
# legacy copy (not discovered by Claude Code) is removed by the helper only
|
|
1371
|
+
# with a known managed hash (AM-04).
|
|
1372
|
+
install_agent_role_profiles claude-code "$CLAUDE_TARGET_DIR" "$AGENTS_DIR" "$HOME" user "$DEST_DIR" || ((errors++))
|
|
1239
1373
|
copy_file "$CLAUDE_TARGET_DIR/neocortex.agent.yaml" "$DEST_DIR/" || ((errors++))
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
if [ -f "$CLAUDE_TARGET_DIR/neocortex-root.md" ]; then
|
|
1243
|
-
managed_copy_file "$CLAUDE_TARGET_DIR/neocortex-root.md" "$AGENTS_DIR/neocortex-root.md" "profile-claude-neocortex-root-agent" "$HOME" || ((errors++))
|
|
1244
|
-
if [ -f "$CLAUDE_TARGET_DIR/neocortex-root.agent.yaml" ]; then
|
|
1245
|
-
copy_file "$CLAUDE_TARGET_DIR/neocortex-root.agent.yaml" "$DEST_DIR/" || ((errors++))
|
|
1246
|
-
fi
|
|
1374
|
+
if [ -f "$CLAUDE_TARGET_DIR/neocortex-root.md" ] && [ -f "$CLAUDE_TARGET_DIR/neocortex-root.agent.yaml" ]; then
|
|
1375
|
+
copy_file "$CLAUDE_TARGET_DIR/neocortex-root.agent.yaml" "$DEST_DIR/" || ((errors++))
|
|
1247
1376
|
fi
|
|
1248
1377
|
|
|
1249
1378
|
# 4.64.5: v4 story worktrees must start from the epic checkout (local HEAD).
|
|
@@ -1256,10 +1385,6 @@ install_agent() {
|
|
|
1256
1385
|
if [ ! -f "$AGENTS_DIR/neocortex.md" ]; then
|
|
1257
1386
|
fail "neocortex.md nao encontrado no destino apos copia: $AGENTS_DIR/"
|
|
1258
1387
|
((errors++))
|
|
1259
|
-
elif [ "$DRY_RUN" != true ] && [ "$claude_agent_action" != "skipped" ] && [ -f "$DEST_DIR/neocortex.md" ]; then
|
|
1260
|
-
# Migracao: remover o agente legado aninhado (nao descoberto pelo Claude
|
|
1261
|
-
# Code) para nao coexistirem dois agentes com o mesmo nome.
|
|
1262
|
-
rm -f "$DEST_DIR/neocortex.md"
|
|
1263
1388
|
fi
|
|
1264
1389
|
if [ ! -f "$DEST_DIR/neocortex.agent.yaml" ]; then
|
|
1265
1390
|
fail "neocortex.agent.yaml nao encontrado no destino apos copia: $DEST_DIR/"
|
|
@@ -1305,7 +1430,13 @@ install_targets() {
|
|
|
1305
1430
|
mkdir -p "$opencode_home/agents" 2>/dev/null
|
|
1306
1431
|
local opencode_base
|
|
1307
1432
|
opencode_base="$(managed_platform_base "$opencode_home")"
|
|
1308
|
-
|
|
1433
|
+
# P228.19: sentinel -> orchestrator -> alias, CAS-guarded by the helper.
|
|
1434
|
+
local opencode_sentinel_ok=0
|
|
1435
|
+
if [ -f "$opencode_target/neocortex-sentinel.md" ]; then
|
|
1436
|
+
managed_copy_file "$opencode_target/neocortex-sentinel.md" "$opencode_home/agents/neocortex-sentinel.md" "profile-opencode-neocortex-sentinel" "$opencode_base" || opencode_sentinel_ok=1
|
|
1437
|
+
fi
|
|
1438
|
+
if [ "$opencode_sentinel_ok" -eq 0 ] && \
|
|
1439
|
+
managed_copy_file "$opencode_target/neocortex.md" "$opencode_home/agents/neocortex.md" "profile-opencode-neocortex" "$opencode_base" && \
|
|
1309
1440
|
managed_copy_file "$opencode_target/neocortex-root.md" "$opencode_home/agents/neocortex-root.md" "profile-opencode-neocortex-root" "$opencode_base"; then
|
|
1310
1441
|
if [ -f "$opencode_target/opencode-mcp.json" ] && command -v node >/dev/null 2>&1; then
|
|
1311
1442
|
if ! node "$SOURCE_DIR/targets-stubs/lib/mcp-merge.js" json "$opencode_target/opencode-mcp.json" "$opencode_home/opencode.json" mcp OPENCODE; then
|
|
@@ -1427,6 +1558,9 @@ install_targets() {
|
|
|
1427
1558
|
|
|
1428
1559
|
. "$adapter_script"
|
|
1429
1560
|
|
|
1561
|
+
# P228.19 AM-06: the Codex sentinel precedes the adapter's orchestrator write.
|
|
1562
|
+
[ "$target" = "codex" ] && install_codex_sentinel "$HOME" user
|
|
1563
|
+
|
|
1430
1564
|
if type "$func_name" >/dev/null 2>&1; then
|
|
1431
1565
|
"$func_name" "$SOURCE_DIR" "$HOME"
|
|
1432
1566
|
local result=$?
|
|
@@ -1481,49 +1615,6 @@ load_env_file() {
|
|
|
1481
1615
|
return 1
|
|
1482
1616
|
}
|
|
1483
1617
|
|
|
1484
|
-
# =============================================================================
|
|
1485
|
-
# CONFIGURACAO DE TOKENS
|
|
1486
|
-
# =============================================================================
|
|
1487
|
-
|
|
1488
|
-
prompt_tokens() {
|
|
1489
|
-
[ "$QUIET_MODE" = true ] && return
|
|
1490
|
-
[ -n "$CONTEXT7_API_KEY" ] && return
|
|
1491
|
-
|
|
1492
|
-
if [ "$AUTO_YES" = true ]; then
|
|
1493
|
-
return
|
|
1494
|
-
fi
|
|
1495
|
-
|
|
1496
|
-
echo ""
|
|
1497
|
-
info "MCP Context7 nao configurado ${DIM}(opcional)${NC}"
|
|
1498
|
-
echo -ne " Configurar agora? ${BOLD}[s/N]:${NC} "
|
|
1499
|
-
|
|
1500
|
-
local response=""
|
|
1501
|
-
if read -r -t 15 response 2>/dev/null; then
|
|
1502
|
-
: # resposta recebida
|
|
1503
|
-
else
|
|
1504
|
-
echo ""
|
|
1505
|
-
return
|
|
1506
|
-
fi
|
|
1507
|
-
|
|
1508
|
-
if [[ "$response" =~ ^([sS][iI]?[mM]?|[yY][eE]?[sS]?)$ ]]; then
|
|
1509
|
-
echo ""
|
|
1510
|
-
info "Obtenha sua API Key em: ${WHITE}https://context7.com${NC}"
|
|
1511
|
-
echo -ne " Cole sua ${BOLD}CONTEXT7_API_KEY${NC}: "
|
|
1512
|
-
|
|
1513
|
-
local api_key=""
|
|
1514
|
-
if read -r -t 60 api_key 2>/dev/null; then
|
|
1515
|
-
if [[ "$api_key" =~ ^ctx7sk- ]]; then
|
|
1516
|
-
export CONTEXT7_API_KEY="$api_key"
|
|
1517
|
-
ok "CONTEXT7_API_KEY configurada"
|
|
1518
|
-
echo ""
|
|
1519
|
-
info "Para persistir: ${DIM}echo 'export CONTEXT7_API_KEY=\"$api_key\"' >> ~/.bashrc${NC}"
|
|
1520
|
-
elif [ -n "$api_key" ]; then
|
|
1521
|
-
warn "Formato invalido (esperado: ctx7sk-...)"
|
|
1522
|
-
fi
|
|
1523
|
-
fi
|
|
1524
|
-
fi
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
1618
|
# =============================================================================
|
|
1528
1619
|
# INSTALACAO DE MCP SERVERS
|
|
1529
1620
|
# =============================================================================
|
|
@@ -1546,14 +1637,10 @@ install_mcps() {
|
|
|
1546
1637
|
mcp_results="${mcp_results}playwright:FAIL "
|
|
1547
1638
|
fi
|
|
1548
1639
|
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
mcp_results="${mcp_results}context7:FAIL "
|
|
1554
|
-
fi
|
|
1555
|
-
else
|
|
1556
|
-
mcp_results="${mcp_results}context7:SKIP "
|
|
1640
|
+
# P228.08: Context7 is no longer managed. A legacy user-scope entry is never
|
|
1641
|
+
# read, printed or removed here; only the CLI exit code is used.
|
|
1642
|
+
if claude mcp get context7 >/dev/null 2>&1; then
|
|
1643
|
+
info "context7-legacy-entry-retained ${DIM}(Context7 nao e mais gerenciado; para remover: claude mcp remove context7 --scope user)${NC}"
|
|
1557
1644
|
fi
|
|
1558
1645
|
|
|
1559
1646
|
# browser_use: optional (requires uvx and at least one supported LLM API key).
|
|
@@ -1857,14 +1944,10 @@ create_project_dirs() {
|
|
|
1857
1944
|
|
|
1858
1945
|
# Tier 3: copiar apenas 2 stub files
|
|
1859
1946
|
# Claude Code so descobre agents/*.md (top-level); o yaml fica no subdir.
|
|
1860
|
-
|
|
1861
|
-
|
|
1947
|
+
# P228.19: sentinel before the orchestrator; the nested legacy
|
|
1948
|
+
# agent is removed by the helper only with a known hash (AM-04).
|
|
1949
|
+
install_agent_role_profiles claude-code "$claude_target_dir" "$project_dir/.claude/agents" "$project_dir" project "$project_dir/.claude/agents/neocortex"
|
|
1862
1950
|
managed_copy_file "$claude_target_dir/neocortex.agent.yaml" "$project_dir/.claude/agents/neocortex/" "project-claude-neocortex-yaml" "$project_dir"
|
|
1863
|
-
# Migracao: remover agente legado aninhado apos gravar o top-level
|
|
1864
|
-
# (nunca quando o top-level existente foi preservado por drift)
|
|
1865
|
-
if [ "$DRY_RUN" != true ] && [ "$project_agent_action" != "skipped" ] && [ -f "$project_dir/.claude/agents/neocortex.md" ]; then
|
|
1866
|
-
rm -f "$project_dir/.claude/agents/neocortex/neocortex.md" 2>/dev/null
|
|
1867
|
-
fi
|
|
1868
1951
|
# Cleanup workflow.md from previous versions
|
|
1869
1952
|
rm -f "$project_dir/.claude/agents/neocortex/workflow.md" 2>/dev/null
|
|
1870
1953
|
|
|
@@ -1902,6 +1985,9 @@ create_project_dirs() {
|
|
|
1902
1985
|
local stub_adapter="$SOURCE_DIR/targets-stubs/codex/install-codex.sh"
|
|
1903
1986
|
if [ -f "$stub_adapter" ]; then
|
|
1904
1987
|
. "$stub_adapter"
|
|
1988
|
+
# P228.19 AM-06: both Codex sentinels precede the adapter.
|
|
1989
|
+
install_codex_sentinel "$project_dir" project
|
|
1990
|
+
install_codex_sentinel "$HOME" user
|
|
1905
1991
|
install_codex "$SOURCE_DIR" "$project_dir"
|
|
1906
1992
|
target_summary="${target_summary}codex, "
|
|
1907
1993
|
fi
|
|
@@ -1926,6 +2012,10 @@ create_project_dirs() {
|
|
|
1926
2012
|
local opencode_target="$SOURCE_DIR/targets-stubs/opencode"
|
|
1927
2013
|
if [ -f "$opencode_target/neocortex.md" ] && [ -f "$opencode_target/neocortex-root.md" ]; then
|
|
1928
2014
|
mkdir -p "$project_dir/.opencode/agents" 2>/dev/null
|
|
2015
|
+
# P228.19: sentinel before the orchestrator.
|
|
2016
|
+
if [ -f "$opencode_target/neocortex-sentinel.md" ]; then
|
|
2017
|
+
managed_copy_file "$opencode_target/neocortex-sentinel.md" "$project_dir/.opencode/agents/neocortex-sentinel.md" "project-opencode-neocortex-sentinel" "$project_dir"
|
|
2018
|
+
fi
|
|
1929
2019
|
managed_copy_file "$opencode_target/neocortex.md" "$project_dir/.opencode/agents/neocortex.md" "project-opencode-neocortex" "$project_dir"
|
|
1930
2020
|
managed_copy_file "$opencode_target/neocortex-root.md" "$project_dir/.opencode/agents/neocortex-root.md" "project-opencode-neocortex-root" "$project_dir"
|
|
1931
2021
|
target_summary="${target_summary}opencode, "
|
|
@@ -2022,31 +2112,57 @@ get_tier_from_config() {
|
|
|
2022
2112
|
fi
|
|
2023
2113
|
}
|
|
2024
2114
|
|
|
2115
|
+
# P228.05: the per-platform tier table is generated from the server table
|
|
2116
|
+
# (packages/shared/src/tier-config.ts PLATFORM_GATES) and checked by
|
|
2117
|
+
# packages/shared/src/__tests__/p228-tier-parity.test.ts. Never edit by hand.
|
|
2118
|
+
# BEGIN NEOCORTEX PLATFORM TIER TABLE (generated from packages/shared/src/tier-config.ts PLATFORM_GATES; do not edit by hand)
|
|
2119
|
+
platform_required_tier() {
|
|
2120
|
+
case "$1" in
|
|
2121
|
+
claude-code) echo "free" ;;
|
|
2122
|
+
cursor) echo "pro" ;;
|
|
2123
|
+
vscode) echo "pro" ;;
|
|
2124
|
+
gemini) echo "pro" ;;
|
|
2125
|
+
gemini-cli) echo "pro" ;;
|
|
2126
|
+
codex) echo "pro" ;;
|
|
2127
|
+
grok) echo "pro" ;;
|
|
2128
|
+
antigravity) echo "pro" ;;
|
|
2129
|
+
opencode) echo "pro" ;;
|
|
2130
|
+
kimi) echo "pro" ;;
|
|
2131
|
+
openclaw) echo "pro" ;;
|
|
2132
|
+
deepseek-harness) echo "pro" ;;
|
|
2133
|
+
*) echo "free" ;;
|
|
2134
|
+
esac
|
|
2135
|
+
}
|
|
2136
|
+
# END NEOCORTEX PLATFORM TIER TABLE
|
|
2137
|
+
|
|
2138
|
+
# Tier hierarchy (free < pro < enterprise). Unrecognized values rank as free,
|
|
2139
|
+
# so the installer can only narrow access and never grants a tier.
|
|
2140
|
+
platform_tier_rank() {
|
|
2141
|
+
case "$1" in
|
|
2142
|
+
enterprise) echo 2 ;;
|
|
2143
|
+
pro) echo 1 ;;
|
|
2144
|
+
*) echo 0 ;;
|
|
2145
|
+
esac
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2025
2148
|
# Check if a platform is allowed for the current tier
|
|
2026
2149
|
# Returns 0 if allowed, 1 if blocked
|
|
2027
2150
|
check_platform_tier() {
|
|
2028
2151
|
local platform=$1
|
|
2029
2152
|
local tier=$2
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
;;
|
|
2040
|
-
vscode|antigravity|kimi)
|
|
2041
|
-
if [ "$tier" != "enterprise" ]; then
|
|
2042
|
-
warn "$platform requer plano Enterprise."
|
|
2043
|
-
info "Upgrade: ${CYAN}https://neocortex.sh/portal/dashboard/plans${NC}"
|
|
2044
|
-
return 1
|
|
2045
|
-
fi
|
|
2046
|
-
return 0
|
|
2047
|
-
;;
|
|
2153
|
+
local required
|
|
2154
|
+
required=$(platform_required_tier "$platform")
|
|
2155
|
+
if [ "$(platform_tier_rank "$tier")" -ge "$(platform_tier_rank "$required")" ]; then
|
|
2156
|
+
return 0
|
|
2157
|
+
fi
|
|
2158
|
+
local required_label
|
|
2159
|
+
case "$required" in
|
|
2160
|
+
enterprise) required_label="Enterprise" ;;
|
|
2161
|
+
*) required_label="Pro" ;;
|
|
2048
2162
|
esac
|
|
2049
|
-
|
|
2163
|
+
warn "$platform requer plano ${required_label}. Plataforma disponivel: Claude Code."
|
|
2164
|
+
info "Upgrade: ${CYAN}https://neocortex.sh/portal/dashboard/plans${NC}"
|
|
2165
|
+
return 1
|
|
2050
2166
|
}
|
|
2051
2167
|
|
|
2052
2168
|
# =============================================================================
|
|
@@ -2134,6 +2250,8 @@ main() {
|
|
|
2134
2250
|
|
|
2135
2251
|
if [ "$DRY_RUN" = true ]; then
|
|
2136
2252
|
show_target_resolution_dry_run "$SELECTED_TARGETS"
|
|
2253
|
+
# P228.19 AC3: report the role-migration plan; nothing is written.
|
|
2254
|
+
plan_agent_role_migration "$SELECTED_TARGETS"
|
|
2137
2255
|
exit 0
|
|
2138
2256
|
fi
|
|
2139
2257
|
|
|
@@ -2162,12 +2280,13 @@ main() {
|
|
|
2162
2280
|
|
|
2163
2281
|
# Step 4: Targets
|
|
2164
2282
|
step 4 $TOTAL_STEPS "Instalando ${BOLD}$target_count${NC} plataforma(s)"
|
|
2283
|
+
# P228.19 AM-05: existing project role profiles migrate before the user scope.
|
|
2284
|
+
migrate_existing_project_agent_roles "$PWD" "$SELECTED_TARGETS"
|
|
2165
2285
|
install_targets "$SELECTED_TARGETS"
|
|
2166
2286
|
|
|
2167
2287
|
# Step 5: Claude Code extras
|
|
2168
2288
|
if echo "$SELECTED_TARGETS" | grep -q "claude-code"; then
|
|
2169
2289
|
load_env_file
|
|
2170
|
-
prompt_tokens
|
|
2171
2290
|
|
|
2172
2291
|
step 5 $TOTAL_STEPS "Configurando MCPs"
|
|
2173
2292
|
install_mcps
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as m}from"node:fs";import{join as l}from"node:path";const g=/^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/;function
|
|
1
|
+
import{existsSync as m}from"node:fs";import{join as l}from"node:path";const g=/^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/;function f(n,a=_(n)){if(a.targetId!=="codex")return;const r=["CODEX_THREAD_ID","CODEX_SESSION_ID","CODEX_SANDBOX_NETWORK_DISABLED"].some(s=>n.env[s]!==void 0),i=r&&n.env.CODEX_REMOTE_PAYLOAD!==void 0,o=i?"codex-desktop":r?"codex-cli":"unknown",t=n.nativeHostVersion?.trim()??"",c=g.test(t)?t:null,e=!!n.targetFlag&&!r;return Object.freeze({schemaVersion:1,platformTarget:"codex",hostKind:o,hostVersion:c,origin:e?"explicit-override":i?"host-observed":r?"environment":"unknown",confidence:e||o==="unknown"?"unknown":i?"observed":"inferred",publicSafe:!0})}const E=new Set(["claude-code","cursor","vscode","gemini","codex","opencode","github-copilot-cli","kimi","antigravity","openclaw","grok","deepseek","runner","unknown"]),I=Object.freeze({claude:"claude-code","claude-code":"claude-code",cursor:"cursor",vscode:"vscode","vscode-copilot":"vscode",gemini:"gemini","gemini-cli":"gemini",codex:"codex","codex-cli":"codex",opencode:"opencode","copilot-cli":"github-copilot-cli","github-copilot-cli":"github-copilot-cli",kimi:"kimi",antigravity:"antigravity",openclaw:"openclaw","open-claw":"openclaw",grok:"grok","grok-build":"grok",deepseek:"deepseek","deepseek-harness":"deepseek",deepseek_harness:"deepseek",dsh:"deepseek",runner:"runner",unknown:"unknown"});function D(n){return E.has(n)}function p(n){return I[n.trim().toLowerCase()]??null}const S=n=>m(n);function _(n,a=S){if(n.targetFlag){const e=p(n.targetFlag);return e?{targetId:e,confidence:1,reason:`Explicit --target=${e} flag`,reasonCode:"platform-target-explicit"}:{targetId:"unknown",confidence:0,reason:"Explicit platform target is not recognized",reasonCode:"platform-target-invalid-override"}}const r=e=>n.env[e]!==void 0,i=[],o=(e,s,d)=>{d.some(r)&&i.push({targetId:e,signal:s})};o("claude-code","Claude Code runtime",["CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE","CLAUDE_AGENT"]),o("codex","Codex runtime",["CODEX_THREAD_ID","CODEX_SESSION_ID","CODEX_SANDBOX_NETWORK_DISABLED"]),o("opencode","OpenCode runtime",["OPENCODE","OPENCODE_SESSION_ID"]),o("cursor","Cursor runtime",["CURSOR_SESSION_ID","CURSOR_TRACE_ID"]),o("gemini","Gemini CLI runtime",["GEMINI_CLI"]),o("github-copilot-cli","GitHub Copilot CLI runtime",["COPILOT_CLI"]),o("kimi","Kimi Code runtime",["KIMI_SESSION_ID","KIMI_CODE_SESSION_ID"]),o("antigravity","Antigravity runtime",["ANTIGRAVITY_SESSION_ID","ANTIGRAVITY_AGENT"]),o("openclaw","OpenClaw runtime",["OPENCLAW_SESSION_ID","OPENCLAW_GATEWAY"]),o("grok","Grok Build runtime",["GROK_SESSION_ID","GROK_AGENT","GROK_HOME"]),o("deepseek","DeepSeek Harness runtime",["DSH_SHELL","DSH_SESSION_ID"]);const t=[...new Map(i.map(e=>[e.targetId,e])).values()];if(t.length>1)return{targetId:"unknown",confidence:0,reason:`Conflicting runtime platform signals: ${t.map(({targetId:e})=>e).sort().join(", ")}`,reasonCode:"platform-target-ambiguous"};if(t.length===1){const e=t[0],d={"claude-code":"CLAUDE.md",codex:"AGENTS.md",cursor:".cursor",gemini:"GEMINI.md",vscode:".vscode",grok:"AGENTS.md"}[e.targetId],u=d?a(l(n.cwd,d)):!1;return{targetId:e.targetId,confidence:u?.98:.95,reason:`${e.signal} signal${u?` corroborated by ${d}`:""}`,reasonCode:"platform-target-runtime-signal"}}return r("VSCODE_PID")||n.env.TERM_PROGRAM==="vscode"?{targetId:"vscode",confidence:.75,reason:"VS Code runtime signal without a stronger agent runtime signal",reasonCode:"platform-target-runtime-signal"}:["AGENTS.md",".cursor",".cursorrules","CLAUDE.md",".vscode","GEMINI.md"].some(e=>a(l(n.cwd,e)))?{targetId:"unknown",confidence:0,reason:"Filesystem marker found without platform-owned runtime evidence",reasonCode:"platform-target-filesystem-only"}:{targetId:"unknown",confidence:0,reason:"No platform runtime signals detected",reasonCode:"platform-target-unknown"}}export{f as detectNativeHostAttestation,_ as detectPlatform,D as isValidTargetId,p as normalizeTargetId};
|
|
@@ -10,6 +10,34 @@
|
|
|
10
10
|
*
|
|
11
11
|
* See the LICENSE file in the project root for full license text.
|
|
12
12
|
*/
|
|
13
|
+
/**
|
|
14
|
+
* P228.19 (P228-CON-MANIFEST-MIGRATION): public, path-relative outcome of one
|
|
15
|
+
* managed profile write. Never carries absolute paths or file content.
|
|
16
|
+
*/
|
|
17
|
+
export interface AgentMigrationPublicResult {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly scope: 'project' | 'user';
|
|
20
|
+
readonly relativePath: string;
|
|
21
|
+
readonly action: string;
|
|
22
|
+
readonly reasonCode: string;
|
|
23
|
+
readonly nextStep?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface RefreshStubsReport {
|
|
26
|
+
readonly refreshed: number;
|
|
27
|
+
readonly results: readonly AgentMigrationPublicResult[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* P227.14 T3: one id per managed destination across writers. The installer
|
|
31
|
+
* (`install-codex.sh`) owns these ids; refresh reuses them instead of deriving
|
|
32
|
+
* `profile-<sourceDir>-<relativeDest>`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const CANONICAL_MANAGED_IDS: Readonly<Record<string, string>>;
|
|
35
|
+
/**
|
|
36
|
+
* P228.19 AM-08: OpenCode refresh writes `~/.opencode/agents`, a different
|
|
37
|
+
* destination than the installer (`$OPENCODE_HOME/agents`), so it keeps its
|
|
38
|
+
* derived id (no ownership conflict) and takes role semantics by role id.
|
|
39
|
+
*/
|
|
40
|
+
export declare const AGENT_ROLE_IDS: Readonly<Record<string, string>>;
|
|
13
41
|
/**
|
|
14
42
|
* Replace all version strings in a stub file with the given version.
|
|
15
43
|
* Handles 4 patterns:
|
|
@@ -62,6 +90,16 @@ export interface StubTarget {
|
|
|
62
90
|
fileDestDirs?: Readonly<Record<string, string>>;
|
|
63
91
|
}
|
|
64
92
|
export declare const STUB_TARGETS: readonly StubTarget[];
|
|
93
|
+
interface ProjectRoleTarget {
|
|
94
|
+
/** Directory name in targets-stubs/. */
|
|
95
|
+
readonly stubDir: string;
|
|
96
|
+
readonly agentsDir: string;
|
|
97
|
+
/** [file, managed id, create when missing] in migration order. */
|
|
98
|
+
readonly roleFiles: readonly (readonly [string, string, boolean])[];
|
|
99
|
+
readonly legacyDir?: string;
|
|
100
|
+
}
|
|
101
|
+
/** P228.19 spec T1: project scope, migrated before the user scope. */
|
|
102
|
+
export declare const PROJECT_ROLE_TARGETS: readonly ProjectRoleTarget[];
|
|
65
103
|
/**
|
|
66
104
|
* Find the monorepo / npm package root by walking up from this file's location.
|
|
67
105
|
* Looks for a package.json with name '@ornexus/neocortex' (monorepo root) or
|
|
@@ -98,6 +136,12 @@ export interface RefreshStubsOptions {
|
|
|
98
136
|
* real environment.
|
|
99
137
|
*/
|
|
100
138
|
env?: NodeJS.ProcessEnv;
|
|
139
|
+
/**
|
|
140
|
+
* P228.19: absolute project root. Existing project agent profiles (Claude,
|
|
141
|
+
* OpenCode, Codex) are migrated before the user scope; refresh never
|
|
142
|
+
* creates a project profile where none was installed.
|
|
143
|
+
*/
|
|
144
|
+
projectRoot?: string;
|
|
101
145
|
}
|
|
102
146
|
/**
|
|
103
147
|
* Refresh installed stubs if CLI version differs from installed version.
|
|
@@ -115,3 +159,9 @@ export interface RefreshStubsOptions {
|
|
|
115
159
|
* Returns the number of targets that were refreshed.
|
|
116
160
|
*/
|
|
117
161
|
export declare function refreshStubs(cliVersion: string, options?: RefreshStubsOptions): number;
|
|
162
|
+
/**
|
|
163
|
+
* P228.19: same refresh as {@link refreshStubs}, plus the ordered public
|
|
164
|
+
* results (project scope first). Never throws.
|
|
165
|
+
*/
|
|
166
|
+
export declare function refreshStubsReport(cliVersion: string, options?: RefreshStubsOptions): RefreshStubsReport;
|
|
167
|
+
export {};
|