@dannylee1020/kkt 0.5.0

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.
Files changed (50) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +275 -0
  3. package/assets/kkt-readme-modern.png +0 -0
  4. package/bin/kkt-install.mjs +25 -0
  5. package/cmd/kkt/main.go +15 -0
  6. package/go.mod +3 -0
  7. package/internal/workflow/cli.go +349 -0
  8. package/internal/workflow/cli_test.go +1266 -0
  9. package/internal/workflow/guardrails.go +900 -0
  10. package/internal/workflow/init.go +164 -0
  11. package/internal/workflow/init_test.go +113 -0
  12. package/internal/workflow/operations.go +1855 -0
  13. package/internal/workflow/validation_commands.go +291 -0
  14. package/internal/workflow/workspace.go +802 -0
  15. package/internal/workflow/workspace_test.go +285 -0
  16. package/package.json +45 -0
  17. package/scripts/install-cli.sh +210 -0
  18. package/scripts/install.sh +644 -0
  19. package/skills/kkt/SKILL.md +74 -0
  20. package/skills/kkt/references/discovery-tooling.md +53 -0
  21. package/skills/kkt/references/feature-optimization-model.md +120 -0
  22. package/skills/kkt/references/kkt-kernel.md +58 -0
  23. package/skills/kkt/references/layered-modeling-methods.md +101 -0
  24. package/skills/kkt/references/plan-assimilation.md +46 -0
  25. package/skills/kkt/references/schemas.md +231 -0
  26. package/skills/kkt/references/state-contract.md +76 -0
  27. package/skills/kkt-loop/SKILL.md +99 -0
  28. package/skills/kkt-loop/references/discovery-tooling.md +53 -0
  29. package/skills/kkt-loop/references/feature-optimization-model.md +120 -0
  30. package/skills/kkt-loop/references/kkt-kernel.md +58 -0
  31. package/skills/kkt-loop/references/layered-modeling-methods.md +101 -0
  32. package/skills/kkt-loop/references/plan-assimilation.md +46 -0
  33. package/skills/kkt-loop/references/schemas.md +231 -0
  34. package/skills/kkt-loop/references/state-contract.md +76 -0
  35. package/skills/kkt-model/SKILL.md +76 -0
  36. package/skills/kkt-model/references/discovery-tooling.md +53 -0
  37. package/skills/kkt-model/references/feature-optimization-model.md +120 -0
  38. package/skills/kkt-model/references/kkt-kernel.md +58 -0
  39. package/skills/kkt-model/references/layered-modeling-methods.md +101 -0
  40. package/skills/kkt-model/references/plan-assimilation.md +46 -0
  41. package/skills/kkt-model/references/schemas.md +231 -0
  42. package/skills/kkt-model/references/state-contract.md +76 -0
  43. package/skills/kkt-run/SKILL.md +62 -0
  44. package/skills/kkt-run/references/discovery-tooling.md +53 -0
  45. package/skills/kkt-run/references/feature-optimization-model.md +120 -0
  46. package/skills/kkt-run/references/kkt-kernel.md +58 -0
  47. package/skills/kkt-run/references/layered-modeling-methods.md +101 -0
  48. package/skills/kkt-run/references/plan-assimilation.md +46 -0
  49. package/skills/kkt-run/references/schemas.md +231 -0
  50. package/skills/kkt-run/references/state-contract.md +76 -0
