@unity-china/codely-cli 1.0.0-rc.50 → 1.0.0-rc.53
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,111 @@
|
|
|
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
|
+
# Same-tier conflicts resolve in ordinal (code-point) file order, independent
|
|
17
|
+
# of the system locale: thresholds/flags take the last ordinal declaration,
|
|
18
|
+
# rules take the first — and within one file, rules resolve by numeric
|
|
19
|
+
# declaration order (every toolName entry expanded from one rule shares its
|
|
20
|
+
# declaration index).
|
|
21
|
+
#
|
|
22
|
+
# Content detection layers:
|
|
23
|
+
# - Short fast-path: identical short chunks / same line, count from
|
|
24
|
+
# content_repeat_threshold (the length windows stay code constants)
|
|
25
|
+
# - Long-stream probe: tail needle grep → discover period length
|
|
26
|
+
|
|
27
|
+
version = 1
|
|
28
|
+
|
|
29
|
+
# Enable periodic tool-call cycle detection (A→B→A→B, k=2..tool_cycle_max_period).
|
|
30
|
+
# Does NOT disable content/reasoning probe detection.
|
|
31
|
+
enable_cycle_detection = true
|
|
32
|
+
|
|
33
|
+
# Max tool-cycle period length k (detect cycles of length 2..k). Range: 2–32.
|
|
34
|
+
tool_cycle_max_period = 32
|
|
35
|
+
|
|
36
|
+
# Full A→B periods required before a tool cycle is reported. Range: 2–20.
|
|
37
|
+
# Deliberately independent of tool_call_threshold: an alternating pattern is
|
|
38
|
+
# weaker evidence than a byte-identical consecutive repeat, so lowering the
|
|
39
|
+
# consecutive threshold must not make cycles fire sooner. A run of the *same*
|
|
40
|
+
# call is never reported here — that is tool_call_threshold's job.
|
|
41
|
+
tool_cycle_repeat_count = 3
|
|
42
|
+
|
|
43
|
+
# Consecutive byte-identical calls of the same tool before detection. The key is
|
|
44
|
+
# a hash of the tool name plus the full model-supplied arguments (never the call
|
|
45
|
+
# id), so a repeat carries no new information. Default 3 tolerates exactly one
|
|
46
|
+
# identical retry: an errored tool's response carries retry guidance, so the
|
|
47
|
+
# immediate same-args re-request is legitimate. Range: 2–20.
|
|
48
|
+
tool_call_threshold = 3
|
|
49
|
+
|
|
50
|
+
# Same, for read-only and whitelisted tools. `read_file` uses this value
|
|
51
|
+
# directly; other whitelisted tools (job_*) get an internal ×2. Range: 2–20.
|
|
52
|
+
# Read-only classification covers the current retrieval tools, e.g.
|
|
53
|
+
# search_file_content, glob, lsp, list_directory.
|
|
54
|
+
read_only_tool_call_threshold = 3
|
|
55
|
+
|
|
56
|
+
# Identical short chunks, or an identical line, repeated this many times in one
|
|
57
|
+
# stream. Kept high on purpose: echoing a file with repetitive lines is normal,
|
|
58
|
+
# so lower this only deliberately. Range: 2–50.
|
|
59
|
+
content_repeat_threshold = 10
|
|
60
|
+
|
|
61
|
+
# Detections within a single prompt before escalating from corrective feedback
|
|
62
|
+
# to a hard halt. Main agent only; subagents never escalate. Range: 1–10.
|
|
63
|
+
strike_threshold = 3
|
|
64
|
+
|
|
65
|
+
# Long-stream content/reasoning: how many full periods after probe finds a cycle.
|
|
66
|
+
# Range: 2–20. Note this is separate from content_repeat_threshold, and the bar
|
|
67
|
+
# after a read-only tool is raised internally to 10 periods.
|
|
68
|
+
content_probe_repeat_threshold = 3
|
|
69
|
+
|
|
70
|
+
# Minimum discovered period length (chars). Must be > short fast-path max (30)
|
|
71
|
+
# so probe does not false-trigger on short repeats. Range: 31–2000. Default: 48.
|
|
72
|
+
# Feasibility: min_period × content_probe_repeat_threshold ≤ 8192 (probe buffer).
|
|
73
|
+
content_probe_min_period_chars = 48
|
|
74
|
+
|
|
75
|
+
# Models matching these patterns disable ALL loop detection for that model
|
|
76
|
+
# instance (stream tool/content/reasoning, LLM judge, strike/recovery/halt).
|
|
77
|
+
# Exact match or a single trailing *; case-insensitive. Highest-tier TOML
|
|
78
|
+
# replaces the whole list (`[]` clears). Main and subagent each evaluate their
|
|
79
|
+
# own active model independently.
|
|
80
|
+
# Example: ["codely-core*", "gpt-5*", "claude-*"]
|
|
81
|
+
loop_detection_exempt_model = ["codely-core*"]
|
|
82
|
+
|
|
83
|
+
judge_system_prompt = """
|
|
84
|
+
An unproductive state is characterized by one or more of the following patterns over the last 5 or more assistant turns:
|
|
85
|
+
|
|
86
|
+
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, ...).
|
|
87
|
+
|
|
88
|
+
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.
|
|
89
|
+
|
|
90
|
+
Crucially, differentiate between a true unproductive state and legitimate, incremental progress.
|
|
91
|
+
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.
|
|
92
|
+
Batch edits across files, different regions of the same file, re-testing after edits, and searches with different parameters are NOT loops.
|
|
93
|
+
|
|
94
|
+
{{ignored_tools_section}}
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
# No loop-evidence rules ship by default: every tool counts as evidence.
|
|
98
|
+
#
|
|
99
|
+
# `loop_detection_rule` is the ONLY place these exemptions can come from — there
|
|
100
|
+
# are no hard-coded builtin rules. Exempting a tool is heavier than it looks: it
|
|
101
|
+
# hides the tool from the consecutive AND cycle detectors, and once ignored tools
|
|
102
|
+
# make up half of recent history the LLM judge is skipped entirely. Prefer
|
|
103
|
+
# raising a threshold over adding an exemption.
|
|
104
|
+
#
|
|
105
|
+
# To exempt a tool family, add it in a user/system policy file:
|
|
106
|
+
#
|
|
107
|
+
# [[loop_detection_rule]]
|
|
108
|
+
# name = "ignore my diagnostic tools"
|
|
109
|
+
# toolName = ["my_diag_*", "my_probe"]
|
|
110
|
+
# action = "ignore_as_evidence"
|
|
111
|
+
# 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.
|
|
3
|
+
"version": "1.0.0-rc.53",
|
|
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",
|