@ksuchoi216/ahe 0.1.2 → 0.1.7

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.
@@ -0,0 +1,8 @@
1
+ agent_md: 80
2
+ product_md: 180
3
+ instructions_md: 180
4
+ feature_list_json: 180
5
+ progress_md: 180
6
+ session_handoff_md: 180
7
+ todo_md: 180
8
+ total: 750
@@ -1,137 +1,195 @@
1
1
  #!/usr/bin/env node
2
2
  const AHE_DIRECTIVE_MARKER = "<ahe-mode>";
3
+
4
+ const STATUS_TABLE_LINES = [
5
+ " - Start the response with a concise status report table.",
6
+ " - Use this consistent Markdown table format:",
7
+ " | Item | Content |",
8
+ " |---|---|",
9
+ " | AGENTS.md | Exists/missing, purpose status, and any obvious issue. |",
10
+ " | PRODUCT.md | Exists/missing, completion state, and whether product scope needs work. |",
11
+ " | INSTRUCTIONS.md | Exists/missing, and whether instruction boundaries need work. |",
12
+ " | feature-list.json | Valid/missing/invalid, unfinished feature summary, and all-done status. |",
13
+ " | PROGRESS.md | Exists/missing and current session state. |",
14
+ " - Keep the table short and readable.",
15
+ " - Do not include the next step inside the table.",
16
+ ];
17
+
18
+ const COMMON_ROUTING_LINES = [
19
+ "1. Run CodeGraph preflight before inspecting harness status:",
20
+ " - Check whether the CodeGraph CLI is installed with `command -v codegraph`.",
21
+ " - If the `codegraph` command is not installed, report `NOT INSTALLATION of codegraph`, skip `codegraph init` and `codegraph sync`, and continue with normal repo inspection.",
22
+ " - If `.codegraph/` does not exist, run `codegraph init` before reviewing code.",
23
+ " - If `.codegraph/` exists, run `codegraph sync` before reviewing code.",
24
+ "",
25
+ "2. Inspect current harness state before choosing a workflow:",
26
+ " - Check `AGENTS.md`.",
27
+ " - Check `docs/PRODUCT.md` and `docs/INSTRUCTIONS.md` as the product/specification source of truth.",
28
+ " - Check `feature-list.json` as a derived tracker.",
29
+ " - Check `PROGRESS.md`.",
30
+ " - Use `ahe-thinker` as the internal decision layer before choosing the next action.",
31
+ " - Before reading large harness files wholesale, let `ahe-thinker` run the `ahe-compression` size detector and call `ahe-compression` if compression is required.",
32
+ "",
33
+ "3. Review code through CodeGraph when available:",
34
+ " - Prefer CodeGraph MCP or CodeGraph exploration for code review and impact context after the preflight command succeeds.",
35
+ " - If CodeGraph is not installed, skip CodeGraph review and rely on normal repo inspection.",
36
+ "",
37
+ "4. Make the first response a simple harness engineering status report table before proceeding:",
38
+ ...STATUS_TABLE_LINES,
39
+ ];
40
+
3
41
  const AHE_PROGRESS_DIRECTIVE = [
42
+ AHE_DIRECTIVE_MARKER,
43
+ "AHE automatic operation activated.",
44
+ "",
45
+ "The user sent the exact AHE command. Operate as the Awesome Harness Engineering router:",
46
+ "",
47
+ ...COMMON_ROUTING_LINES,
48
+ "",
49
+ "5. Decide the next AHE workflow with `ahe-thinker`:",
50
+ " - If no harness files exist, route to `$ahe-init`.",
51
+ " - If `docs/PRODUCT.md` or `docs/INSTRUCTIONS.md` is missing or empty, classify the state as `harness engineering not enough`.",
52
+ " - If `feature-list.json` is missing or invalid, generating an empty one from template is allowed, but do not write specific features until `docs/PRODUCT.md` and `docs/INSTRUCTIONS.md` are created and organized.",
53
+ " - If any feature in `feature-list.json` has a status other than `done`, classify the state as `in the middle of building features` and continue the first unfinished feature whose dependencies are satisfied.",
54
+ " - If all features are `done` and no obvious harness gap remains, classify the state as `completed all` and ask the user for the next task.",
55
+ " - Call `ahe-reviewer` when repo or code understanding is needed.",
56
+ " - Call `ahe-conversator` when the next safe step is blocked on user input.",
57
+ " - Call `ahe-harness` when product docs, instructions, tracking, todo sync, or compression-aware harness maintenance must change.",
58
+ " - Call `ahe-solver` when the next job is solving or planning a feature.",
59
+ "",
60
+ "6. After the table, classify the harness into exactly one state.",
61
+ " - Use exactly one state: `harness engineering not enough`, `in the middle of building features`, or `completed all`.",
62
+ " - Do not include the next step inside the table.",
63
+ " - Continue automatically after classification.",
64
+ ];
65
+
66
+ const AHE_INIT_DIRECTIVE = [
67
+ AHE_DIRECTIVE_MARKER,
68
+ "AHE automatic operation activated.",
69
+ "",
70
+ "The user sent the exact AHE init command. Treat this as a possible new start request:",
71
+ "",
72
+ "1. Route to `$ahe-init` first.",
73
+ "2. If no AHE-managed harness files exist, start initialization normally.",
74
+ "3. If any AHE-managed harness file exists, read the existing files, summarize the current project purpose and product specification state, and ask what restart scope the user wants.",
75
+ "4. Do not remove, overwrite, or refresh existing harness files before the user answers the restart-scope question.",
76
+ "5. If the chosen restart scope replaces prior harness history, summarize that replaced state in the refreshed tracking artifacts instead of creating backup copies.",
77
+ "6. Interpret the restart scope from the user's free-form answer; examples like `purpose` and `product` are not a closed list.",
78
+ "7. Product/instructions specification details belong in `docs/PRODUCT.md` and `docs/INSTRUCTIONS.md`, not `AGENTS.md`.",
79
+ "8. After setup, call `ahe-harness` to build the initial product, instructions, and tracking state.",
80
+ "9. Use `ahe-thinker` before clarification when the next setup step is uncertain.",
81
+ "10. If clarification is needed, call `ahe-conversator` for the exact missing detail.",
82
+ ].join("\n");
83
+
84
+ function getQueryDirective(prompt) {
85
+ return [
4
86
  AHE_DIRECTIVE_MARKER,
5
87
  "AHE automatic operation activated.",
6
88
  "",
7
- "The user sent the exact AHE command. Operate as the Awesome Harness Engineering router:",
89
+ `Original prompt: "${prompt}"`,
8
90
  "",
9
- "1. Run CodeGraph preflight before inspecting harness status:",
10
- " - Check whether the CodeGraph CLI is installed with `command -v codegraph`.",
11
- " - If the `codegraph` command is not installed, report `NOT INSTALLATION of codegraph`, skip `codegraph init` and `codegraph sync`, and continue with normal repo inspection.",
12
- " - If `.codegraph/` does not exist, run `codegraph init` before reviewing code.",
13
- " - If `.codegraph/` exists, run `codegraph sync` before reviewing code.",
91
+ "The user sent an explicit AHE query. Route it through `ahe-thinker`:",
14
92
  "",
15
- "2. Inspect current harness state before choosing a workflow:",
16
- " - Check `AGENTS.md`.",
17
- " - Check `docs/PRODUCT.md` and `docs/INSTRUCTIONS.md` as the product/specification source of truth.",
18
- " - Check `feature-list.json` as a derived tracker.",
19
- " - Check `PROGRESS.md`.",
20
- " - Use `ahe-thinking` as the internal decision layer before choosing the next action.",
93
+ ...COMMON_ROUTING_LINES,
21
94
  "",
22
- "3. Review code through CodeGraph when available:",
23
- " - Prefer CodeGraph MCP or CodeGraph exploration for code review and impact context after the preflight command succeeds.",
24
- " - If CodeGraph is not installed, skip CodeGraph review and rely on normal repo inspection.",
95
+ "5. Decide the next AHE workflow with `ahe-thinker` based on the original prompt:",
96
+ " - Use `ahe-reviewer` for code or harness review work.",
97
+ " - Use `ahe-harness` for product, instructions, progress, feature-list, todo, or compression maintenance.",
98
+ " - For `ahe compress feature-list`, replace old completed feature entries with one summarized done feature, preserve unfinished details, and reconcile `feature-list.json` against `docs/PRODUCT.md`.",
99
+ " - If no new feature can be derived from `docs/PRODUCT.md`, call `ahe-conversator` to ask what next feature, product direction, or goal should be tracked.",
100
+ " - Use `ahe-solver` for feature-solving work.",
101
+ " - If multiple plausible next steps remain, use `ahe-conversator` to ask the minimum question needed.",
25
102
  "",
26
- "4. Make the first response a simple harness engineering status report table before proceeding:",
27
- " - Start the response with a concise status report table.",
28
- " - Use this consistent Markdown table format:",
29
- " | Item | Content |",
30
- " |---|---|",
31
- " | AGENTS.md | Exists/missing, purpose status, and any obvious issue. |",
32
- " | PRODUCT.md | Exists/missing, completion state, and whether product scope needs work. |",
33
- " | INSTRUCTIONS.md | Exists/missing, and whether instruction boundaries need work. |",
34
- " | feature-list.json | Valid/missing/invalid, unfinished feature summary, and all-done status. |",
35
- " | PROGRESS.md | Exists/missing and current session state. |",
36
- " - Keep the table short and readable.",
37
- " - Do not include the next step inside the table.",
38
- "",
39
- "5. Decide the next AHE workflow with `ahe-thinking`:",
40
- " - If no harness files exist, route to `$ahe-init`.",
41
- " - If `docs/PRODUCT.md` or `docs/INSTRUCTIONS.md` is missing or empty, classify the state as `harness engineering not enough` and prioritize product/instructions specification.",
42
- " - If `feature-list.json` is missing or invalid, generating an empty one from template is allowed, but do not write specific features until `docs/PRODUCT.md` and `docs/INSTRUCTIONS.md` are created and organized.",
43
- " - If any feature in `feature-list.json` has a status other than `done`, classify the state as `in the middle of building features` and continue the first unfinished feature whose dependencies are satisfied.",
44
- " - Respect dependencies listed in `feature-list.json`; do not start a dependent feature before prerequisites are done.",
45
- " - If all features are `done` and no obvious harness gap remains, classify the state as `completed all` and ask the user for the next task.",
46
- " - Judge the active `project`, `feature`, or `sub-feature` before moving forward.",
47
- " - For a `project`, require `Why`, `What`, and `How` by default.",
48
- " - For a `feature` or `sub-feature`, require only the minimum of `Why`, `What`, and `How` needed to proceed safely.",
49
- "",
50
- "6. Ask for clarification instead of guessing:",
51
- " - If multiple plausible next steps exist, feature data conflicts, dependencies are unclear, or CodeGraph review points to several valid directions, use `ahe-thinking` to judge the missing detail.",
52
- " - If clarity is missing, call `ahe-conversation` for the exact missing `Why`, `What`, or `How`.",
53
- " - Continue only after one safe next step is clear.",
54
- "",
55
- "7. After the table, classify the harness into exactly one state.",
103
+ "6. After the table, classify the harness into exactly one state.",
56
104
  " - Use exactly one state: `harness engineering not enough`, `in the middle of building features`, or `completed all`.",
57
105
  " - Do not include the next step inside the table.",
58
106
  " - Continue automatically after classification.",
59
- " - Follow this loop: `thinking -> conversation if needed -> execution -> thinking`.",
60
- ].join("\\n");
107
+ ].join("\n");
108
+ }
61
109
 
