Commit bf8c8d6
feat(workspace): inject originating site agent context into worktrees (#46)
Adds a default-on injection step to `workspace worktree add` that
snapshots the originating site's agent memory (MEMORY.md, USER.md,
RULES.md) into the new worktree so a fresh agent session cooking in
that worktree starts with the same architectural context its parent
site has accumulated.
Written files:
<worktree>/.claude/CLAUDE.local.md — Claude Code convention
<worktree>/.opencode/AGENTS.local.md — OpenCode convention
Both files receive the same runtime-agnostic payload. The injected
paths are added to the repository's `info/exclude` (NOT .gitignore,
so the tracked repo is never dirtied). git's exclude lookup always
uses the common git dir — per-worktree info/exclude is a no-op — so
we resolve commondir from the worktree's `.git` file and write there.
The patterns are narrow enough to be harmless across other worktrees
and the primary checkout, where no injected files ever exist.
New CLI:
wp datamachine-code workspace worktree add <repo> <branch>
[--skip-context-injection]
wp datamachine-code workspace worktree refresh-context <handle>
New ability:
datamachine/workspace-worktree-refresh-context
Worktree-add ability gains an `inject_context` input (default true);
set false to create a bare worktree. Metadata (`created_from_site`:
URL + agent slug + abspath + timestamp) is persisted in the
`datamachine_worktree_metadata` option keyed by workspace handle, and
dropped when the worktree is removed.
When DM's agent memory layer is unavailable (plugin inactive, running
outside a site context) injection becomes a graceful no-op: the
worktree is still created, the response surfaces
`context_injected=false` with a skip reason, and no error fires.
Closes #45
Co-authored-by: chubes4 <chris@chubes.net>1 parent 784e12c commit bf8c8d6
4 files changed
Lines changed: 708 additions & 28 deletions
File tree
- inc
- Abilities
- Cli/Commands
- Workspace
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
706 | 706 | | |
707 | 707 | | |
708 | 708 | | |
709 | | - | |
| 709 | + | |
710 | 710 | | |
711 | 711 | | |
712 | 712 | | |
713 | 713 | | |
714 | | - | |
| 714 | + | |
715 | 715 | | |
716 | 716 | | |
717 | 717 | | |
718 | | - | |
| 718 | + | |
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
722 | | - | |
| 722 | + | |
723 | 723 | | |
724 | 724 | | |
725 | 725 | | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
726 | 730 | | |
727 | 731 | | |
728 | 732 | | |
729 | 733 | | |
730 | 734 | | |
731 | 735 | | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
739 | 750 | | |
740 | 751 | | |
741 | 752 | | |
| |||
744 | 755 | | |
745 | 756 | | |
746 | 757 | | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
747 | 795 | | |
748 | 796 | | |
749 | 797 | | |
| |||
1131 | 1179 | | |
1132 | 1180 | | |
1133 | 1181 | | |
| 1182 | + | |
| 1183 | + | |
1134 | 1184 | | |
1135 | 1185 | | |
1136 | 1186 | | |
1137 | | - | |
| 1187 | + | |
| 1188 | + | |
1138 | 1189 | | |
1139 | 1190 | | |
1140 | 1191 | | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
1141 | 1203 | | |
1142 | 1204 | | |
1143 | 1205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
887 | 887 | | |
888 | 888 | | |
889 | 889 | | |
890 | | - | |
| 890 | + | |
891 | 891 | | |
892 | 892 | | |
893 | | - | |
| 893 | + | |
| 894 | + | |
894 | 895 | | |
895 | 896 | | |
896 | 897 | | |
897 | 898 | | |
898 | 899 | | |
899 | 900 | | |
900 | 901 | | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
901 | 910 | | |
902 | 911 | | |
903 | 912 | | |
| |||
948 | 957 | | |
949 | 958 | | |
950 | 959 | | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
951 | 966 | | |
952 | 967 | | |
953 | 968 | | |
954 | 969 | | |
955 | 970 | | |
956 | 971 | | |
957 | | - | |
| 972 | + | |
958 | 973 | | |
959 | 974 | | |
960 | 975 | | |
961 | 976 | | |
962 | | - | |
963 | | - | |
964 | | - | |
965 | | - | |
966 | | - | |
967 | | - | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
968 | 984 | | |
969 | 985 | | |
970 | 986 | | |
| |||
983 | 999 | | |
984 | 1000 | | |
985 | 1001 | | |
986 | | - | |
| 1002 | + | |
987 | 1003 | | |
988 | 1004 | | |
989 | 1005 | | |
990 | 1006 | | |
991 | 1007 | | |
992 | 1008 | | |
993 | 1009 | | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
994 | 1020 | | |
995 | 1021 | | |
996 | 1022 | | |
| |||
1118 | 1144 | | |
1119 | 1145 | | |
1120 | 1146 | | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
1121 | 1177 | | |
1122 | 1178 | | |
1123 | 1179 | | |
| |||
0 commit comments