@colin4k1024/tsp 2.5.2 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lib/install-surface.js +5 -0
- package/commands/goal.md +7 -1
- package/commands/heartbeat.md +34 -1
- package/commands/loop-start.md +34 -6
- package/commands/triage.md +8 -1
- package/hooks/README.md +2 -2
- package/hooks/harness-statusline.js +24 -22
- package/hooks/strategic-compact/README.md +11 -12
- package/manifests/install-components.json +40 -0
- package/manifests/install-modules.json +141 -31
- package/manifests/install-profiles.json +2 -0
- package/package.json +2 -1
- package/schemas/loop-spec.schema.json +124 -0
- package/scripts/hooks/pre-compact.js +39 -8
- package/scripts/hooks/session-start-goal-resume.js +3 -20
- package/scripts/hooks/suggest-compact.js +9 -74
- package/scripts/lib/completion-oracle.js +4 -27
- package/scripts/lib/context-window-state.js +129 -0
- package/scripts/lib/context-window.js +294 -0
- package/scripts/lib/heartbeat-scheduler.js +40 -25
- package/scripts/lib/install/request.js +1 -1
- package/scripts/lib/install-manifests.js +9 -1
- package/scripts/lib/install-targets/cangming-home.js +143 -0
- package/scripts/lib/install-targets/codewhale-home.js +187 -0
- package/scripts/lib/install-targets/registry.js +4 -0
- package/scripts/lib/loop-oracle.js +5 -0
- package/scripts/lib/loop-spec.js +168 -0
- package/scripts/lib/loop-state-store.js +221 -0
- package/scripts/lib/transcript-usage.js +193 -0
- package/scripts/test-cangming-install.js +105 -0
- package/skills/strategic-compact/SKILL.md +11 -2
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
"antigravity",
|
|
15
15
|
"codex",
|
|
16
16
|
"opencode",
|
|
17
|
+
"cangming",
|
|
17
18
|
"codebuddy",
|
|
18
19
|
"copilot",
|
|
19
20
|
"windsurf",
|
|
20
|
-
"augment"
|
|
21
|
+
"augment",
|
|
22
|
+
"codewhale"
|
|
21
23
|
],
|
|
22
24
|
"dependencies": [],
|
|
23
25
|
"defaultInstall": true,
|
|
@@ -39,7 +41,9 @@
|
|
|
39
41
|
"antigravity",
|
|
40
42
|
"codex",
|
|
41
43
|
"opencode",
|
|
42
|
-
"
|
|
44
|
+
"cangming",
|
|
45
|
+
"codebuddy",
|
|
46
|
+
"codewhale"
|
|
43
47
|
],
|
|
44
48
|
"dependencies": [],
|
|
45
49
|
"defaultInstall": true,
|
|
@@ -59,7 +63,9 @@
|
|
|
59
63
|
"antigravity",
|
|
60
64
|
"codex",
|
|
61
65
|
"opencode",
|
|
62
|
-
"
|
|
66
|
+
"cangming",
|
|
67
|
+
"codebuddy",
|
|
68
|
+
"codewhale"
|
|
63
69
|
],
|
|
64
70
|
"dependencies": [],
|
|
65
71
|
"defaultInstall": true,
|
|
@@ -79,7 +85,9 @@
|
|
|
79
85
|
"claude",
|
|
80
86
|
"cursor",
|
|
81
87
|
"opencode",
|
|
82
|
-
"
|
|
88
|
+
"cangming",
|
|
89
|
+
"codebuddy",
|
|
90
|
+
"codewhale"
|
|
83
91
|
],
|
|
84
92
|
"dependencies": [],
|
|
85
93
|
"defaultInstall": true,
|
|
@@ -104,10 +112,12 @@
|
|
|
104
112
|
"codex",
|
|
105
113
|
"gemini",
|
|
106
114
|
"opencode",
|
|
115
|
+
"cangming",
|
|
107
116
|
"codebuddy",
|
|
108
117
|
"copilot",
|
|
109
118
|
"windsurf",
|
|
110
|
-
"augment"
|
|
119
|
+
"augment",
|
|
120
|
+
"codewhale"
|
|
111
121
|
],
|
|
112
122
|
"dependencies": [],
|
|
113
123
|
"defaultInstall": true,
|
|
@@ -162,7 +172,9 @@
|
|
|
162
172
|
"antigravity",
|
|
163
173
|
"codex",
|
|
164
174
|
"opencode",
|
|
165
|
-
"
|
|
175
|
+
"cangming",
|
|
176
|
+
"codebuddy",
|
|
177
|
+
"codewhale"
|
|
166
178
|
],
|
|
167
179
|
"dependencies": [
|
|
168
180
|
"rules-core",
|
|
@@ -190,7 +202,9 @@
|
|
|
190
202
|
"antigravity",
|
|
191
203
|
"codex",
|
|
192
204
|
"opencode",
|
|
193
|
-
"
|
|
205
|
+
"cangming",
|
|
206
|
+
"codebuddy",
|
|
207
|
+
"codewhale"
|
|
194
208
|
],
|
|
195
209
|
"dependencies": [
|
|
196
210
|
"platform-configs"
|
|
@@ -233,7 +247,9 @@
|
|
|
233
247
|
"antigravity",
|
|
234
248
|
"codex",
|
|
235
249
|
"opencode",
|
|
236
|
-
"
|
|
250
|
+
"cangming",
|
|
251
|
+
"codebuddy",
|
|
252
|
+
"codewhale"
|
|
237
253
|
],
|
|
238
254
|
"dependencies": [
|
|
239
255
|
"platform-configs"
|
|
@@ -260,7 +276,9 @@
|
|
|
260
276
|
"antigravity",
|
|
261
277
|
"codex",
|
|
262
278
|
"opencode",
|
|
263
|
-
"
|
|
279
|
+
"cangming",
|
|
280
|
+
"codebuddy",
|
|
281
|
+
"codewhale"
|
|
264
282
|
],
|
|
265
283
|
"dependencies": [
|
|
266
284
|
"workflow-quality"
|
|
@@ -284,7 +302,9 @@
|
|
|
284
302
|
"antigravity",
|
|
285
303
|
"codex",
|
|
286
304
|
"opencode",
|
|
287
|
-
"
|
|
305
|
+
"cangming",
|
|
306
|
+
"codebuddy",
|
|
307
|
+
"codewhale"
|
|
288
308
|
],
|
|
289
309
|
"dependencies": [
|
|
290
310
|
"platform-configs"
|
|
@@ -321,7 +341,9 @@
|
|
|
321
341
|
"antigravity",
|
|
322
342
|
"codex",
|
|
323
343
|
"opencode",
|
|
324
|
-
"
|
|
344
|
+
"cangming",
|
|
345
|
+
"codebuddy",
|
|
346
|
+
"codewhale"
|
|
325
347
|
],
|
|
326
348
|
"dependencies": [
|
|
327
349
|
"platform-configs"
|
|
@@ -357,7 +379,9 @@
|
|
|
357
379
|
"antigravity",
|
|
358
380
|
"codex",
|
|
359
381
|
"opencode",
|
|
360
|
-
"
|
|
382
|
+
"cangming",
|
|
383
|
+
"codebuddy",
|
|
384
|
+
"codewhale"
|
|
361
385
|
],
|
|
362
386
|
"dependencies": [
|
|
363
387
|
"platform-configs"
|
|
@@ -385,7 +409,9 @@
|
|
|
385
409
|
"antigravity",
|
|
386
410
|
"codex",
|
|
387
411
|
"opencode",
|
|
388
|
-
"
|
|
412
|
+
"cangming",
|
|
413
|
+
"codebuddy",
|
|
414
|
+
"codewhale"
|
|
389
415
|
],
|
|
390
416
|
"dependencies": [
|
|
391
417
|
"platform-configs"
|
|
@@ -411,7 +437,9 @@
|
|
|
411
437
|
"antigravity",
|
|
412
438
|
"codex",
|
|
413
439
|
"opencode",
|
|
414
|
-
"
|
|
440
|
+
"cangming",
|
|
441
|
+
"codebuddy",
|
|
442
|
+
"codewhale"
|
|
415
443
|
],
|
|
416
444
|
"dependencies": [
|
|
417
445
|
"platform-configs"
|
|
@@ -434,7 +462,9 @@
|
|
|
434
462
|
"antigravity",
|
|
435
463
|
"codex",
|
|
436
464
|
"opencode",
|
|
437
|
-
"
|
|
465
|
+
"cangming",
|
|
466
|
+
"codebuddy",
|
|
467
|
+
"codewhale"
|
|
438
468
|
],
|
|
439
469
|
"dependencies": [
|
|
440
470
|
"business-content"
|
|
@@ -460,7 +490,9 @@
|
|
|
460
490
|
"cursor",
|
|
461
491
|
"codex",
|
|
462
492
|
"opencode",
|
|
463
|
-
"
|
|
493
|
+
"cangming",
|
|
494
|
+
"codebuddy",
|
|
495
|
+
"codewhale"
|
|
464
496
|
],
|
|
465
497
|
"dependencies": [
|
|
466
498
|
"platform-configs"
|
|
@@ -484,7 +516,52 @@
|
|
|
484
516
|
"targets": [
|
|
485
517
|
"claude",
|
|
486
518
|
"codex",
|
|
487
|
-
"opencode"
|
|
519
|
+
"opencode",
|
|
520
|
+
"cangming",
|
|
521
|
+
"codewhale"
|
|
522
|
+
],
|
|
523
|
+
"dependencies": [
|
|
524
|
+
"commands-core",
|
|
525
|
+
"platform-configs"
|
|
526
|
+
],
|
|
527
|
+
"defaultInstall": false,
|
|
528
|
+
"cost": "medium",
|
|
529
|
+
"stability": "beta"
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
"id": "loop-engineering",
|
|
533
|
+
"kind": "orchestration",
|
|
534
|
+
"description": "Loop Engineering command surface, target-neutral state runtime, loop spec schema, heartbeat discovery, and maker/checker loop skills.",
|
|
535
|
+
"paths": [
|
|
536
|
+
".tsp/loop.example.yaml",
|
|
537
|
+
"commands/goal.md",
|
|
538
|
+
"commands/heartbeat.md",
|
|
539
|
+
"commands/triage.md",
|
|
540
|
+
"commands/loop-start.md",
|
|
541
|
+
"commands/loop-status.md",
|
|
542
|
+
"docs/runbooks/loop-engineering-usage.md",
|
|
543
|
+
"schemas/loop-spec.schema.json",
|
|
544
|
+
"scripts/lib/loop-state-store.js",
|
|
545
|
+
"scripts/lib/loop-spec.js",
|
|
546
|
+
"scripts/lib/loop-oracle.js",
|
|
547
|
+
"scripts/lib/completion-oracle.js",
|
|
548
|
+
"scripts/lib/heartbeat-scheduler.js",
|
|
549
|
+
"scripts/hooks/session-start-goal-resume.js",
|
|
550
|
+
"skills/loop-heartbeat",
|
|
551
|
+
"skills/goal-convergence",
|
|
552
|
+
"skills/rework-loop",
|
|
553
|
+
"skills/context-engineering",
|
|
554
|
+
"skills/context-lifecycle",
|
|
555
|
+
"templates/context-docs"
|
|
556
|
+
],
|
|
557
|
+
"targets": [
|
|
558
|
+
"claude",
|
|
559
|
+
"cursor",
|
|
560
|
+
"codex",
|
|
561
|
+
"opencode",
|
|
562
|
+
"cangming",
|
|
563
|
+
"codebuddy",
|
|
564
|
+
"codewhale"
|
|
488
565
|
],
|
|
489
566
|
"dependencies": [
|
|
490
567
|
"commands-core",
|
|
@@ -511,7 +588,9 @@
|
|
|
511
588
|
"cursor",
|
|
512
589
|
"codex",
|
|
513
590
|
"opencode",
|
|
514
|
-
"
|
|
591
|
+
"cangming",
|
|
592
|
+
"codebuddy",
|
|
593
|
+
"codewhale"
|
|
515
594
|
],
|
|
516
595
|
"dependencies": [
|
|
517
596
|
"platform-configs"
|
|
@@ -532,7 +611,9 @@
|
|
|
532
611
|
"cursor",
|
|
533
612
|
"codex",
|
|
534
613
|
"opencode",
|
|
535
|
-
"
|
|
614
|
+
"cangming",
|
|
615
|
+
"codebuddy",
|
|
616
|
+
"codewhale"
|
|
536
617
|
],
|
|
537
618
|
"dependencies": [
|
|
538
619
|
"workflow-engine"
|
|
@@ -559,7 +640,9 @@
|
|
|
559
640
|
"antigravity",
|
|
560
641
|
"codex",
|
|
561
642
|
"opencode",
|
|
562
|
-
"
|
|
643
|
+
"cangming",
|
|
644
|
+
"codebuddy",
|
|
645
|
+
"codewhale"
|
|
563
646
|
],
|
|
564
647
|
"dependencies": [
|
|
565
648
|
"platform-configs"
|
|
@@ -598,7 +681,9 @@
|
|
|
598
681
|
"antigravity",
|
|
599
682
|
"codex",
|
|
600
683
|
"opencode",
|
|
601
|
-
"
|
|
684
|
+
"cangming",
|
|
685
|
+
"codebuddy",
|
|
686
|
+
"codewhale"
|
|
602
687
|
],
|
|
603
688
|
"dependencies": [
|
|
604
689
|
"platform-configs"
|
|
@@ -621,7 +706,9 @@
|
|
|
621
706
|
"antigravity",
|
|
622
707
|
"codex",
|
|
623
708
|
"opencode",
|
|
624
|
-
"
|
|
709
|
+
"cangming",
|
|
710
|
+
"codebuddy",
|
|
711
|
+
"codewhale"
|
|
625
712
|
],
|
|
626
713
|
"dependencies": [
|
|
627
714
|
"platform-configs"
|
|
@@ -650,7 +737,9 @@
|
|
|
650
737
|
"antigravity",
|
|
651
738
|
"codex",
|
|
652
739
|
"opencode",
|
|
653
|
-
"
|
|
740
|
+
"cangming",
|
|
741
|
+
"codebuddy",
|
|
742
|
+
"codewhale"
|
|
654
743
|
],
|
|
655
744
|
"dependencies": [
|
|
656
745
|
"platform-configs"
|
|
@@ -673,7 +762,9 @@
|
|
|
673
762
|
"antigravity",
|
|
674
763
|
"codex",
|
|
675
764
|
"opencode",
|
|
676
|
-
"
|
|
765
|
+
"cangming",
|
|
766
|
+
"codebuddy",
|
|
767
|
+
"codewhale"
|
|
677
768
|
],
|
|
678
769
|
"dependencies": [
|
|
679
770
|
"platform-configs"
|
|
@@ -695,7 +786,9 @@
|
|
|
695
786
|
"claude",
|
|
696
787
|
"cursor",
|
|
697
788
|
"codex",
|
|
698
|
-
"opencode"
|
|
789
|
+
"opencode",
|
|
790
|
+
"cangming",
|
|
791
|
+
"codewhale"
|
|
699
792
|
],
|
|
700
793
|
"dependencies": [
|
|
701
794
|
"agents-core",
|
|
@@ -720,7 +813,9 @@
|
|
|
720
813
|
"claude",
|
|
721
814
|
"cursor",
|
|
722
815
|
"codex",
|
|
723
|
-
"opencode"
|
|
816
|
+
"opencode",
|
|
817
|
+
"cangming",
|
|
818
|
+
"codewhale"
|
|
724
819
|
],
|
|
725
820
|
"dependencies": [
|
|
726
821
|
"team-workflow"
|
|
@@ -760,8 +855,17 @@
|
|
|
760
855
|
"skills/workflow-forensics",
|
|
761
856
|
"templates/context-docs"
|
|
762
857
|
],
|
|
763
|
-
"targets": [
|
|
764
|
-
|
|
858
|
+
"targets": [
|
|
859
|
+
"claude",
|
|
860
|
+
"cursor",
|
|
861
|
+
"codex",
|
|
862
|
+
"opencode",
|
|
863
|
+
"cangming",
|
|
864
|
+
"codewhale"
|
|
865
|
+
],
|
|
866
|
+
"dependencies": [
|
|
867
|
+
"team-workflow"
|
|
868
|
+
],
|
|
765
869
|
"defaultInstall": false,
|
|
766
870
|
"cost": "heavy",
|
|
767
871
|
"stability": "stable"
|
|
@@ -781,7 +885,9 @@
|
|
|
781
885
|
"antigravity",
|
|
782
886
|
"codex",
|
|
783
887
|
"opencode",
|
|
784
|
-
"
|
|
888
|
+
"cangming",
|
|
889
|
+
"codebuddy",
|
|
890
|
+
"codewhale"
|
|
785
891
|
],
|
|
786
892
|
"dependencies": [
|
|
787
893
|
"platform-configs",
|
|
@@ -808,7 +914,9 @@
|
|
|
808
914
|
"antigravity",
|
|
809
915
|
"codex",
|
|
810
916
|
"opencode",
|
|
811
|
-
"
|
|
917
|
+
"cangming",
|
|
918
|
+
"codebuddy",
|
|
919
|
+
"codewhale"
|
|
812
920
|
],
|
|
813
921
|
"dependencies": [
|
|
814
922
|
"hooks-runtime",
|
|
@@ -843,7 +951,9 @@
|
|
|
843
951
|
"antigravity",
|
|
844
952
|
"codex",
|
|
845
953
|
"opencode",
|
|
846
|
-
"
|
|
954
|
+
"cangming",
|
|
955
|
+
"codebuddy",
|
|
956
|
+
"codewhale"
|
|
847
957
|
],
|
|
848
958
|
"dependencies": [
|
|
849
959
|
"commands-core",
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"workflow-engine",
|
|
79
79
|
"workflow-defaults",
|
|
80
80
|
"orchestration",
|
|
81
|
+
"loop-engineering",
|
|
81
82
|
"swift-apple",
|
|
82
83
|
"agentic-patterns",
|
|
83
84
|
"devops-infra",
|
|
@@ -105,6 +106,7 @@
|
|
|
105
106
|
"knowledge-graph",
|
|
106
107
|
"workflow-engine",
|
|
107
108
|
"workflow-defaults",
|
|
109
|
+
"loop-engineering",
|
|
108
110
|
"design-prototyping",
|
|
109
111
|
"enhanced-workflows",
|
|
110
112
|
"rtk-optimization"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colin4k1024/tsp",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.4",
|
|
4
4
|
"description": "Open-source Team Skills Platform for role-based AI delivery workflows, shared skills, hooks, commands, and multi-platform installs.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"install:codex": "node scripts/install-apply.js --profile full --target codex",
|
|
63
63
|
"install:cursor": "node scripts/install-apply.js --profile full --target cursor",
|
|
64
64
|
"install:opencode": "node scripts/install-apply.js --profile full --target opencode",
|
|
65
|
+
"install:cangming": "node scripts/install-apply.js --profile full --target cangming",
|
|
65
66
|
"prepack": "node scripts/validate-prebuilt.js",
|
|
66
67
|
"prepublishOnly": "node scripts/validate-prebuilt.js",
|
|
67
68
|
"test": "node tests/run-all.js",
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://colin4k1024.github.io/tsp/schemas/loop-spec.schema.json",
|
|
4
|
+
"title": "TSP Loop Engineering Spec",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["loop"],
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"loop": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"required": [
|
|
12
|
+
"id",
|
|
13
|
+
"description",
|
|
14
|
+
"cadence",
|
|
15
|
+
"skill",
|
|
16
|
+
"stateFile",
|
|
17
|
+
"gates",
|
|
18
|
+
"maker",
|
|
19
|
+
"checker",
|
|
20
|
+
"budget"
|
|
21
|
+
],
|
|
22
|
+
"additionalProperties": false,
|
|
23
|
+
"properties": {
|
|
24
|
+
"id": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"minLength": 1
|
|
27
|
+
},
|
|
28
|
+
"description": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"minLength": 1
|
|
31
|
+
},
|
|
32
|
+
"cadence": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"pattern": "^[0-9]+[mhd]$"
|
|
35
|
+
},
|
|
36
|
+
"skill": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"minLength": 1
|
|
39
|
+
},
|
|
40
|
+
"stateFile": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"minLength": 1
|
|
43
|
+
},
|
|
44
|
+
"gates": {
|
|
45
|
+
"type": "array",
|
|
46
|
+
"minItems": 1,
|
|
47
|
+
"items": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"required": ["name", "command"],
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"properties": {
|
|
52
|
+
"name": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"minLength": 1
|
|
55
|
+
},
|
|
56
|
+
"command": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"minLength": 1
|
|
59
|
+
},
|
|
60
|
+
"description": {
|
|
61
|
+
"type": "string"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"maker": {
|
|
67
|
+
"$ref": "#/$defs/actor"
|
|
68
|
+
},
|
|
69
|
+
"checker": {
|
|
70
|
+
"$ref": "#/$defs/actor"
|
|
71
|
+
},
|
|
72
|
+
"budget": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"required": ["maxIterations", "maxDuration", "maxDollars"],
|
|
75
|
+
"additionalProperties": false,
|
|
76
|
+
"properties": {
|
|
77
|
+
"maxIterations": {
|
|
78
|
+
"type": "number",
|
|
79
|
+
"exclusiveMinimum": 0
|
|
80
|
+
},
|
|
81
|
+
"maxDuration": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"pattern": "^[0-9]+[mh]$"
|
|
84
|
+
},
|
|
85
|
+
"maxDollars": {
|
|
86
|
+
"type": "number",
|
|
87
|
+
"exclusiveMinimum": 0
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"escalation": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"additionalProperties": false,
|
|
94
|
+
"properties": {
|
|
95
|
+
"onBudgetExhausted": {
|
|
96
|
+
"type": "string",
|
|
97
|
+
"enum": ["triage", "human", "stop"]
|
|
98
|
+
},
|
|
99
|
+
"onSecurityFinding": {
|
|
100
|
+
"type": "string",
|
|
101
|
+
"enum": ["human", "triage", "stop"]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"$defs": {
|
|
109
|
+
"actor": {
|
|
110
|
+
"type": "object",
|
|
111
|
+
"required": ["role", "writeAccess"],
|
|
112
|
+
"additionalProperties": false,
|
|
113
|
+
"properties": {
|
|
114
|
+
"role": {
|
|
115
|
+
"type": "string",
|
|
116
|
+
"minLength": 1
|
|
117
|
+
},
|
|
118
|
+
"writeAccess": {
|
|
119
|
+
"type": "boolean"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -18,8 +18,16 @@ const {
|
|
|
18
18
|
appendFile,
|
|
19
19
|
log
|
|
20
20
|
} = require('../lib/utils');
|
|
21
|
+
const { recordCompactEvent } = require('../lib/context-window-state');
|
|
22
|
+
|
|
23
|
+
async function main(rawInput = '{}') {
|
|
24
|
+
let input = {};
|
|
25
|
+
try {
|
|
26
|
+
input = JSON.parse(rawInput || '{}');
|
|
27
|
+
} catch (_) {
|
|
28
|
+
input = {};
|
|
29
|
+
}
|
|
21
30
|
|
|
22
|
-
async function main() {
|
|
23
31
|
const sessionsDir = getSessionsDir();
|
|
24
32
|
const compactionLog = path.join(sessionsDir, 'compaction-log.txt');
|
|
25
33
|
|
|
@@ -27,7 +35,18 @@ async function main() {
|
|
|
27
35
|
|
|
28
36
|
// Log compaction event with timestamp
|
|
29
37
|
const timestamp = getDateTimeString();
|
|
30
|
-
|
|
38
|
+
let compactEvent = null;
|
|
39
|
+
try {
|
|
40
|
+
compactEvent = recordCompactEvent(input, {
|
|
41
|
+
cwd: input.cwd || input.workspace?.current_dir || process.cwd(),
|
|
42
|
+
});
|
|
43
|
+
} catch (_) {
|
|
44
|
+
compactEvent = null;
|
|
45
|
+
}
|
|
46
|
+
const compactCountSuffix = compactEvent
|
|
47
|
+
? ` (session compact #${compactEvent.sessionCompactCount}, total #${compactEvent.totalCompactCount})`
|
|
48
|
+
: '';
|
|
49
|
+
appendFile(compactionLog, `[${timestamp}] Context compaction triggered${compactCountSuffix}\n`);
|
|
31
50
|
|
|
32
51
|
// If there's an active session file, note the compaction
|
|
33
52
|
const sessions = findFiles(sessionsDir, '*-session.tmp');
|
|
@@ -35,14 +54,26 @@ async function main() {
|
|
|
35
54
|
if (sessions.length > 0) {
|
|
36
55
|
const activeSession = sessions[0].path;
|
|
37
56
|
const timeStr = getTimeString();
|
|
38
|
-
|
|
57
|
+
const countNote = compactEvent ? ` (compact #${compactEvent.sessionCompactCount})` : '';
|
|
58
|
+
appendFile(activeSession, `\n---\n**[Compaction occurred at ${timeStr}${countNote}]** - Context was summarized\n`);
|
|
39
59
|
}
|
|
40
60
|
|
|
41
|
-
log(
|
|
61
|
+
log(`[PreCompact] State saved before compaction${compactCountSuffix}`);
|
|
42
62
|
process.exit(0);
|
|
43
63
|
}
|
|
44
64
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
65
|
+
if (require.main === module) {
|
|
66
|
+
let input = '';
|
|
67
|
+
const stdinTimeout = setTimeout(() => main(input), 5000);
|
|
68
|
+
process.stdin.setEncoding('utf8');
|
|
69
|
+
process.stdin.on('data', chunk => { input += chunk; });
|
|
70
|
+
process.stdin.on('end', () => {
|
|
71
|
+
clearTimeout(stdinTimeout);
|
|
72
|
+
main(input).catch(err => {
|
|
73
|
+
console.error('[PreCompact] Error:', err.message);
|
|
74
|
+
process.exit(0);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = { main };
|
|
@@ -11,34 +11,17 @@
|
|
|
11
11
|
* session start output so the user knows they can resume with `/goal resume`.
|
|
12
12
|
*
|
|
13
13
|
* Behavior:
|
|
14
|
-
* 1. Scans
|
|
14
|
+
* 1. Scans the TSP loop state goals store for active or paused goal files
|
|
15
15
|
* 2. If found, appends a summary to the hook output
|
|
16
16
|
* 3. Non-blocking: failures are silently ignored
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
const fs = require('fs');
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
function getGoalsDir() {
|
|
23
|
-
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
24
|
-
return path.join(home, '.claude', 'goals');
|
|
25
|
-
}
|
|
20
|
+
const { listGoals } = require('../lib/loop-state-store');
|
|
26
21
|
|
|
27
22
|
function scanActiveGoals() {
|
|
28
|
-
const dir = getGoalsDir();
|
|
29
|
-
if (!fs.existsSync(dir)) return [];
|
|
30
|
-
|
|
31
23
|
try {
|
|
32
|
-
return
|
|
33
|
-
.filter(f => f.endsWith('.json'))
|
|
34
|
-
.map(f => {
|
|
35
|
-
try {
|
|
36
|
-
return JSON.parse(fs.readFileSync(path.join(dir, f), 'utf-8'));
|
|
37
|
-
} catch {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
.filter(g => g && (g.state === 'active' || g.state === 'paused'))
|
|
24
|
+
return [...listGoals('active'), ...listGoals('paused')]
|
|
42
25
|
.sort((a, b) => new Date(b.updatedAt) - new Date(a.updatedAt));
|
|
43
26
|
} catch {
|
|
44
27
|
return [];
|