62
- const AHE_INIT_DIRECTIVE = [
63
- AHE_DIRECTIVE_MARKER,
64
- "AHE automatic operation activated.",
65
- "",
66
- "The user sent the exact AHE init command. Treat this as a possible new start request:",
67
- "",
68
- "1. Route to `$ahe-init` first.",
69
- "2. If no AHE-managed harness files exist, start initialization normally.",
70
- "3. If any AHE-managed harness file exists, read the existing files, summarize the current project purpose and product specification state, and ask what restart scope the user wants.",
71
- "4. Do not back up, remove, overwrite, or refresh existing harness files before the user answers the restart-scope question.",
72
- "5. Interpret the restart scope from the user's free-form answer; examples like `purpose` and `product` are not a closed list.",
73
- "6. Product/instructions specification details belong in `docs/PRODUCT.md` and `docs/INSTRUCTIONS.md`, not `AGENTS.md`.",
74
- "7. Use `ahe-thinking` before clarification when the next setup step is uncertain.",
75
- "8. If clarification is needed, call `ahe-conversation` for the exact missing detail.",
76
- "9. Continue through initialization work until the new start path is clear.",
77
- ].join("\\n");
110
+ function normalizePrompt(prompt) {
111
+ return prompt.trim().toLowerCase();
112
+ }
78
113
 
