@unity-china/codely-cli 1.0.0-rc.50 → 1.0.0-rc.52

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.
@@ -79,6 +79,45 @@
79
79
  * symbols and keeps scope helpers for its own use.
80
80
  * SPDX-License-Identifier: Apache-2.0
81
81
  */
82
+ /**
83
+ * @license
84
+ * Copyright 2026 Codely
85
+ * SPDX-License-Identifier: Apache-2.0
86
+ *
87
+ * Absolute physical anchor for the non-alt (main-screen Static-split) live
88
+ * region.
89
+ *
90
+ * Every normal frame positions the floating dock with RELATIVE cursor moves
91
+ * (`parkBackToBottom` + `cursorUp(prevHeight)`), which assumes the physical
92
+ * cursor is exactly where ink parked it. Recovery paths (sleep/stall
93
+ * self-heal, focus regain) inherit that assumption, so if anything moved the
94
+ * physical cursor out of band the repaint lands on the wrong rows — it can
95
+ * stack a second dock or paint over committed transcript.
96
+ *
97
+ * The insight that makes recovery fixable: out-of-band cursor moves relocate
98
+ * the CURSOR, not the CONTENT. The dock's physical rows are still where ink
99
+ * wrote them. So if ink remembers the live region's absolute TOP row, a
100
+ * recovery repaint can address it with an absolute CUP instead of relative
101
+ * moves and is then immune to cursor drift.
102
+ *
103
+ * Tracking rules (all derived from data ink already has per frame):
104
+ *
105
+ * - The absolute row is unknowable at startup: the CLI begins wherever the
106
+ * shell prompt happened to be. `top` therefore starts as `null` and callers
107
+ * must fall back to the legacy relative behavior while it is null.
108
+ * - Once ink has emitted at least `terminalRows` scrollback rows, everything
109
+ * it wrote has scrolled the cursor to the bottom row, so the live region
110
+ * provably occupies the last `liveHeight` rows — that is the one moment an
111
+ * exact absolute claim can be made, and it seeds the anchor.
112
+ * - Afterwards the anchor moves incrementally: appended static rows push it
113
+ * down (bounded by the screen bottom), a growing live region pushes it up,
114
+ * and a shrinking one leaves it where it is — `serializeFrameForOverwrite`
115
+ * keeps the region top fixed on a shrink and erases the vacated rows below,
116
+ * so the dock is NOT bottom-pinned after shrinking.
117
+ * - Anything that invalidates ink's picture of the screen (resize, ED2/clear,
118
+ * external-program handoff, alt-screen transitions) resets the anchor to
119
+ * unknown rather than guessing.
120
+ */
82
121
  /**
83
122
  * @license
84
123
  * Copyright 2026 Codely
@@ -0,0 +1,76 @@
1
+ # Codely built-in loop-detection evidence policy (DEFAULT tier).
2
+ # Override by placing files in:
3
+ # ~/.codely-cli/loop-detection-policies/*.toml
4
+ # (system) .../loop-detection-policies/*.toml
5
+ #
6
+ # judge_system_prompt configures only the policy body. The code always wraps it
7
+ # in fixed diagnostic, untrusted-data, non-execution, and response guardrails.
8
+ # Placeholders in this policy body:
9
+ # {{ignored_tools}} — comma-separated ignored tool patterns
10
+ # {{ignored_tools_section}} — full ignored-tools paragraph (or empty)
11
+ # {{analysis_max_chars}} — analysis length budget
12
+ #
13
+ # Threshold fields below are the shipped defaults (keep in sync with
14
+ # DEFAULT_LOOP_CYCLE_THRESHOLD_CONFIG in loopEvidencePolicy.ts). Higher-tier
15
+ # TOML may override individual fields; omitted fields keep these defaults.
16
+ #
17
+ # Content detection layers (not all TOML-configurable):
18
+ # - Short fast-path (code): identical short chunks / same line ×10
19
+ # - Long-stream probe (TOML): tail needle grep → discover period length
20
+
21
+ version = 1
22
+
23
+ # Enable periodic tool-call cycle detection (A→B→A→B, k=2..tool_cycle_max_period).
24
+ # Does NOT disable content/reasoning probe detection.
25
+ enable_cycle_detection = true
26
+
27
+ # Max tool-cycle period length k (detect cycles of length 2..k). Range: 2–10.
28
+ tool_cycle_max_period = 5
29
+
30
+ # Optional fixed repeat count for tool cycles. When omitted (default), required
31
+ # repeats are derived from each tool's effective threshold (e.g. 5 for normal
32
+ # tools, higher for read_file / read-only). Uncomment to force a fixed count:
33
+ # tool_cycle_repeat_count = 5
34
+
35
+ # Long-stream content/reasoning: how many full periods after probe finds a cycle.
36
+ # Range: 2–20. Short chanting still uses the code fast-path (×10).
37
+ content_probe_repeat_threshold = 3
38
+
39
+ # Minimum discovered period length (chars). Must be > short fast-path max (30)
40
+ # so probe does not false-trigger on short repeats. Range: 31–2000. Default: 48.
41
+ # Feasibility: min_period × content_probe_repeat_threshold ≤ 8192 (probe buffer).
42
+ content_probe_min_period_chars = 48
43
+
44
+ # Models matching these patterns disable ALL loop detection for that model
45
+ # instance (stream tool/content/reasoning, LLM judge, strike/recovery/halt).
46
+ # Exact match or a single trailing *; case-insensitive. Highest-tier TOML
47
+ # replaces the whole list (`[]` clears). Main and subagent each evaluate their
48
+ # own active model independently.
49
+ # Example: ["codely-core*", "gpt-5*", "claude-*"]
50
+ loop_detection_exempt_model = ["codely-core*"]
51
+
52
+ judge_system_prompt = """
53
+ An unproductive state is characterized by one or more of the following patterns over the last 5 or more assistant turns:
54
+
55
+ Repetitive Actions: The assistant repeats the same tool calls or conversational responses a decent number of times. This includes simple loops (e.g., tool_A, tool_A, tool_A) and alternating patterns (e.g., tool_A, tool_B, tool_A, tool_B, ...).
56
+
57
+ Cognitive Loop: The assistant seems unable to determine the next logical step. It might express confusion, repeatedly ask the same questions, or generate responses that don't logically follow from the previous turns, indicating it's stuck and not advancing the task.
58
+
59
+ Crucially, differentiate between a true unproductive state and legitimate, incremental progress.
60
+ For example, a series of 'tool_A' or 'tool_B' tool calls that make small, distinct changes to the same file (like adding docstrings to functions one by one) is considered forward progress and is NOT a loop. A loop would be repeatedly replacing the same text with the same content, or cycling between a small set of files with no net change.
61
+ Batch edits across files, different regions of the same file, re-testing after edits, and searches with different parameters are NOT loops.
62
+
63
+ {{ignored_tools_section}}
64
+ """
65
+
66
+ [[loop_detection_rule]]
67
+ name = "ignore builtin Unity TCP tools"
68
+ toolName = "unity_*"
69
+ action = "ignore_as_evidence"
70
+ priority = 500
71
+
72
+ [[loop_detection_rule]]
73
+ name = "ignore Unity bridge entry points"
74
+ toolName = ["execute_custom_tool", "execute_csharp_script"]
75
+ action = "ignore_as_evidence"
76
+ priority = 500
package/package.json CHANGED
@@ -1,13 +1,9 @@
1
1
  {
2
2
  "name": "@unity-china/codely-cli",
3
- "version": "1.0.0-rc.50",
3
+ "version": "1.0.0-rc.52",
4
4
  "engines": {
5
5
  "node": ">=20.0.0"
6
6
  },
7
- "publishConfig": {
8
- "access": "public",
9
- "registry": "https://registry.npmjs.org/"
10
- },
11
7
  "type": "module",
12
8
  "workspaces": [
13
9
  "packages/*"
@@ -78,6 +74,10 @@
78
74
  "README.zh-CN.md",
79
75
  "LICENSE"
80
76
  ],
77
+ "publishConfig": {
78
+ "access": "public",
79
+ "registry": "https://registry.npmjs.org/"
80
+ },
81
81
  "devDependencies": {
82
82
  "@types/marked": "^5.0.2",
83
83
  "@types/micromatch": "^4.0.9",