@@ -0,0 +1,101 @@
1
+ # Layered Modeling Methods
2
+
3
+ Use this catalog for `$kkt-model`, `$kkt-loop`, or unusually complex `$kkt` work. Do not apply every method to every request.
4
+
5
+ Every layer must produce enough output for the next layer to continue without hidden session context. Load `schemas.md` only when a copyable layer-contract shape is needed.
6
+
7
+ ## Profiles
8
+
9
+ ### Plan Profile
10
+
11
+ Use for ordinary `$kkt` implementation work:
12
+
13
+ - compact intent frame;
14
+ - local discovery with `git`, `rg`, and structural search when useful;
15
+ - hard-constraint feasibility gate;
16
+ - lexicographic ranking of feasible plans;
17
+ - approval before implementation;
18
+ - validation certificate.
19
+
20
+ Keep formal method names out of normal output unless they explain a material tradeoff.
21
+
22
+ ### Deep Profile
23
+
24
+ Use for `$kkt-model` and complex planning:
25
+
26
+ - ask targeted owner-decision questions after quick inspection;
27
+ - build a discovery map with evidence confidence;
28
+ - select and record one intent, discovery, and modeling method;
29
+ - compare candidate models and reject infeasible options first;
30
+ - explain binding constraints, sensitivity, and execution implications.
31
+
32
+ Fallback set: `goal_anti_goal`, `traceability_matrix`, `lexicographic`. Use it when specialized methods do not materially improve reliability.
33
+
34
+ ### Loop Profile
35
+
36
+ Use for `$kkt-loop`:
37
+
38
+ - front-load deeper modeling before execution;
39
+ - write durable state through the CLI;
40
+ - require approval before workspace execution or goal launch;
41
+ - continue from CLI state and evidence;
42
+ - re-optimize only when new evidence changes feasibility, constraints, objective fit, or validation feasibility.
43
+
44
+ ## Intent Methods
45
+
46
+ Purpose: turn rough user input into a meaning frame discovery can test against the repo.
47
+
48
+ - Goal / anti-goal: desired outcome and explicit non-goals.
49
+ - WHY / HOW ladder: find the real objective; ask HOW only when it clarifies desired behavior.
50
+ - Obstacle questions: identify interpretations that would be unacceptable, too broad, or aimed at the wrong workflow.
51
+ - Example / counterexample: use when examples would prevent a materially wrong interpretation.
52
+ - Tradeoff prompt: ask only when competing priorities change the model.
53
+ - Owner-decision filter: classify possible questions as discoverable facts, reversible defaults, owner decisions, or blocking unknowns.
54
+
55
+ Question budget:
56
+
57
+ - clear task: 0-1 questions;
58
+ - medium ambiguity: 1-3 targeted questions;
59
+ - large, high-risk, or ambiguous work: short Socratic pass after quick inspection.
60
+
61
+ ## Discovery Methods
62
+
63
+ Purpose: convert intent into inspected facts and traceable system context.
64
+
65
+ - Naive/local discovery: direct `git`, `rg`, file reads, and tests for obvious locality.
66
+ - Traceability matrix: map intent to files, modules, routes, schemas, tests, docs, config, and runtime boundaries.
67
+ - Coupling map: identify callers, public interfaces, state owners, side effects, and downstream contracts.
68
+ - DSM-lite: use a small dependency matrix when several modules/workflows make blast radius unclear.
69
+ - Structural discovery: use `ast-grep` when syntax matters.
70
+
71
+ Discovery output must distinguish observed facts, inferred constraints, assumptions, unknowns, validation paths, unavailable preferred tools, fallback notes, and important negative searches.
72
+
73
+ ## Modeling Methods
74
+
75
+ Always apply the hard-constraint feasibility gate before ranking.
76
+
77
+ | Decision shape | Method | Use when |
78
+ | --- | --- | --- |
79
+ | Normal implementation choice | Lexicographic ranking | Priorities are clear and correctness / safety / contracts outrank lower preferences. |
80
+ | Branching facts determine feasibility | Decision tree | Repo facts eliminate paths. |
81
+ | Staged transition or rollout | Shortest path | There are real states, transitions, costs, and forbidden states. |
82
+ | Comparable feasible options | Ordinal MCDA | Alternatives differ across blast radius, maintainability, validation clarity, speed, or reversibility. |
83
+ | User priorities are unclear | AHP-style pairwise questions | Risk, speed, migration, or architecture preference determines the choice. |
84
+ | No feasible option clearly dominates | Outranking shortlist | Architecture choices need a defensible shortlist rather than a forced winner. |
85
+
86
+ Do not invent numeric scores for subjective criteria. Prefer ordinal labels unless the user supplies actual weights.
87
+
88
+ ## Execution Methods
89
+
90
+ - Smallest feasible step: edit only the surfaces selected by the model.
91
+ - Contract-preserving change: preserve public APIs, data contracts, security boundaries, and user non-goals unless approval changed them.
92
+ - Re-optimization trigger: stop when new evidence changes feasibility, selected decisions, or validation feasibility.
93
+
94
+ ## Validation Methods
95
+
96
+ - Acceptance-criteria map: map each criterion to evidence.
97
+ - Hard-constraint audit: explicitly check feasibility constraints.
98
+ - Binding-constraint audit: verify the selected plan still respects the constraints that shaped it.
99
+ - Residual-risk register: list claims not proven by validation.
100
+
101
+ Final validation must include commands, checks, artifacts, unavailable checks, residual risk, and a completion certificate.
@@ -0,0 +1,46 @@
1
+ # Plan Assimilation
2
+
3
+ Use this only when KKT is invoked after a host agent or default plan mode has already produced a plan.
4
+
5
+ ## Rule
6
+
7
+ Prior plan text is an untrusted scaffold. Consume whatever exists, extract useful signals, verify discoverable claims, and rebuild the KKT model from KKT's own intent, discovery, constraints, decision variables, selected plan, and validation proof.
8
+
9
+ Do not ask the user to reformat prior plan output.
10
+
11
+ ## Checklist
12
+
13
+ 1. Preserve the original user request and explicit user constraints.
14
+ 2. Extract signals from the prior plan:
15
+ - proposed goal and steps;
16
+ - suspected files, modules, APIs, schemas, routes, tests, docs, or operational surfaces;
17
+ - stated or implied constraints;
18
+ - validation suggestions;
19
+ - open questions and risk signals.
20
+ 3. Classify each signal:
21
+ - `explicit_user_input`;
22
+ - `plan_assumption`;
23
+ - `discoverable_fact`;
24
+ - `candidate_decision`;
25
+ - `candidate_constraint`;
26
+ - `candidate_validation`;
27
+ - `unknown_or_ambiguous`.
28
+ 4. Verify discoverable facts through repo inspection before using them as facts.
29
+ 5. Keep unverified claims as assumptions or candidates, never as discovered facts.
30
+ 6. Add missing KKT structure: objective, constraints, decision variables, candidate feasibility, selected plan, binding constraints, guardrails, and validation proof.
31
+ 7. Reject or revise the prior plan when it violates hard constraints, skips cheaper feasible paths, or names validation that does not exist.
32
+
33
+ ## Anti-Anchoring Checks
34
+
35
+ - Which prior-plan claims were verified?
36
+ - Which claims remain assumptions?
37
+ - Which constraints or decision variables did the plan miss?
38
+ - What smaller or safer feasible plan exists?
39
+ - What validation proof would certify the selected plan?
40
+
41
+ ## Guardrails
42
+
43
+ - Do not enforce a schema on host plan-mode output.
44
+ - Do not treat prior-plan file names, routes, commands, or architecture claims as facts before inspection.
45
+ - Do not rubber-stamp the prior plan as the selected KKT plan.
46
+ - Do not ask the user for repo facts the discovery layer can verify.
@@ -0,0 +1,231 @@
1
+ # KKT Schemas
2
+
3
+ Optional reference for copyable shapes. Do not load this on every invocation; use it when writing or auditing durable KKT state, layer contracts, plan-assimilation output, discovery tooling output, or guardrails.
4
+
5
+ ## Layer Contract
6
+
7
+ ```yaml
8
+ layer_contract:
9
+ layer:
10
+ status: pending | complete | blocked
11
+ method_used:
12
+ inputs_consumed:
13
+ outputs:
14
+ decisions:
15
+ assumptions:
16
+ unknowns:
17
+ artifact_refs:
18
+ next_layer_readiness:
19
+ ```
20
+
21
+ ## Optimized Plan
22
+
23
+ ```yaml
24
+ optimized_plan:
25
+ objective_function:
26
+ known_constraints:
27
+ explicit:
28
+ discovered:
29
+ inferred:
30
+ assumptions:
31
+ decision_variables:
32
+ - name:
33
+ allowed_domain:
34
+ chosen_value:
35
+ rationale:
36
+ files_to_modify:
37
+ - path_or_surface:
38
+ change_type:
39
+ rationale:
40
+ constraint_functions:
41
+ hard:
42
+ - name:
43
+ predicate:
44
+ source:
45
+ status:
46
+ soft:
47
+ - name:
48
+ preference:
49
+ source:
50
+ status:
51
+ candidates:
52
+ feasible:
53
+ rejected:
54
+ selected_plan:
55
+ binding_constraints:
56
+ validation_plan:
57
+ validation_proof:
58
+ execution_implications:
59
+ guardrail_variables:
60
+ residual_risk:
61
+ ```
62
+
63
+ ## Plan Assimilation
64
+
65
+ ```yaml
66
+ plan_assimilation:
67
+ source:
68
+ original_request:
69
+ prior_plan_text:
70
+ extracted_signals:
71
+ proposed_goal:
72
+ proposed_steps:
73
+ suspected_surfaces:
74
+ implied_constraints:
75
+ validation_suggestions:
76
+ open_questions:
77
+ risk_signals:
78
+ classification:
79
+ explicit_user_input:
80
+ plan_assumption:
81
+ discoverable_fact:
82
+ candidate_decision:
83
+ candidate_constraint:
84
+ candidate_validation:
85
+ unknown_or_ambiguous:
86
+ verification:
87
+ verified_facts:
88
+ rejected_claims:
89
+ assumptions_carried:
90
+ searches_or_evidence:
91
+ next_layer_readiness:
92
+ ```
93
+
94
+ ## Discovery Tooling
95
+
96
+ ```yaml
97
+ discovery_tooling:
98
+ available:
99
+ core:
100
+ preferred:
101
+ optional:
102
+ language_native:
103
+ unavailable:
104
+ searches:
105
+ - tool:
106
+ purpose:
107
+ query_or_pattern:
108
+ paths:
109
+ result_summary:
110
+ confidence:
111
+ negative_searches:
112
+ - tool:
113
+ query_or_pattern:
114
+ paths:
115
+ implication:
116
+ fallback_notes:
117
+ ```
118
+
119
+ ## Execution Contract
120
+
121
+ ```yaml
122
+ execution_contract:
123
+ acceptance_criteria:
124
+ validation_plan:
125
+ evidence_required:
126
+ stop_conditions:
127
+ continuation_policy:
128
+ ```
129
+
130
+ ## kkt.yaml
131
+
132
+ ```yaml
133
+ schema_version: 1
134
+ workspace_type: plan | model | run | loop
135
+ profile: plan | model | run | loop
136
+ status: initialized | modeling | approved | executing | validating | complete | blocked
137
+ active_layer: intent | discovery | modeling | execution | validation
138
+ layers:
139
+ intent:
140
+ status: pending | complete | blocked
141
+ method: pending | goal_anti_goal | why_how | obstacle_questions | pairwise_questions
142
+ summary: ""
143
+ artifact: intent.md
144
+ discovery:
145
+ status: pending | complete | blocked
146
+ method: pending | naive | traceability_matrix | coupling_map | dsm_lite
147
+ summary: ""
148
+ artifact: discovery.md
149
+ modeling:
150
+ status: pending | complete | blocked
151
+ method: pending | lexicographic | decision_tree | shortest_path | ordinal_mcda | pairwise_ahp | outranking
152
+ summary: ""
153
+ artifact: model.md
154
+ execution:
155
+ status: pending | complete | blocked
156
+ method: pending | smallest_feasible_step | contract_preserving_change
157
+ summary: ""
158
+ artifact: plan.md
159
+ validation:
160
+ status: pending | complete | blocked
161
+ method: pending | acceptance_map | hard_constraint_audit | binding_constraint_audit
162
+ summary: ""
163
+ artifact: evidence.md
164
+ method_invocations: []
165
+ decision_log: []
166
+ planning_contract:
167
+ objective_function:
168
+ files_to_modify:
169
+ constraint_functions:
170
+ decision_variables:
171
+ validation_proof:
172
+ artifact_refs:
173
+ approval:
174
+ required: true
175
+ status: not_required | pending | approved | rejected
176
+ approved_scope:
177
+ stop_conditions: []
178
+ loop_state:
179
+ current_task: ""
180
+ tasks: []
181
+ acceptance_criteria: []
182
+ evidence: []
183
+ stop_conditions: []
184
+ ```
185
+
186
+ ## guardrails.json
187
+
188
+ ```json
189
+ {
190
+ "schema_version": 1,
191
+ "source": {
192
+ "workspace_type": "model",
193
+ "workspace": ".kkt/model/<slug>",
194
+ "request": ""
195
+ },
196
+ "constraints": [
197
+ {
198
+ "id": "stable-contract",
199
+ "kind": "architecture",
200
+ "severity": "block",
201
+ "statement": "Preserve the selected model's public contract.",
202
+ "allowed_paths": ["internal/workflow/**"],
203
+ "blocked_paths": ["dist/**"]
204
+ }
205
+ ],
206
+ "change_bounds": {
207
+ "allowed_paths": ["internal/workflow/**"],
208
+ "blocked_paths": [".git/**", ".env*", "dist/**"],
209
+ "require_explicit_approval_outside_allowed": true
210
+ },
211
+ "workflow": {
212
+ "execution_mode": "run",
213
+ "requires_approval_before_mutation": true,
214
+ "requires_validation_before_done": true
215
+ },
216
+ "validation": {
217
+ "acceptance_criteria": [],
218
+ "required_commands": [],
219
+ "evidence_required": ["scope audit confirms only allowed paths changed"]
220
+ },
221
+ "drift_policy": {
222
+ "block_on": [
223
+ "missing_approval",
224
+ "empty_allowed_paths",
225
+ "changed_blocked_path",
226
+ "validation_failed"
227
+ ],
228
+ "warn_on": []
229
+ }
230
+ }
231
+ ```
@@ -0,0 +1,76 @@
1
+ # KKT State Contract
2
+
3
+ Use this when KKT state must survive across layers, turns, or coding agents. The goal is not to store everything in YAML; it is to make handoff state explicit, inspectable, and hard to confuse.
4
+
5
+ Load `schemas.md` only when a full `kkt.yaml`, layer output, or `guardrails.json` shape is needed.
6
+
7
+ ## Persistence Tiers
8
+
9
+ | Tier | Skill | Durable files | Use when |
10
+ | --- | --- | --- | --- |
11
+ | Plan | `kkt` | none by default; optional `.kkt/kkt.yaml` | ordinary work where Markdown artifacts would be overhead. |
12
+ | Model | `kkt-model` | `.kkt/model/<slug>/kkt.yaml`, `intent.md`, `discovery.md`, `model.md`, `guardrails.json` | durable model or decision brief before execution. |
13
+ | Run | `kkt-run` | `.kkt/run/<slug>/kkt.yaml`, imported artifacts, `guardrails.json`, `plan.md`, `progress.md`, `evidence.md`, `notes.md` | completed model should be implemented now without loop state. |
14
+ | Loop | `kkt-loop` | `.kkt/loop/<slug>/kkt.yaml`, layer artifacts, `guardrails.json`, `plan.md`, `progress.md`, `evidence.md`, `notes.md`, `events.jsonl` | long-running or resumable execution. |
15
+
16
+ Durable `.kkt/` paths are rooted at the nearest Git/worktree root. Outside Git, the CLI falls back to the current directory.
17
+
18
+ ## CLI Ownership
19
+
20
+ The `kkt` CLI is the canonical mutation interface for KKT state. Skills should use CLI commands for workspace creation, state reads, artifact recording, guardrails, approvals, progress, evidence, validation, and completion.
21
+
22
+ - `kkt.yaml`: current status, active layer, method choices, decisions, artifact references, approvals, stop conditions, and summaries.
23
+ - Markdown artifacts: detailed intent, discovery, modeling rationale, execution plan, progress, evidence, and notes.
24
+ - `guardrails.json`: modeled constraints, allowed paths, blocked paths, validation requirements, and drift policy.
25
+ - `events.jsonl`: loop-only append history for task transitions, evidence, approvals, blockers, validation, and completion.
26
+
27
+ Do not hand-edit `kkt.yaml` as the primary workflow operation when a CLI command exists.
28
+
29
+ ## Useful Commands
30
+
31
+ ```text
32
+ kkt start plan "<request>"
33
+ kkt start model "<request>"
34
+ kkt run from-model [model-workspace]
35
+ kkt start run "<request>"
36
+ kkt start loop "<request>"
37
+ kkt intent|discovery|model --method <method> "<layer output>"
38
+ kkt guardrails show|set|validate
39
+ kkt judge --checkpoint model-ready|pre-mutation|continuation|finalize --json
40
+ kkt validate [--run]
41
+ kkt done
42
+ ```
43
+
44
+ ## Artifact Boundaries
45
+
46
+ - `intent.md`: user meaning, success, scope, examples, priority signals, explicit constraints, unresolved meaning questions.
47
+ - `discovery.md`: files, symbols, components, workflows, discovered constraints, validation paths, coupling, evidence, confidence, unknowns.
48
+ - `model.md`: method selection, objective, constraints, decision variables, candidates, feasibility, selected plan, binding constraints, validation plan, sensitivity, execution implications, residual risk.
49
+ - `guardrails.json`: machine-readable drift contract; run and loop execution must not proceed when modeled constraints or allowed paths are empty.
50
+ - `plan.md`: execution tasks, acceptance criteria, validation plan, evidence required, stop conditions, continuation policy.
51
+ - `progress.md`: work log, progress narrative, blocker notes.
52
+ - `evidence.md`: validation map, command outputs, artifacts, final certificate.
53
+ - `notes.md`: observations, assumptions, open questions, deferred ideas.
54
+ - `events.jsonl`: append-only loop event history, not a competing source of truth for current state.
55
+
56
+ When `guardrails.json` lists `validation.required_commands`, run or loop workspaces must use `kkt validate --run` to record deterministic command proof. `kkt evidence` records narrative evidence and criterion mapping only.
57
+
58
+ ## Handoff Rules
59
+
60
+ 1. Read `kkt.yaml` first when it exists.
61
+ 2. Read the prior layer's artifact before acting.
62
+ 3. Update only the current layer unless repairing a stale reference.
63
+ 4. Append decisions instead of overwriting prior rationale.
64
+ 5. Set `next_layer_readiness` before handing off.
65
+ 6. Record blockers with the smallest user or system change that would unblock.
66
+ 7. If new evidence invalidates an earlier layer, mark the active layer blocked and re-open the earlier layer instead of silently continuing.
67
+
68
+ ## Judge Checkpoints
69
+
70
+ - `model-ready`: before implementation; blocks run/loop execution when model, guardrails, or allowed path bounds are incomplete.
71
+ - `pre-mutation`: before edits or side effects; blocks when approval is missing or explicitly blocked paths changed; unrelated dirty paths outside allowed bounds are ignored.
72
+ - `continuation`: before loop continuation; blocks on active stop conditions or replay drift.
73
+ - `finalize`: before `kkt done`; blocks when validation fails or explicitly blocked paths changed; unrelated dirty paths outside allowed bounds are ignored.
74
+ - `pre-tool`, `post-tool`, `pre-compact`, `post-compact`: portable hook names for adapters; enforce explicit blocked paths without requiring a clean worktree.
75
+
76
+ Treat `block` as a hard stop. Treat `warn` as a contract-quality issue to repair before risky work. Treat `allow` as permission to continue to the next workflow step.
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: kkt-run
3
+ description: Execute an existing KKT model with deterministic drift guardrails. Use when a coding agent should pick up a completed kkt-model workspace, preserve the optimized model and guardrail contract, check model-readiness before mutation, implement the selected plan, validate with evidence, and finish without the long-running kkt-loop continuation machinery.
4
+ license: Apache-2.0
5
+ ---
6
+
7
+ # KKT Run
8
+
9
+ Use this skill when modeling is already complete and the user wants implementation now. It is the execution tier between `$kkt-model` and `$kkt-loop`: richer than a compact plan, but lighter than a durable long-running loop.
10
+
11
+ Read `references/kkt-kernel.md` and `references/state-contract.md` before acting. Read `references/feature-optimization-model.md` only when the completed model must be interpreted, repaired, or checked for drift. Read `references/plan-assimilation.md` only when the selected model used prior-plan assimilation. Read `references/discovery-tooling.md` only when verifying drift or missing facts. Read `references/layered-modeling-methods.md` only when reopening an incomplete model. Read `references/schemas.md` only when auditing full state or guardrail shapes.
12
+
13
+ ## Core Rule
14
+
15
+ Run only the selected model. Before edits, load the model workspace, validate the guardrail contract, run the model-ready judge checkpoint, show the execution contract, and get explicit approval. During implementation, use the pre-mutation and finalize checkpoints to catch drift before changing files or finishing.
16
+
17
+ ## CLI-First Workflow
18
+
19
+ Use the `kkt` CLI as the workflow control path. The skill owns implementation judgment; the CLI owns deterministic workspace creation, guardrail state, checkpoint results, evidence, validation, and completion.
20
+
21
+ ```text
22
+ kkt run from-model [model-workspace]
23
+ kkt status [--json]
24
+ kkt show model
25
+ kkt guardrails validate
26
+ kkt judge --checkpoint model-ready --json
27
+ kkt approve "<approved scope>"
28
+ kkt judge --checkpoint pre-mutation --json
29
+ kkt plan "<execution contract>"
30
+ kkt progress "<progress update>"
31
+ kkt evidence --command "<validation command>" "<validation evidence>"
32
+ kkt validate --run
33
+ kkt judge --checkpoint finalize --json
34
+ kkt done
35
+ ```
36
+
37
+ If no completed model workspace exists, switch back to `$kkt-model` instead of inventing one. If the work needs continuation, autonomous execution, multiple resumptions, task queues, or event replay, switch to `$kkt-loop`.
38
+
39
+ ## Workflow
40
+
41
+ 1. Resolve or create the run workspace with `kkt run from-model [model-workspace]`.
42
+ 2. Read `kkt status --json`, `kkt show model`, `kkt show guardrails`, and `kkt guardrails validate`.
43
+ 3. Run `kkt judge --checkpoint model-ready --json`. Treat `block` as a hard stop, `warn` as a contract-quality issue to repair before risky edits, and `allow` as permission to seek approval. This checkpoint blocks if modeled constraints or allowed path bounds are missing.
44
+ 4. Confirm whether the selected model used plan assimilation. Preserve the model's classification of prior-plan claims and do not promote unverified prior-plan assumptions during execution.
45
+ 5. Show the user the execution contract: selected model, hard constraints, allowed paths, blocked paths, validation commands, and residual risk.
46
+ 6. Get explicit approval and record it with `kkt approve`.
47
+ 7. Before modifying files, run `kkt judge --checkpoint pre-mutation --json`; it blocks if existing git changes are outside `allowed_paths` or inside `blocked_paths`.
48
+ 8. Implement the smallest change that satisfies the selected model. Do not expand scope, add unrelated cleanup, or change the model unless new evidence invalidates feasibility.
49
+ 9. Record progress and validation evidence with CLI commands. Use `kkt evidence` for narrative evidence, not as deterministic command proof.
50
+ 10. Run `kkt validate --run` when guardrails list required commands, then run `kkt judge --checkpoint finalize --json` before `kkt done`.
51
+
52
+ ## Stop Conditions
53
+
54
+ Stop before editing when the model-ready checkpoint blocks, guardrails are missing or invalid for the intended change, approval is missing, changed files are outside allowed paths, changed files hit blocked paths, the selected model no longer matches repo facts, destructive action is required, credentials/secrets/external access/paid services are required, or implementation would expand beyond the model.
55
+
56
+ ## Do Not
57
+
58
+ - Do not use `$kkt-run` as a substitute for modeling.
59
+ - Do not execute an incomplete or blocked model workspace.
60
+ - Do not continue past a blocking judge result.
61
+ - Do not create loop tasks or rely on `events.jsonl`; use `$kkt-loop` for continuation.
62
+ - Do not silently change the selected model during implementation.
@@ -0,0 +1,53 @@
1
+ # Discovery Tooling
2
+
3
+ Use this during discovery to prove repo facts accurately with direct agent tool calls.
4
+
5
+ ## Rule
6
+
7
+ Use the lightest reliable tool that can prove the needed fact. Start with `rg` for broad text/file discovery, then use `ast-grep` for structural questions. Prefer exact, inspectable evidence over broad inference. Record important negative searches when they shape the model.
8
+
9
+ Discovery tools are read-only during planning and modeling. Rewrite, update, or codegen modes belong to approved execution.
10
+
11
+ Do not route discovery through `kkt` CLI commands. The CLI owns deterministic workflow state; the agent owns repo inspection.
12
+
13
+ ## Tool Ladder
14
+
15
+ - Core: `git` for repository boundary, tracked files, status, diffs, history, and changed-path scope.
16
+ - Core: `rg` for strings, filenames, config keys, docs, tests, shell scripts, and negative searches.
17
+ - Core structural: `ast-grep` for syntax-aware search when call sites, imports, handlers, declarations, components, error handling, or API shapes matter.
18
+ - Optional: `fd`, `ctags`, `tokei`, `scc`, and repo-native commands when they add confidence.
19
+ - Language-native: `go list`, `go test`, `cargo metadata`, `npm` scripts, `tsc`, `pytest --collect-only`, Gradle, Maven, Rails, Django, or equivalent repo tooling.
20
+
21
+ ## Selection Rules
22
+
23
+ - Use `git ls-files` or `rg --files` before broad recursive scans.
24
+ - Use `rg` for text and file discovery.
25
+ - Use `ast-grep` when syntax matters and text evidence would be noisy or ambiguous.
26
+ - Use language-native tooling for package boundaries, route maps, type contracts, test commands, or generated-code boundaries.
27
+ - If `ast-grep` is unavailable, record the setup gap and fall back only as far as the evidence supports. Do not claim AST-level certainty from text search alone.
28
+
29
+ ## Ast-Grep Policy
30
+
31
+ Allowed during discovery:
32
+
33
+ ```text
34
+ ast-grep --pattern '<pattern>' --lang <language>
35
+ ast-grep --pattern '<pattern>' --lang <language> --json
36
+ ast-grep scan --config sgconfig.yml --json
37
+ ```
38
+
39
+ Forbidden during planning or modeling:
40
+
41
+ ```text
42
+ ast-grep --rewrite ...
43
+ ast-grep scan --update-all
44
+ ast-grep scan --interactive
45
+ ```
46
+
47
+ Rewrites require the execution layer, approval, and normal KKT guardrails.
48
+
49
+ ## Guardrails
50
+
51
+ - Do not add a KKT discovery command as a substitute for direct `rg` and `ast-grep` use.
52
+ - Do not claim structural certainty from plain text search when AST search or language-native tools are needed and available.
53
+ - Do not use generated, vendored, or build-output files as primary evidence unless the task explicitly targets them.