aether-colony 3.1.17 → 5.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/.aether/aether-utils.sh +5354 -0
- package/.aether/agents-claude/aether-ambassador.md +265 -0
- package/.aether/agents-claude/aether-archaeologist.md +327 -0
- package/.aether/agents-claude/aether-architect.md +236 -0
- package/.aether/agents-claude/aether-auditor.md +271 -0
- package/.aether/agents-claude/aether-builder.md +224 -0
- package/.aether/agents-claude/aether-chaos.md +269 -0
- package/.aether/agents-claude/aether-chronicler.md +305 -0
- package/.aether/agents-claude/aether-gatekeeper.md +330 -0
- package/.aether/agents-claude/aether-includer.md +374 -0
- package/.aether/agents-claude/aether-keeper.md +272 -0
- package/.aether/agents-claude/aether-measurer.md +322 -0
- package/.aether/agents-claude/aether-oracle.md +237 -0
- package/.aether/agents-claude/aether-probe.md +211 -0
- package/.aether/agents-claude/aether-queen.md +330 -0
- package/.aether/agents-claude/aether-route-setter.md +178 -0
- package/.aether/agents-claude/aether-sage.md +418 -0
- package/.aether/agents-claude/aether-scout.md +179 -0
- package/.aether/agents-claude/aether-surveyor-disciplines.md +417 -0
- package/.aether/agents-claude/aether-surveyor-nest.md +355 -0
- package/.aether/agents-claude/aether-surveyor-pathogens.md +289 -0
- package/.aether/agents-claude/aether-surveyor-provisions.md +360 -0
- package/.aether/agents-claude/aether-tracker.md +270 -0
- package/.aether/agents-claude/aether-watcher.md +280 -0
- package/.aether/agents-claude/aether-weaver.md +248 -0
- package/.aether/commands/archaeology.yaml +653 -0
- package/.aether/commands/build.yaml +1221 -0
- package/.aether/commands/chaos.yaml +653 -0
- package/.aether/commands/colonize.yaml +438 -0
- package/.aether/commands/continue.yaml +1484 -0
- package/.aether/commands/council.yaml +304 -0
- package/.aether/commands/data-clean.yaml +80 -0
- package/.aether/commands/dream.yaml +275 -0
- package/.aether/commands/entomb.yaml +863 -0
- package/.aether/commands/export-signals.yaml +64 -0
- package/.aether/commands/feedback.yaml +158 -0
- package/.aether/commands/flag.yaml +160 -0
- package/.aether/commands/flags.yaml +177 -0
- package/.aether/commands/focus.yaml +112 -0
- package/.aether/commands/help.yaml +167 -0
- package/.aether/commands/history.yaml +137 -0
- package/.aether/commands/import-signals.yaml +79 -0
- package/.aether/commands/init.yaml +469 -0
- package/.aether/commands/insert-phase.yaml +98 -0
- package/.aether/commands/interpret.yaml +285 -0
- package/.aether/commands/lay-eggs.yaml +224 -0
- package/.aether/commands/maturity.yaml +122 -0
- package/.aether/commands/memory-details.yaml +74 -0
- package/.aether/commands/migrate-state.yaml +174 -0
- package/.aether/commands/oracle.yaml +1224 -0
- package/.aether/commands/organize.yaml +446 -0
- package/.aether/commands/patrol.yaml +621 -0
- package/.aether/commands/pause-colony.yaml +424 -0
- package/.aether/commands/phase.yaml +124 -0
- package/.aether/commands/pheromones.yaml +153 -0
- package/.aether/commands/plan.yaml +1313 -0
- package/.aether/commands/preferences.yaml +63 -0
- package/.aether/commands/redirect.yaml +123 -0
- package/.aether/commands/resume-colony.yaml +373 -0
- package/.aether/commands/resume.yaml +398 -0
- package/.aether/commands/run.yaml +193 -0
- package/.aether/commands/seal.yaml +1205 -0
- package/.aether/commands/skill-create.yaml +337 -0
- package/.aether/commands/status.yaml +364 -0
- package/.aether/commands/swarm.yaml +352 -0
- package/.aether/commands/tunnels.yaml +814 -0
- package/.aether/commands/update.yaml +131 -0
- package/.aether/commands/verify-castes.yaml +159 -0
- package/.aether/commands/watch.yaml +454 -0
- package/.aether/docs/INCIDENT_TEMPLATE.md +32 -0
- package/.aether/docs/QUEEN-SYSTEM.md +211 -0
- package/.aether/docs/README.md +98 -0
- package/.aether/docs/caste-system.md +48 -0
- package/.aether/docs/command-playbooks/README.md +23 -0
- package/.aether/docs/command-playbooks/build-complete.md +349 -0
- package/.aether/docs/command-playbooks/build-context.md +282 -0
- package/.aether/docs/command-playbooks/build-full.md +1682 -0
- package/.aether/docs/command-playbooks/build-prep.md +283 -0
- package/.aether/docs/command-playbooks/build-verify.md +405 -0
- package/.aether/docs/command-playbooks/build-wave.md +749 -0
- package/.aether/docs/command-playbooks/continue-advance.md +524 -0
- package/.aether/docs/command-playbooks/continue-finalize.md +447 -0
- package/.aether/docs/command-playbooks/continue-full.md +1724 -0
- package/.aether/docs/command-playbooks/continue-gates.md +686 -0
- package/.aether/docs/command-playbooks/continue-verify.md +406 -0
- package/.aether/docs/context-continuity.md +84 -0
- package/{runtime → .aether/docs/disciplines}/DISCIPLINES.md +13 -11
- package/.aether/docs/error-codes.md +268 -0
- package/.aether/docs/known-issues.md +94 -0
- package/{runtime → .aether}/docs/pheromones.md +86 -6
- package/.aether/docs/plans/pheromone-display-plan.md +257 -0
- package/.aether/docs/queen-commands.md +98 -0
- package/.aether/docs/source-of-truth-map.md +132 -0
- package/.aether/docs/xml-utilities.md +47 -0
- package/{runtime → .aether}/exchange/pheromone-xml.sh +2 -1
- package/{runtime → .aether}/exchange/registry-xml.sh +7 -3
- package/{runtime → .aether}/exchange/wisdom-xml.sh +11 -4
- package/.aether/rules/aether-colony.md +144 -0
- package/.aether/schemas/example-prompt-builder.xml +234 -0
- package/.aether/scripts/incident-test-add.sh +47 -0
- package/.aether/scripts/weekly-audit.sh +79 -0
- package/.aether/skills/.index.json +649 -0
- package/.aether/skills/colony/.manifest.json +16 -0
- package/.aether/skills/colony/build-discipline/SKILL.md +78 -0
- package/.aether/skills/colony/colony-interaction/SKILL.md +56 -0
- package/.aether/skills/colony/colony-lifecycle/SKILL.md +77 -0
- package/.aether/skills/colony/colony-visuals/SKILL.md +112 -0
- package/.aether/skills/colony/context-management/SKILL.md +80 -0
- package/.aether/skills/colony/error-presentation/SKILL.md +99 -0
- package/.aether/skills/colony/pheromone-protocol/SKILL.md +79 -0
- package/.aether/skills/colony/pheromone-visibility/SKILL.md +81 -0
- package/.aether/skills/colony/state-safety/SKILL.md +84 -0
- package/.aether/skills/colony/worker-priming/SKILL.md +82 -0
- package/.aether/skills/domain/.manifest.json +24 -0
- package/.aether/skills/domain/README.md +33 -0
- package/.aether/skills/domain/django/SKILL.md +49 -0
- package/.aether/skills/domain/docker/SKILL.md +52 -0
- package/.aether/skills/domain/golang/SKILL.md +52 -0
- package/.aether/skills/domain/graphql/SKILL.md +51 -0
- package/.aether/skills/domain/html-css/SKILL.md +48 -0
- package/.aether/skills/domain/nextjs/SKILL.md +45 -0
- package/.aether/skills/domain/nodejs/SKILL.md +53 -0
- package/.aether/skills/domain/postgresql/SKILL.md +53 -0
- package/.aether/skills/domain/prisma/SKILL.md +59 -0
- package/.aether/skills/domain/python/SKILL.md +50 -0
- package/.aether/skills/domain/rails/SKILL.md +52 -0
- package/.aether/skills/domain/react/SKILL.md +45 -0
- package/.aether/skills/domain/rest-api/SKILL.md +58 -0
- package/.aether/skills/domain/svelte/SKILL.md +47 -0
- package/.aether/skills/domain/tailwind/SKILL.md +45 -0
- package/.aether/skills/domain/testing/SKILL.md +53 -0
- package/.aether/skills/domain/typescript/SKILL.md +58 -0
- package/.aether/skills/domain/vue/SKILL.md +49 -0
- package/.aether/templates/QUEEN.md.template +61 -0
- package/.aether/templates/colony-state-reset.jq.template +23 -0
- package/.aether/templates/colony-state.template.json +39 -0
- package/.aether/templates/constraints.template.json +9 -0
- package/.aether/templates/crowned-anthill.template.md +36 -0
- package/.aether/templates/handoff-build-error.template.md +30 -0
- package/.aether/templates/handoff-build-success.template.md +39 -0
- package/.aether/templates/handoff.template.md +40 -0
- package/.aether/templates/learning-observations.template.json +6 -0
- package/.aether/templates/midden.template.json +13 -0
- package/.aether/templates/pheromones.template.json +6 -0
- package/.aether/templates/session.template.json +9 -0
- package/{runtime → .aether}/utils/atomic-write.sh +68 -22
- package/{runtime → .aether}/utils/chamber-compare.sh +23 -10
- package/.aether/utils/chamber-utils.sh +440 -0
- package/.aether/utils/emoji-audit.sh +166 -0
- package/{runtime → .aether}/utils/error-handler.sh +34 -8
- package/.aether/utils/file-lock.sh +313 -0
- package/.aether/utils/flag.sh +267 -0
- package/.aether/utils/hive.sh +572 -0
- package/.aether/utils/learning.sh +1928 -0
- package/.aether/utils/midden.sh +342 -0
- package/.aether/utils/oracle/oracle.md +168 -0
- package/.aether/utils/oracle/oracle.sh +1023 -0
- package/.aether/utils/pheromone.sh +2029 -0
- package/.aether/utils/queen.sh +1698 -0
- package/.aether/utils/scan.sh +860 -0
- package/.aether/utils/semantic-cli.sh +415 -0
- package/.aether/utils/session.sh +552 -0
- package/.aether/utils/skills.sh +509 -0
- package/.aether/utils/spawn-tree.sh +260 -0
- package/.aether/utils/spawn.sh +260 -0
- package/.aether/utils/state-api.sh +199 -0
- package/{runtime → .aether}/utils/state-loader.sh +8 -6
- package/.aether/utils/suggest.sh +611 -0
- package/{runtime → .aether}/utils/swarm-display.sh +10 -1
- package/.aether/utils/swarm.sh +1004 -0
- package/{runtime → .aether}/utils/watch-spawn-tree.sh +11 -2
- package/{runtime → .aether}/utils/xml-compose.sh +9 -3
- package/.aether/utils/xml-convert.sh +277 -0
- package/{runtime → .aether}/utils/xml-core.sh +5 -9
- package/.aether/utils/xml-query.sh +201 -0
- package/.aether/utils/xml-utils.sh +110 -0
- package/{runtime → .aether}/workers.md +97 -81
- package/.claude/agents/ant/aether-ambassador.md +265 -0
- package/.claude/agents/ant/aether-archaeologist.md +327 -0
- package/.claude/agents/ant/aether-architect.md +236 -0
- package/.claude/agents/ant/aether-auditor.md +271 -0
- package/.claude/agents/ant/aether-builder.md +224 -0
- package/.claude/agents/ant/aether-chaos.md +269 -0
- package/.claude/agents/ant/aether-chronicler.md +305 -0
- package/.claude/agents/ant/aether-gatekeeper.md +330 -0
- package/.claude/agents/ant/aether-includer.md +374 -0
- package/.claude/agents/ant/aether-keeper.md +272 -0
- package/.claude/agents/ant/aether-measurer.md +322 -0
- package/.claude/agents/ant/aether-oracle.md +237 -0
- package/.claude/agents/ant/aether-probe.md +211 -0
- package/.claude/agents/ant/aether-queen.md +330 -0
- package/.claude/agents/ant/aether-route-setter.md +178 -0
- package/.claude/agents/ant/aether-sage.md +418 -0
- package/.claude/agents/ant/aether-scout.md +179 -0
- package/.claude/agents/ant/aether-surveyor-disciplines.md +417 -0
- package/.claude/agents/ant/aether-surveyor-nest.md +355 -0
- package/.claude/agents/ant/aether-surveyor-pathogens.md +289 -0
- package/.claude/agents/ant/aether-surveyor-provisions.md +360 -0
- package/.claude/agents/ant/aether-tracker.md +270 -0
- package/.claude/agents/ant/aether-watcher.md +280 -0
- package/.claude/agents/ant/aether-weaver.md +248 -0
- package/.claude/commands/ant/archaeology.md +16 -14
- package/.claude/commands/ant/build.md +43 -1028
- package/.claude/commands/ant/chaos.md +19 -23
- package/.claude/commands/ant/colonize.md +52 -31
- package/.claude/commands/ant/continue.md +40 -1016
- package/.claude/commands/ant/council.md +21 -18
- package/.claude/commands/ant/data-clean.md +81 -0
- package/.claude/commands/ant/dream.md +27 -15
- package/.claude/commands/ant/entomb.md +317 -225
- package/.claude/commands/ant/export-signals.md +57 -0
- package/.claude/commands/ant/feedback.md +48 -26
- package/.claude/commands/ant/flag.md +30 -10
- package/.claude/commands/ant/flags.md +34 -12
- package/.claude/commands/ant/focus.md +45 -19
- package/.claude/commands/ant/help.md +50 -8
- package/.claude/commands/ant/history.md +13 -0
- package/.claude/commands/ant/import-signals.md +71 -0
- package/.claude/commands/ant/init.md +345 -194
- package/.claude/commands/ant/insert-phase.md +101 -0
- package/.claude/commands/ant/interpret.md +26 -4
- package/.claude/commands/ant/lay-eggs.md +184 -127
- package/.claude/commands/ant/maturity.md +32 -11
- package/.claude/commands/ant/memory-details.md +77 -0
- package/.claude/commands/ant/migrate-state.md +20 -2
- package/.claude/commands/ant/oracle.md +337 -74
- package/.claude/commands/ant/organize.md +39 -25
- package/.claude/commands/ant/patrol.md +620 -0
- package/.claude/commands/ant/pause-colony.md +23 -27
- package/.claude/commands/ant/phase.md +40 -42
- package/.claude/commands/ant/pheromones.md +156 -0
- package/.claude/commands/ant/plan.md +185 -51
- package/.claude/commands/ant/preferences.md +65 -0
- package/.claude/commands/ant/redirect.md +45 -30
- package/.claude/commands/ant/resume-colony.md +51 -27
- package/.claude/commands/ant/resume.md +314 -94
- package/.claude/commands/ant/run.md +195 -0
- package/.claude/commands/ant/seal.md +650 -221
- package/.claude/commands/ant/skill-create.md +286 -0
- package/.claude/commands/ant/status.md +196 -31
- package/.claude/commands/ant/swarm.md +16 -46
- package/.claude/commands/ant/tunnels.md +280 -105
- package/.claude/commands/ant/update.md +73 -89
- package/.claude/commands/ant/verify-castes.md +100 -42
- package/.claude/commands/ant/watch.md +14 -12
- package/.opencode/agents/aether-ambassador.md +63 -20
- package/.opencode/agents/aether-archaeologist.md +29 -12
- package/.opencode/agents/aether-architect.md +103 -36
- package/.opencode/agents/aether-auditor.md +51 -18
- package/.opencode/agents/aether-builder.md +70 -20
- package/.opencode/agents/aether-chaos.md +29 -12
- package/.opencode/agents/aether-chronicler.md +60 -18
- package/.opencode/agents/aether-gatekeeper.md +27 -18
- package/.opencode/agents/aether-includer.md +27 -18
- package/.opencode/agents/aether-keeper.md +89 -18
- package/.opencode/agents/aether-measurer.md +27 -18
- package/.opencode/agents/aether-oracle.md +137 -0
- package/.opencode/agents/aether-probe.md +60 -18
- package/.opencode/agents/aether-queen.md +172 -24
- package/.opencode/agents/aether-route-setter.md +57 -12
- package/.opencode/agents/aether-sage.md +26 -18
- package/.opencode/agents/aether-scout.md +28 -20
- package/.opencode/agents/aether-surveyor-disciplines.md +59 -2
- package/.opencode/agents/aether-surveyor-nest.md +59 -2
- package/.opencode/agents/aether-surveyor-pathogens.md +57 -2
- package/.opencode/agents/aether-surveyor-provisions.md +59 -2
- package/.opencode/agents/aether-tracker.md +64 -18
- package/.opencode/agents/aether-watcher.md +66 -19
- package/.opencode/agents/aether-weaver.md +61 -18
- package/.opencode/commands/ant/archaeology.md +7 -14
- package/.opencode/commands/ant/build.md +437 -257
- package/.opencode/commands/ant/chaos.md +7 -24
- package/.opencode/commands/ant/colonize.md +8 -17
- package/.opencode/commands/ant/continue.md +661 -142
- package/.opencode/commands/ant/council.md +11 -22
- package/.opencode/commands/ant/data-clean.md +77 -0
- package/.opencode/commands/ant/dream.md +15 -17
- package/.opencode/commands/ant/entomb.md +133 -62
- package/.opencode/commands/ant/export-signals.md +54 -0
- package/.opencode/commands/ant/feedback.md +24 -5
- package/.opencode/commands/ant/flag.md +16 -4
- package/.opencode/commands/ant/flags.md +24 -10
- package/.opencode/commands/ant/focus.md +22 -5
- package/.opencode/commands/ant/help.md +41 -8
- package/.opencode/commands/ant/history.md +9 -0
- package/.opencode/commands/ant/import-signals.md +68 -0
- package/.opencode/commands/ant/init.md +374 -167
- package/.opencode/commands/ant/insert-phase.md +107 -0
- package/.opencode/commands/ant/interpret.md +16 -0
- package/.opencode/commands/ant/lay-eggs.md +184 -112
- package/.opencode/commands/ant/maturity.md +18 -2
- package/.opencode/commands/ant/memory-details.md +83 -0
- package/.opencode/commands/ant/migrate-state.md +12 -0
- package/.opencode/commands/ant/oracle.md +322 -67
- package/.opencode/commands/ant/organize.md +18 -16
- package/.opencode/commands/ant/patrol.md +626 -0
- package/.opencode/commands/ant/pause-colony.md +12 -29
- package/.opencode/commands/ant/phase.md +30 -40
- package/.opencode/commands/ant/pheromones.md +162 -0
- package/.opencode/commands/ant/plan.md +184 -56
- package/.opencode/commands/ant/preferences.md +71 -0
- package/.opencode/commands/ant/redirect.md +22 -5
- package/.opencode/commands/ant/resume-colony.md +38 -27
- package/.opencode/commands/ant/resume.md +385 -0
- package/.opencode/commands/ant/run.md +201 -0
- package/.opencode/commands/ant/seal.md +259 -45
- package/.opencode/commands/ant/skill-create.md +63 -0
- package/.opencode/commands/ant/status.md +135 -31
- package/.opencode/commands/ant/swarm.md +3 -345
- package/.opencode/commands/ant/tunnels.md +152 -9
- package/.opencode/commands/ant/update.md +70 -91
- package/.opencode/commands/ant/verify-castes.md +96 -42
- package/.opencode/commands/ant/watch.md +7 -0
- package/CHANGELOG.md +356 -0
- package/README.md +203 -573
- package/bin/cli.js +455 -527
- package/bin/generate-commands.js +186 -0
- package/bin/generate-commands.sh +127 -88
- package/bin/lib/init.js +13 -3
- package/bin/lib/spawn-logger.js +0 -15
- package/bin/lib/update-transaction.js +392 -140
- package/bin/npx-install.js +178 -0
- package/bin/sync-to-runtime.sh +5 -137
- package/bin/validate-package.sh +166 -0
- package/package.json +14 -7
- package/.opencode/agents/aether-guardian.md +0 -107
- package/.opencode/agents/workers.md +0 -1034
- package/bin/lib/model-profiles.js +0 -445
- package/bin/lib/model-verify.js +0 -288
- package/bin/lib/proxy-health.js +0 -253
- package/bin/lib/telemetry.js +0 -441
- package/runtime/CONTEXT.md +0 -160
- package/runtime/QUEEN_ANT_ARCHITECTURE.md +0 -402
- package/runtime/aether-utils.sh +0 -3879
- package/runtime/data/signatures.json +0 -41
- package/runtime/docs/AETHER-2.0-IMPLEMENTATION-PLAN.md +0 -1343
- package/runtime/docs/AETHER-PHEROMONE-SYSTEM-MASTER-SPEC.md +0 -2642
- package/runtime/docs/PHEROMONE-INJECTION.md +0 -240
- package/runtime/docs/PHEROMONE-INTEGRATION.md +0 -192
- package/runtime/docs/PHEROMONE-SYSTEM-DESIGN.md +0 -426
- package/runtime/docs/README.md +0 -94
- package/runtime/docs/VISUAL-OUTPUT-SPEC.md +0 -219
- package/runtime/docs/biological-reference.md +0 -272
- package/runtime/docs/codebase-review.md +0 -399
- package/runtime/docs/command-sync.md +0 -164
- package/runtime/docs/constraints.md +0 -116
- package/runtime/docs/implementation-learnings.md +0 -89
- package/runtime/docs/known-issues.md +0 -217
- package/runtime/docs/namespace.md +0 -148
- package/runtime/docs/pathogen-schema-example.json +0 -36
- package/runtime/docs/pathogen-schema.md +0 -111
- package/runtime/docs/planning-discipline.md +0 -159
- package/runtime/docs/progressive-disclosure.md +0 -184
- package/runtime/lib/queen-utils.sh +0 -729
- package/runtime/model-profiles.yaml +0 -100
- package/runtime/planning.md +0 -159
- package/runtime/recover.sh +0 -136
- package/runtime/templates/QUEEN.md.template +0 -79
- package/runtime/utils/chamber-utils.sh +0 -285
- package/runtime/utils/file-lock.sh +0 -122
- package/runtime/utils/spawn-tree.sh +0 -428
- package/runtime/utils/spawn-with-model.sh +0 -56
- package/runtime/utils/xml-utils.sh +0 -2196
- package/runtime/workers-new-castes.md +0 -516
- /package/{runtime → .aether/docs/disciplines}/coding-standards.md +0 -0
- /package/{runtime → .aether/docs/disciplines}/debugging.md +0 -0
- /package/{runtime → .aether/docs/disciplines}/learning.md +0 -0
- /package/{runtime → .aether/docs/disciplines}/tdd.md +0 -0
- /package/{runtime → .aether/docs/disciplines}/verification-loop.md +0 -0
- /package/{runtime → .aether/docs/disciplines}/verification.md +0 -0
- /package/{runtime → .aether}/schemas/aether-types.xsd +0 -0
- /package/{runtime → .aether}/schemas/colony-registry.xsd +0 -0
- /package/{runtime → .aether}/schemas/pheromone.xsd +0 -0
- /package/{runtime → .aether}/schemas/prompt.xsd +0 -0
- /package/{runtime → .aether}/schemas/queen-wisdom.xsd +0 -0
- /package/{runtime → .aether}/schemas/worker-priming.xsd +0 -0
- /package/{runtime → .aether}/utils/colorize-log.sh +0 -0
- /package/{runtime → .aether}/utils/queen-to-md.xsl +0 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Semantic CLI - Shell interface to Python semantic layer
|
|
3
|
+
#
|
|
4
|
+
# Provides semantic search and indexing capabilities for Aether colony.
|
|
5
|
+
# Uses Python semantic_layer.py for embeddings and similarity search.
|
|
6
|
+
#
|
|
7
|
+
# Usage:
|
|
8
|
+
# source .aether/utils/semantic-cli.sh
|
|
9
|
+
# semantic-init # Initialize semantic store
|
|
10
|
+
# semantic-index "text" # Add text to index
|
|
11
|
+
# semantic-search "query" # Find similar entries
|
|
12
|
+
# semantic-rebuild # Rebuild from all sources
|
|
13
|
+
|
|
14
|
+
# Only set strict mode when executed directly, not when sourced
|
|
15
|
+
if [[ "${BASH_SOURCE[0]:-$0}" == "${0}" ]]; then
|
|
16
|
+
set -euo pipefail
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
# Get script directory for relative paths
|
|
20
|
+
# Fallback for when BASH_SOURCE isn't set (non-interactive sourcing)
|
|
21
|
+
if [[ -n "${BASH_SOURCE[0]:-}" ]]; then
|
|
22
|
+
SEMANTIC_CLI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
23
|
+
else
|
|
24
|
+
# Try to find .aether directory from current location
|
|
25
|
+
if [[ -d ".aether" ]]; then
|
|
26
|
+
SEMANTIC_CLI_DIR="$(pwd)/.aether/utils"
|
|
27
|
+
elif [[ -d "../.aether" ]]; then
|
|
28
|
+
SEMANTIC_CLI_DIR="$(cd .. && pwd)/.aether/utils"
|
|
29
|
+
else
|
|
30
|
+
# Last resort - use aether-utils.sh's detected AETHER_DIR if available
|
|
31
|
+
SEMANTIC_CLI_DIR="${AETHER_DIR:-$HOME/.aether/system}/utils"
|
|
32
|
+
fi
|
|
33
|
+
fi
|
|
34
|
+
AETHER_DIR="$(dirname "$SEMANTIC_CLI_DIR")"
|
|
35
|
+
PROJECT_ROOT="$(dirname "$AETHER_DIR")"
|
|
36
|
+
|
|
37
|
+
# Data directory for semantic store
|
|
38
|
+
SEMANTIC_DATA_DIR="${AETHER_DIR}/data/semantic"
|
|
39
|
+
SEMANTIC_EMBEDDINGS_FILE="${SEMANTIC_DATA_DIR}/embeddings.json"
|
|
40
|
+
|
|
41
|
+
# Check if Python dependencies are available
|
|
42
|
+
semantic-check-deps() {
|
|
43
|
+
python3 -c "import sys; sys.path.insert(0, '$AETHER_DIR'); from semantic_layer import EmbeddingModel; print('ok')" 2>/dev/null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Initialize semantic store directory
|
|
47
|
+
semantic-init() {
|
|
48
|
+
mkdir -p "$SEMANTIC_DATA_DIR"
|
|
49
|
+
|
|
50
|
+
if [[ ! -f "$SEMANTIC_DATA_DIR/index.json" ]]; then
|
|
51
|
+
cat > "$SEMANTIC_DATA_DIR/index.json" << 'EOF'
|
|
52
|
+
{
|
|
53
|
+
"version": "1.0",
|
|
54
|
+
"entries": [],
|
|
55
|
+
"last_updated": null,
|
|
56
|
+
"stats": {
|
|
57
|
+
"total_entries": 0,
|
|
58
|
+
"by_source": {}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
EOF
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
if [[ ! -f "$SEMANTIC_EMBEDDINGS_FILE" ]]; then
|
|
65
|
+
echo '{"embeddings":{}}' > "$SEMANTIC_EMBEDDINGS_FILE"
|
|
66
|
+
fi
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# Index a single text entry
|
|
70
|
+
# Usage: semantic-index <text> <source> [entry_id]
|
|
71
|
+
semantic-index() {
|
|
72
|
+
local text="${1:-}"
|
|
73
|
+
local source="${2:-unknown}"
|
|
74
|
+
local entry_id="${3:-}"
|
|
75
|
+
|
|
76
|
+
if [[ -z "$text" ]]; then
|
|
77
|
+
semantic_json_err 1 "semantic-index requires text argument"
|
|
78
|
+
return 1
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
semantic-init
|
|
82
|
+
|
|
83
|
+
# Generate entry ID if not provided
|
|
84
|
+
if [[ -z "$entry_id" ]]; then
|
|
85
|
+
entry_id="${source}_$(date +%s)_$((RANDOM % 10000))"
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
local timestamp
|
|
89
|
+
timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
90
|
+
|
|
91
|
+
# Call Python to compute embedding and save everything
|
|
92
|
+
python3 << PYTHON_SCRIPT 2>/dev/null
|
|
93
|
+
import sys
|
|
94
|
+
import json
|
|
95
|
+
sys.path.insert(0, '$AETHER_DIR')
|
|
96
|
+
from semantic_layer import EmbeddingModel
|
|
97
|
+
|
|
98
|
+
# Compute embedding
|
|
99
|
+
model = EmbeddingModel()
|
|
100
|
+
embedding = model.encode('''$text''')
|
|
101
|
+
|
|
102
|
+
# Load existing embeddings
|
|
103
|
+
try:
|
|
104
|
+
with open('$SEMANTIC_EMBEDDINGS_FILE', 'r') as f:
|
|
105
|
+
emb_store = json.load(f)
|
|
106
|
+
except:
|
|
107
|
+
emb_store = {'embeddings': {}}
|
|
108
|
+
|
|
109
|
+
# Store embedding
|
|
110
|
+
emb_store['embeddings']['$entry_id'] = {
|
|
111
|
+
'embedding': embedding,
|
|
112
|
+
'text': '''$text''',
|
|
113
|
+
'source': '$source',
|
|
114
|
+
'indexed_at': '$timestamp'
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
# Save embeddings
|
|
118
|
+
with open('$SEMANTIC_EMBEDDINGS_FILE', 'w') as f:
|
|
119
|
+
json.dump(emb_store, f)
|
|
120
|
+
|
|
121
|
+
# Update index
|
|
122
|
+
try:
|
|
123
|
+
with open('$SEMANTIC_DATA_DIR/index.json', 'r') as f:
|
|
124
|
+
index = json.load(f)
|
|
125
|
+
except:
|
|
126
|
+
index = {'version': '1.0', 'entries': [], 'stats': {}}
|
|
127
|
+
|
|
128
|
+
index['entries'].append({
|
|
129
|
+
'id': '$entry_id',
|
|
130
|
+
'source': '$source',
|
|
131
|
+
'text_preview': '''${text:0:200}''',
|
|
132
|
+
'indexed_at': '$timestamp'
|
|
133
|
+
})
|
|
134
|
+
index['last_updated'] = '$timestamp'
|
|
135
|
+
index['stats']['total_entries'] = len(index['entries'])
|
|
136
|
+
|
|
137
|
+
by_source = {}
|
|
138
|
+
for e in index['entries']:
|
|
139
|
+
src = e.get('source', 'unknown')
|
|
140
|
+
by_source[src] = by_source.get(src, 0) + 1
|
|
141
|
+
index['stats']['by_source'] = by_source
|
|
142
|
+
|
|
143
|
+
with open('$SEMANTIC_DATA_DIR/index.json', 'w') as f:
|
|
144
|
+
json.dump(index, f, indent=2)
|
|
145
|
+
|
|
146
|
+
print(json.dumps({
|
|
147
|
+
'ok': True,
|
|
148
|
+
'entry_id': '$entry_id',
|
|
149
|
+
'embedding_dim': len(embedding),
|
|
150
|
+
'source': '$source'
|
|
151
|
+
}))
|
|
152
|
+
PYTHON_SCRIPT
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
# Search for similar entries
|
|
156
|
+
# Usage: semantic-search <query> [top_k] [threshold] [source_filter]
|
|
157
|
+
semantic-search() {
|
|
158
|
+
local query="${1:-}"
|
|
159
|
+
local top_k="${2:-5}"
|
|
160
|
+
local threshold="${3:-0.5}"
|
|
161
|
+
local source_filter="${4:-}"
|
|
162
|
+
|
|
163
|
+
if [[ -z "$query" ]]; then
|
|
164
|
+
semantic_json_err 1 "semantic-search requires query argument"
|
|
165
|
+
return 1
|
|
166
|
+
fi
|
|
167
|
+
|
|
168
|
+
if [[ ! -f "$SEMANTIC_EMBEDDINGS_FILE" ]]; then
|
|
169
|
+
semantic_json_ok '{"results":[]}' "No semantic index found. Run semantic-init first."
|
|
170
|
+
return 0
|
|
171
|
+
fi
|
|
172
|
+
|
|
173
|
+
# Call Python to search
|
|
174
|
+
python3 << PYTHON_SCRIPT 2>/dev/null
|
|
175
|
+
import sys
|
|
176
|
+
import json
|
|
177
|
+
import math
|
|
178
|
+
sys.path.insert(0, '$AETHER_DIR')
|
|
179
|
+
from semantic_layer import EmbeddingModel
|
|
180
|
+
|
|
181
|
+
def cosine_similarity(v1, v2):
|
|
182
|
+
dot = sum(a*b for a,b in zip(v1, v2))
|
|
183
|
+
norm1 = math.sqrt(sum(a*a for a in v1))
|
|
184
|
+
norm2 = math.sqrt(sum(b*b for b in v2))
|
|
185
|
+
if norm1 == 0 or norm2 == 0:
|
|
186
|
+
return 0.0
|
|
187
|
+
return dot / (norm1 * norm2)
|
|
188
|
+
|
|
189
|
+
# Compute query embedding
|
|
190
|
+
model = EmbeddingModel()
|
|
191
|
+
query_emb = model.encode('''$query''')
|
|
192
|
+
|
|
193
|
+
# Load stored embeddings
|
|
194
|
+
with open('$SEMANTIC_EMBEDDINGS_FILE', 'r') as f:
|
|
195
|
+
emb_store = json.load(f)
|
|
196
|
+
|
|
197
|
+
# Search
|
|
198
|
+
results = []
|
|
199
|
+
for entry_id, data in emb_store.get('embeddings', {}).items():
|
|
200
|
+
# Source filter
|
|
201
|
+
source = data.get('source', '')
|
|
202
|
+
if '$source_filter' and source != '$source_filter':
|
|
203
|
+
continue
|
|
204
|
+
|
|
205
|
+
stored_emb = data.get('embedding', [])
|
|
206
|
+
if not stored_emb:
|
|
207
|
+
continue
|
|
208
|
+
|
|
209
|
+
similarity = cosine_similarity(query_emb, stored_emb)
|
|
210
|
+
|
|
211
|
+
if similarity >= $threshold:
|
|
212
|
+
results.append({
|
|
213
|
+
'id': entry_id,
|
|
214
|
+
'text': data.get('text', ''),
|
|
215
|
+
'source': source,
|
|
216
|
+
'similarity': round(similarity, 3),
|
|
217
|
+
'indexed_at': data.get('indexed_at', '')
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
# Sort by similarity
|
|
221
|
+
results.sort(key=lambda x: x['similarity'], reverse=True)
|
|
222
|
+
results = results[:$top_k]
|
|
223
|
+
|
|
224
|
+
print(json.dumps({
|
|
225
|
+
'ok': True,
|
|
226
|
+
'query': '''$query''',
|
|
227
|
+
'count': len(results),
|
|
228
|
+
'results': results
|
|
229
|
+
}))
|
|
230
|
+
PYTHON_SCRIPT
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
# Find similar entries to check for duplicates
|
|
234
|
+
semantic-find-duplicate() {
|
|
235
|
+
local text="${1:-}"
|
|
236
|
+
local threshold="${2:-0.85}"
|
|
237
|
+
|
|
238
|
+
if [[ -z "$text" ]]; then
|
|
239
|
+
semantic_json_err 1 "semantic-find-duplicate requires text argument"
|
|
240
|
+
return 1
|
|
241
|
+
fi
|
|
242
|
+
|
|
243
|
+
local result
|
|
244
|
+
result=$(semantic-search "$text" 3 "$threshold")
|
|
245
|
+
|
|
246
|
+
local count
|
|
247
|
+
count=$(echo "$result" | jq -r '.count // 0')
|
|
248
|
+
|
|
249
|
+
if [[ "$count" -gt 0 ]]; then
|
|
250
|
+
echo "$result" | jq '. + {"is_duplicate": true}'
|
|
251
|
+
else
|
|
252
|
+
semantic_json_ok "[]" "No duplicates found"
|
|
253
|
+
fi
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
# Rebuild entire index from all Aether data sources
|
|
257
|
+
semantic-rebuild() {
|
|
258
|
+
echo "Rebuilding semantic index from all sources..."
|
|
259
|
+
|
|
260
|
+
# Reset
|
|
261
|
+
rm -rf "$SEMANTIC_DATA_DIR"/*
|
|
262
|
+
semantic-init
|
|
263
|
+
|
|
264
|
+
local count=0
|
|
265
|
+
|
|
266
|
+
# Index flags
|
|
267
|
+
if [[ -f "$AETHER_DIR/data/flags.json" ]]; then
|
|
268
|
+
echo " Indexing flags..."
|
|
269
|
+
local flags_json
|
|
270
|
+
flags_json=$(jq -c '.flags[]' "$AETHER_DIR/data/flags.json" 2>/dev/null || echo "")
|
|
271
|
+
|
|
272
|
+
while IFS= read -r flag; do
|
|
273
|
+
[[ -z "$flag" ]] && continue
|
|
274
|
+
local flag_id flag_title flag_desc
|
|
275
|
+
flag_id=$(echo "$flag" | jq -r '.id // empty')
|
|
276
|
+
flag_title=$(echo "$flag" | jq -r '.title // empty')
|
|
277
|
+
flag_desc=$(echo "$flag" | jq -r '.description // empty')
|
|
278
|
+
|
|
279
|
+
if [[ -n "$flag_title" ]]; then
|
|
280
|
+
semantic-index "$flag_title: $flag_desc" "flags" "$flag_id" >/dev/null 2>&1 || true
|
|
281
|
+
((count++)) || true
|
|
282
|
+
fi
|
|
283
|
+
done <<< "$flags_json"
|
|
284
|
+
fi
|
|
285
|
+
|
|
286
|
+
# Index dreams
|
|
287
|
+
if [[ -d "$AETHER_DIR/dreams" ]]; then
|
|
288
|
+
echo " Indexing dreams..."
|
|
289
|
+
for dream in "$AETHER_DIR/dreams"/*.md; do
|
|
290
|
+
[[ -f "$dream" ]] || continue
|
|
291
|
+
local dream_id dream_content
|
|
292
|
+
dream_id=$(basename "$dream" .md)
|
|
293
|
+
dream_content=$(head -100 "$dream" | tr '\n' ' ')
|
|
294
|
+
|
|
295
|
+
if [[ -n "$dream_content" ]]; then
|
|
296
|
+
semantic-index "$dream_content" "dreams" "$dream_id" >/dev/null 2>&1 || true
|
|
297
|
+
((count++)) || true
|
|
298
|
+
fi
|
|
299
|
+
done
|
|
300
|
+
fi
|
|
301
|
+
|
|
302
|
+
# Index pheromones
|
|
303
|
+
if [[ -f "$AETHER_DIR/data/pheromones.json" ]]; then
|
|
304
|
+
echo " Indexing pheromones..."
|
|
305
|
+
local signals_json
|
|
306
|
+
signals_json=$(jq -c '.signals[]' "$AETHER_DIR/data/pheromones.json" 2>/dev/null || echo "")
|
|
307
|
+
|
|
308
|
+
while IFS= read -r signal; do
|
|
309
|
+
[[ -z "$signal" ]] && continue
|
|
310
|
+
local sig_id sig_type sig_content
|
|
311
|
+
sig_id=$(echo "$signal" | jq -r '.id // empty')
|
|
312
|
+
sig_type=$(echo "$signal" | jq -r '.type // empty')
|
|
313
|
+
sig_content=$(echo "$signal" | jq -r '.content.text // .content // empty')
|
|
314
|
+
|
|
315
|
+
if [[ -n "$sig_content" ]]; then
|
|
316
|
+
semantic-index "[$sig_type] $sig_content" "pheromones" "$sig_id" >/dev/null 2>&1 || true
|
|
317
|
+
((count++)) || true
|
|
318
|
+
fi
|
|
319
|
+
done <<< "$signals_json"
|
|
320
|
+
fi
|
|
321
|
+
|
|
322
|
+
# Index QUEEN.md if exists
|
|
323
|
+
if [[ -f "$AETHER_DIR/data/QUEEN.md" ]]; then
|
|
324
|
+
echo " Indexing QUEEN.md..."
|
|
325
|
+
local queen_content
|
|
326
|
+
queen_content=$(cat "$AETHER_DIR/data/QUEEN.md" | tr '\n' ' ')
|
|
327
|
+
semantic-index "$queen_content" "queen" "queen-wisdom" >/dev/null 2>&1 || true
|
|
328
|
+
((count++)) || true
|
|
329
|
+
fi
|
|
330
|
+
|
|
331
|
+
echo "✅ Indexed $count entries"
|
|
332
|
+
jq -c '.stats' "$SEMANTIC_DATA_DIR/index.json"
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
# Get context relevant to a task (for worker injection)
|
|
336
|
+
semantic-get-context() {
|
|
337
|
+
local task="${1:-}"
|
|
338
|
+
local max_results="${2:-3}"
|
|
339
|
+
|
|
340
|
+
if [[ -z "$task" ]]; then
|
|
341
|
+
echo ""
|
|
342
|
+
return 0
|
|
343
|
+
fi
|
|
344
|
+
|
|
345
|
+
if ! semantic-check-deps >/dev/null 2>&1; then
|
|
346
|
+
echo ""
|
|
347
|
+
return 0
|
|
348
|
+
fi
|
|
349
|
+
|
|
350
|
+
local result
|
|
351
|
+
result=$(semantic-search "$task" "$max_results" 0.5 2>/dev/null || echo '{"results":[]}')
|
|
352
|
+
|
|
353
|
+
local count
|
|
354
|
+
count=$(echo "$result" | jq -r '.count // 0')
|
|
355
|
+
|
|
356
|
+
if [[ "$count" -eq 0 ]]; then
|
|
357
|
+
echo ""
|
|
358
|
+
return 0
|
|
359
|
+
fi
|
|
360
|
+
|
|
361
|
+
echo "---"
|
|
362
|
+
echo "## Relevant Context (semantic search)"
|
|
363
|
+
echo ""
|
|
364
|
+
echo "$result" | jq -r '.results[] | "### \(.source // "unknown") (similarity: \(.similarity))\n\(.text[:200] // .text)\n"'
|
|
365
|
+
echo "---"
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
# Check semantic layer status
|
|
369
|
+
semantic-status() {
|
|
370
|
+
if [[ ! -f "$SEMANTIC_DATA_DIR/index.json" ]]; then
|
|
371
|
+
semantic_json_ok '{"initialized": false, "message": "Run semantic-init to initialize"}'
|
|
372
|
+
return 0
|
|
373
|
+
fi
|
|
374
|
+
|
|
375
|
+
local deps_ok
|
|
376
|
+
if semantic-check-deps >/dev/null 2>&1; then
|
|
377
|
+
deps_ok="true"
|
|
378
|
+
else
|
|
379
|
+
deps_ok="false"
|
|
380
|
+
fi
|
|
381
|
+
|
|
382
|
+
local entry_count
|
|
383
|
+
entry_count=$(jq '.entries | length' "$SEMANTIC_DATA_DIR/index.json" 2>/dev/null || echo "0")
|
|
384
|
+
|
|
385
|
+
jq -n --arg deps_ok "$deps_ok" --arg entries "$entry_count" \
|
|
386
|
+
'{"initialized": true, "dependencies_ok": ($deps_ok == "true"), "total_entries": ($entries | tonumber)}'
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
# Helper: Output JSON OK response
|
|
390
|
+
semantic_json_ok() {
|
|
391
|
+
local result="${1:-}"
|
|
392
|
+
local message="${2:-}"
|
|
393
|
+
jq -n --argjson result "$result" --arg message "$message" \
|
|
394
|
+
'{"ok": true, "result": $result, "message": $message}'
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
# Helper: Output JSON error response
|
|
398
|
+
semantic_json_err() {
|
|
399
|
+
local code="${1:-1}"
|
|
400
|
+
local message="${2:-Unknown error}"
|
|
401
|
+
jq -n --arg code "$code" --arg message "$message" \
|
|
402
|
+
'{"ok": false, "error": {"code": $code, "message": $message}}'
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
# Export functions
|
|
406
|
+
export -f semantic-init
|
|
407
|
+
export -f semantic-index
|
|
408
|
+
export -f semantic-search
|
|
409
|
+
export -f semantic-find-duplicate
|
|
410
|
+
export -f semantic-rebuild
|
|
411
|
+
export -f semantic-get-context
|
|
412
|
+
export -f semantic-status
|
|
413
|
+
export -f semantic-check-deps
|
|
414
|
+
export -f semantic_json_ok
|
|
415
|
+
export -f semantic_json_err
|