79
114
  function isExactAheCommand(prompt) {
80
- return normalizePrompt(prompt) === "ahe";
115
+ return normalizePrompt(prompt) === "ahe";
81
116
  }
82
117
 
83
118
  function isExactAheInitCommand(prompt) {
84
- const normalizedPrompt = normalizePrompt(prompt);
85
- return (
86
- normalizedPrompt === "ahe init" ||
87
- normalizedPrompt === "ahe-init" ||
88
- normalizedPrompt === "$ahe-init"
89
- );
119
+ const normalizedPrompt = normalizePrompt(prompt);
120
+ return (
121
+ normalizedPrompt === "ahe init" ||
122
+ normalizedPrompt === "ahe-init" ||
123
+ normalizedPrompt === "$ahe-init"
124
+ );
90
125
  }
91
126
 
92
- function normalizePrompt(prompt) {
93
- return prompt.trim().toLowerCase();
127
+ function isExplicitAheQuery(prompt) {
128
+ const normalizedPrompt = normalizePrompt(prompt);
129
+ if (isExactAheCommand(prompt) || isExactAheInitCommand(prompt)) {
130
+ return false;
131
+ }
132
+ return normalizedPrompt.startsWith("ahe ");
94
133
  }
95
134
 
96
135
  async function main() {
97
- let raw = "";
98
- process.stdin.setEncoding("utf8");
99
- for await (const chunk of process.stdin) {
100
- raw += chunk;
101
- }
136
+ let raw = "";
137
+ process.stdin.setEncoding("utf8");
138
+ for await (const chunk of process.stdin) {
139
+ raw += chunk;
140
+ }
141
+
142
+ if (!raw.trim()) {
143
+ return;
144
+ }
102
145
 
103
- if (!raw.trim()) return;
146
+ let parsed;
147
+ try {
148
+ parsed = JSON.parse(raw);
149
+ } catch {
150
+ return;
151
+ }
152
+
153
+ if (
154
+ parsed &&
155
+ parsed.hook_event_name === "UserPromptSubmit" &&
156
+ typeof parsed.prompt === "string"
157
+ ) {
158
+ if (isExactAheCommand(parsed.prompt)) {
159
+ process.stdout.write(
160
+ JSON.stringify({
161
+ hookSpecificOutput: {
162
+ hookEventName: "UserPromptSubmit",
163
+ additionalContext: AHE_PROGRESS_DIRECTIVE.join("\n"),
164
+ },
165
+ }) + "\n"
166
+ );
167
+ return;
168
+ }
104
169
 
105
- let parsed;
106
- try {
107
- parsed = JSON.parse(raw);
108
- } catch (e) {
109
- return;
170
+ if (isExactAheInitCommand(parsed.prompt)) {
171
+ process.stdout.write(
172
+ JSON.stringify({
173
+ hookSpecificOutput: {
174
+ hookEventName: "UserPromptSubmit",
175
+ additionalContext: AHE_INIT_DIRECTIVE,
176
+ },
177
+ }) + "\n"
178
+ );
179
+ return;
110
180
  }
111
181
 
112
- if (
113
- parsed &&
114
- parsed.hook_event_name === "UserPromptSubmit" &&
115
- typeof parsed.prompt === "string"
116
- ) {
117
- if (isExactAheCommand(parsed.prompt)) {
118
- const output = {
119
- hookSpecificOutput: {
120
- hookEventName: "UserPromptSubmit",
121
- additionalContext: AHE_PROGRESS_DIRECTIVE
122
- }
123
- };
124
- process.stdout.write(JSON.stringify(output) + "\n");
125
- } else if (isExactAheInitCommand(parsed.prompt)) {
126
- const output = {
127
- hookSpecificOutput: {
128
- hookEventName: "UserPromptSubmit",
129
- additionalContext: AHE_INIT_DIRECTIVE
130
- }
131
- };
132
- process.stdout.write(JSON.stringify(output) + "\n");
133
- }
182
+ if (isExplicitAheQuery(parsed.prompt)) {
183
+ process.stdout.write(
184
+ JSON.stringify({
185
+ hookSpecificOutput: {
186
+ hookEventName: "UserPromptSubmit",
187
+ additionalContext: getQueryDirective(parsed.prompt),
188
+ },
189
+ }) + "\n"
190
+ );
134
191
  }
192
+ }
135
193
  }
136
194
 
137
195
  main().catch(() => {});
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: ahe-compression
3
+ description: Internal AHE compression workflow for detecting oversized harness-engineering files and compacting them before AHE thinker or harness routing reads large context. Use when AGENTS.md, docs/PRODUCT.md, docs/INSTRUCTIONS.md, feature-list.json, PROGRESS.md, SESSION-HANDOFF.md, docs/todo.md, or other AHE harness artifacts have too many lines or waste context.
4
+ ---
5
+
6
+ # AHE Compression
7
+
8
+ This is an internal AHE workflow skill, not a user-facing command.
9
+
10
+ Do not treat `$ahe-compression` as a user command.
11
+ Use it after `ahe-thinker` or `ahe-harness` decides that harness context is too large to read
12
+ efficiently.
13
+
14
+ ## Size Detection
15
+
16
+ Run the deterministic line-count preflight before reading full harness files:
17
+
18
+ ```bash
19
+ sh .codex/skills/ahe-compression/scripts/check-harness-size.sh
20
+ ```
21
+
22
+ The script checks these AHE-managed files when they exist:
23
+
24
+ - `AGENTS.md`
25
+ - `docs/PRODUCT.md`
26
+ - `docs/INSTRUCTIONS.md`
27
+ - `feature-list.json`
28
+ - `PROGRESS.md`
29
+ - `SESSION-HANDOFF.md`
30
+ - `docs/todo.md`
31
+
32
+ Default thresholds are configured in `.codex/ahe-shared/config.yaml`:
33
+
34
+ - `agent_md`: 80
35
+ - `product_md`: 180
36
+ - `instructions_md`: 180
37
+ - `feature_list_json`: 180
38
+ - `progress_md`: 180
39
+ - `session_handoff_md`: 180
40
+ - `todo_md`: 180
41
+ - `total`: 750 (combined harness context limit)
42
+
43
+ Override thresholds only when the workspace has an explicit local rule using environment variables (e.g., `AHE_AGENT_MD_LIMIT`, `AHE_FILE_LINE_LIMIT`, `AHE_TOTAL_LINE_LIMIT`):
44
+
45
+ ```bash
46
+ AHE_AGENT_MD_LIMIT=100 AHE_TOTAL_LINE_LIMIT=900 sh .codex/skills/ahe-compression/scripts/check-harness-size.sh
47
+ ```
48
+
49
+ Exit code meanings:
50
+
51
+ - `0`: no compression needed.
52
+ - `2`: compression needed.
53
+ - Output ending in `COMPRESSION_REQUIRED`: compression needed.
54
+ - Any other nonzero code: detector failed; fall back to `wc -l` on the same
55
+ file set and continue the decision manually.
56
+
57
+ ## Compression Decision
58
+
59
+ - If the detector exits `2`, compress before normal AHE routing continues.
60
+ - If only one file exceeds the per-file threshold, compress that file first.
61
+ - If total harness context exceeds the total threshold, compress the largest
62
+ AHE-managed files until the total is under the threshold.
63
+ - If `AGENTS.md` is oversized, obey the local `AGENTS.md` instructions before
64
+ editing it. Compress only sections that local rules allow. If no section is
65
+ safely editable, report the blocker and compress other harness files instead.
66
+ - Do not read an oversized file wholesale after detection. Read headings,
67
+ current-status sections, JSON keys, or bounded line ranges needed to preserve
68
+ behavior.
69
+
70
+ ## Compression Rules
71
+
72
+ - Preserve active requirements, current decisions, incomplete work, blockers,
73
+ dependencies, and verification evidence.
74
+ - Preserve required headers and file formats for `PROGRESS.md`,
75
+ `SESSION-HANDOFF.md`, `feature-list.json`, and `AGENTS.md`.
76
+ - Keep `feature-list.json` valid JSON. Replace stale completed-feature history
77
+ with one summarized done feature, preserve its `id`, `name`, `description`,
78
+ `dependencies`, `status`, and short evidence, and keep current unfinished
79
+ details as-is.
80
+ - Keep `docs/PRODUCT.md` and `docs/INSTRUCTIONS.md` as the current harness
81
+ contract. Remove duplicate historical wording only when the active contract
82
+ remains clear.
83
+ - Keep `PROGRESS.md` focused on current status, recent completed work,
84
+ decisions that still matter, blockers, and latest verification.
85
+ - Keep `SESSION-HANDOFF.md` focused on the startup path for the next session,
86
+ important files, open questions, and current verification status.
87
+ - Do not create backup copies when compressing harness history. Preserve useful
88
+ context through concise summaries in the refreshed harness files instead.
89
+
90
+ ## Completion
91
+
92
+ - Re-run the size detector after compression.
93
+ - Run JSON validation when `feature-list.json` changed.
94
+ - Run the repository's normal harness verification command when compression
95
+ changed tracked harness files.
96
+ - Update `PROGRESS.md` and `SESSION-HANDOFF.md` with the compression evidence
97
+ when they changed or when compression affects the active workflow.
@@ -0,0 +1,6 @@
1
+ interface:
2
+ display_name: "AHE Compression"
3
+ short_description: "Compress oversized harness context"
4
+ default_prompt: "Use $ahe-compression to compact oversized AHE harness files before continuing."
5
+ policy:
6
+ allow_implicit_invocation: false
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env sh
2
+ set -eu
3
+
4
+ limit_agent_md=180
5
+ limit_product_md=180
6
+ limit_instructions_md=180
7
+ limit_feature_list_json=180
8
+ limit_progress_md=180
9
+ limit_session_handoff_md=180
10
+ limit_todo_md=180
11
+ limit_total=750
12
+
13
+ config_file=".codex/ahe-shared/config.yaml"
14
+ if [ -f "${config_file}" ]; then
15
+ while IFS= read -r line || [ -n "$line" ]; do
16
+ line="${line#"${line%%[![:space:]]*}"}"
17
+ line="${line%"${line##*[![:space:]]}"}"
18
+ case "$line" in
19
+ "" | \#*) continue ;;
20
+ esac
21
+
22
+ key="${line%%:*}"
23
+ val="${line#*:}"
24
+ key="${key%"${key##*[![:space:]]}"}"
25
+ val="${val#"${val%%[![:space:]]*}"}"
26
+
27
+ case "$val" in
28
+ ''|*[!0-9]*) continue ;;
29
+ esac
30
+
31
+ case "$key" in
32
+ agent_md) limit_agent_md="$val" ;;
33
+ product_md) limit_product_md="$val" ;;
34
+ instructions_md) limit_instructions_md="$val" ;;
35
+ feature_list_json) limit_feature_list_json="$val" ;;
36
+ progress_md) limit_progress_md="$val" ;;
37
+ session_handoff_md) limit_session_handoff_md="$val" ;;
38
+ todo_md) limit_todo_md="$val" ;;
39
+ total) limit_total="$val" ;;
40
+ esac
41
+ done < "${config_file}"
42
+ fi
43
+
44
+ limit_agent_md="${AHE_AGENT_MD_LIMIT:-${AHE_FILE_LINE_LIMIT:-$limit_agent_md}}"
45
+ limit_product_md="${AHE_PRODUCT_MD_LIMIT:-${AHE_FILE_LINE_LIMIT:-$limit_product_md}}"
46
+ limit_instructions_md="${AHE_INSTRUCTIONS_MD_LIMIT:-${AHE_FILE_LINE_LIMIT:-$limit_instructions_md}}"
47
+ limit_feature_list_json="${AHE_FEATURE_LIST_JSON_LIMIT:-${AHE_FILE_LINE_LIMIT:-$limit_feature_list_json}}"
48
+ limit_progress_md="${AHE_PROGRESS_MD_LIMIT:-${AHE_FILE_LINE_LIMIT:-$limit_progress_md}}"
49
+ limit_session_handoff_md="${AHE_SESSION_HANDOFF_MD_LIMIT:-${AHE_FILE_LINE_LIMIT:-$limit_session_handoff_md}}"
50
+ limit_todo_md="${AHE_TODO_MD_LIMIT:-${AHE_FILE_LINE_LIMIT:-$limit_todo_md}}"
51
+ total_limit="${AHE_TOTAL_LINE_LIMIT:-$limit_total}"
52
+
53
+ total_lines=0
54
+ compression_required=0
55
+
56
+ if [ "$#" -eq 0 ]; then
57
+ set -- \
58
+ "AGENTS.md" \
59
+ "docs/PRODUCT.md" \
60
+ "docs/INSTRUCTIONS.md" \
61
+ "feature-list.json" \
62
+ "PROGRESS.md" \
63
+ "SESSION-HANDOFF.md" \
64
+ "docs/todo.md"
65
+ fi
66
+
67
+ for file_path in "$@"; do
68
+ if [ ! -f "${file_path}" ]; then
69
+ continue
70
+ fi
71
+
72
+ line_count="$(wc -l < "${file_path}")"
73
+ line_count="${line_count#"${line_count%%[![:space:]]*}"}"
74
+ line_count="${line_count%"${line_count##*[![:space:]]}"}"
75
+ total_lines=$((total_lines + line_count))
76
+
77
+ current_limit=180
78
+ case "${file_path}" in
79
+ "AGENTS.md") current_limit="${limit_agent_md}" ;;
80
+ "docs/PRODUCT.md") current_limit="${limit_product_md}" ;;
81
+ "docs/INSTRUCTIONS.md") current_limit="${limit_instructions_md}" ;;
82
+ "feature-list.json") current_limit="${limit_feature_list_json}" ;;
83
+ "PROGRESS.md") current_limit="${limit_progress_md}" ;;
84
+ "SESSION-HANDOFF.md") current_limit="${limit_session_handoff_md}" ;;
85
+ "docs/todo.md") current_limit="${limit_todo_md}" ;;
86
+ *) current_limit="${AHE_FILE_LINE_LIMIT:-180}" ;;
87
+ esac
88
+
89
+ if [ "${line_count}" -ge "${current_limit}" ]; then
90
+ compression_required=1
91
+ printf 'COMPRESS\t%s\t%s\tlimit=%s\n' "${file_path}" "${line_count}" "${current_limit}"
92
+ else
93
+ printf 'OK\t%s\t%s\tlimit=%s\n' "${file_path}" "${line_count}" "${current_limit}"
94
+ fi
95
+ done
96
+
97
+ if [ "${total_lines}" -ge "${total_limit}" ]; then
98
+ compression_required=1
99
+ printf 'COMPRESS_TOTAL\t%s\tlimit=%s\n' "${total_lines}" "${total_limit}"
100
+ else
101
+ printf 'OK_TOTAL\t%s\tlimit=%s\n' "${total_lines}" "${total_limit}"
102
+ fi
103
+
104
+ if [ "${compression_required}" -eq 1 ]; then
105
+ printf 'COMPRESSION_REQUIRED\n'
106
+ exit 2
107
+ fi
108
+
109
+ printf 'COMPRESSION_NOT_REQUIRED\n'
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: ahe-conversator
3
+ description: Internal AHE conversation protocol for recursive clarification, conversation state, and resume-aware workflow guidance.
4
+ ---
5
+
6
+ # AHE Conversator
7
+
8
+ This is an internal AHE workflow skill, not a user-facing command.
9
+
10
+ Do not treat `$ahe-conversator` as a user command.
11
+ Use it after `ahe-thinker` or another AHE agent identifies a missing decision or
12
+ missing `Why`, `What`, or `How`.
13
+
14
+ ## When To Converse
15
+
16
+ - Ask one question at a time.
17
+ - Use conversation state when multiple answers are needed across turns.
18
+ - Clarify product intent, instructions, next feature, restart scope, or any
19
+ decision that materially changes the workflow.
20
+ - If the answer can be derived safely from repo state, do that instead of
21
+ asking.
22
+
23
+ ## Conversation Protocol
24
+
25
+ - Inspect relevant files before asking.
26
+ - Explain the blocked decision briefly.
27
+ - Use a Codex-supported structured response request when it helps.
28
+ - Ask exactly one focused question at a time.
29
+ - Continue recursively until the answer is specific enough to unblock the
30
+ calling workflow.
31
+
32
+ ## State Persistence
33
+
34
+ - Update `.ahe/process_status.json` before pausing for user input.
35
+ - Preserve the current command, current_step, workflow_complete, and files map.
36
+ - Update `PROGRESS.md` and `SESSION-HANDOFF.md` when the pending question
37
+ changes the workflow state.
38
+
39
+ ## Resume Protocol
40
+
41
+ - Read `.ahe/process_status.json` and the relevant workflow artifacts.
42
+ - Summarize the current state briefly.
43
+ - Ask the next focused question or return control to the caller when the answer
44
+ resolves the missing detail.