@ai-content-space/loopx 0.1.0 → 0.1.1

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 (43) hide show
  1. package/README.md +26 -26
  2. package/package.json +6 -2
  3. package/plugins/loopx/.codex-plugin/plugin.json +6 -6
  4. package/plugins/loopx/scripts/plugin-install.test.mjs +25 -8
  5. package/plugins/loopx/skills/autopilot/SKILL.md +90 -0
  6. package/plugins/loopx/skills/build/SKILL.md +118 -0
  7. package/plugins/loopx/skills/clarify/SKILL.md +219 -0
  8. package/plugins/loopx/skills/plan/SKILL.md +238 -0
  9. package/plugins/loopx/skills/{loopx-review → review}/SKILL.md +9 -4
  10. package/skills/ai-slop-cleaner/SKILL.md +114 -0
  11. package/skills/autopilot/SKILL.md +90 -0
  12. package/skills/autoresearch/SKILL.md +68 -0
  13. package/skills/build/SKILL.md +118 -0
  14. package/skills/clarify/SKILL.md +219 -0
  15. package/skills/deep-interview/SKILL.md +461 -0
  16. package/skills/deepsearch/SKILL.md +38 -0
  17. package/skills/plan/SKILL.md +238 -0
  18. package/skills/ralph/SKILL.md +271 -0
  19. package/skills/ralplan/SKILL.md +49 -0
  20. package/skills/{loopx-review → review}/SKILL.md +9 -4
  21. package/src/autopilot-runtime.mjs +152 -0
  22. package/src/build-runtime.mjs +146 -0
  23. package/src/cli.mjs +43 -7
  24. package/src/codex-exec-runtime.mjs +97 -0
  25. package/src/install-discovery.mjs +7 -7
  26. package/src/plan-runtime.mjs +456 -0
  27. package/src/runtime-maintenance.mjs +36 -8
  28. package/src/workflow.mjs +825 -123
  29. package/templates/architecture.md +3 -3
  30. package/templates/development-plan.md +1 -1
  31. package/templates/execution-record.md +1 -1
  32. package/templates/plan.md +4 -4
  33. package/templates/review-report.md +1 -1
  34. package/templates/spec.md +38 -2
  35. package/templates/test-plan.md +1 -1
  36. package/plugins/loopx/skills/loopx-autopilot/SKILL.md +0 -30
  37. package/plugins/loopx/skills/loopx-build/SKILL.md +0 -25
  38. package/plugins/loopx/skills/loopx-clarify/SKILL.md +0 -25
  39. package/plugins/loopx/skills/loopx-plan/SKILL.md +0 -25
  40. package/skills/loopx-autopilot/SKILL.md +0 -30
  41. package/skills/loopx-build/SKILL.md +0 -25
  42. package/skills/loopx-clarify/SKILL.md +0 -25
  43. package/skills/loopx-plan/SKILL.md +0 -25
package/README.md CHANGED
@@ -1,25 +1,25 @@
1
- # LoopX
1
+ # loopx
2
2
 
3
- `LoopX` is a skill-first workflow product for Codex. It supports two first-class distribution shells:
3
+ `loopx` is a skill-first workflow product for Codex. It supports two first-class distribution shells:
4
4
 
5
5
  - npm/global install
6
6
  - Codex plugin install
7
7
 
8
- Both shells converge on one shared LoopX core and one visible LoopX skill set.
8
+ Both shells converge on one shared loopx core and one visible loopx skill set.
9
9
 
10
10
  ## Release Contract
11
11
 
12
- The active LoopX release flow is:
12
+ The active loopx release flow is:
13
13
 
14
14
  `clarify -> plan -> build -> review`
15
15
 
16
16
  Bundled skill surfaces:
17
17
 
18
- - `loopx-clarify`
19
- - `loopx-plan`
20
- - `loopx-build`
21
- - `loopx-review`
22
- - `loopx-autopilot`
18
+ - `clarify`
19
+ - `plan`
20
+ - `build`
21
+ - `review`
22
+ - `autopilot`
23
23
 
24
24
  There is no public `team` surface in this release.
25
25
 
@@ -27,25 +27,25 @@ There is no public `team` surface in this release.
27
27
 
28
28
  - skill-first for normal use
29
29
  - retained CLI/runtime/debug substrate for maintenance and inspection
30
- - explicit local artifacts and state under `.LoopX/`
30
+ - explicit local artifacts and state under `.loopx/`
31
31
  - bounded migration from legacy `.codex-helper/`
32
32
 
33
33
  ## Runtime Namespace
34
34
 
35
- LoopX user-facing runtime state is stored under:
35
+ loopx user-facing runtime state is stored under:
36
36
 
37
37
  ```text
38
- .LoopX/
38
+ .loopx/
39
39
  ```
40
40
 
41
41
  Key subtrees:
42
42
 
43
- - `.LoopX/specs/`
44
- - `.LoopX/plans/`
45
- - `.LoopX/workflows/<slug>/`
46
- - `.LoopX/autopilot/<slug>/`
43
+ - `.loopx/specs/`
44
+ - `.loopx/plans/`
45
+ - `.loopx/workflows/<slug>/`
46
+ - `.loopx/autopilot/<slug>/`
47
47
 
48
- The `.omx/` tree remains orchestration/planning metadata and is not part of the LoopX runtime rename.
48
+ The `.omx/` tree remains orchestration/planning metadata and is not part of the loopx runtime rename.
49
49
 
50
50
  ## CLI Surface
51
51
 
@@ -65,11 +65,11 @@ loopx migrate
65
65
  loopx repair-install
66
66
  ```
67
67
 
68
- The CLI is supporting runtime/debug tooling. The intended user-facing product surface is the bundled LoopX skills.
68
+ The CLI is supporting runtime/debug tooling. The intended user-facing product surface is the bundled loopx skills.
69
69
 
70
70
  ## Install and Discovery
71
71
 
72
- LoopX supports two install paths that both reuse the same shared install/discovery core:
72
+ loopx supports two install paths that both reuse the same shared install/discovery core:
73
73
 
74
74
  - npm/global install:
75
75
  - `npm install -g @ai-content-space/loopx`
@@ -79,24 +79,24 @@ LoopX supports two install paths that both reuse the same shared install/discove
79
79
 
80
80
  Bootstrap behavior:
81
81
 
82
- - materializes LoopX-owned skills under `~/.agents/skills/`
83
- - updates LoopX-owned `local` rows in `~/.agents/.skill-lock.json`
82
+ - materializes loopx-owned skills under `~/.agents/skills/`
83
+ - updates loopx-owned `local` rows in `~/.agents/.skill-lock.json`
84
84
  - keeps install idempotent
85
85
  - supports repair through `loopx repair-install`
86
86
  - converges npm and plugin installs onto one `installationIdentity=loopx`
87
87
 
88
88
  Discovery is valid only when both are true:
89
89
 
90
- - the installed LoopX skill directory exists
91
- - the matching LoopX-owned registry row exists
90
+ - the installed loopx skill directory exists
91
+ - the matching loopx-owned registry row exists
92
92
 
93
- If both npm and plugin installs are present, Codex should still expose one LoopX skill set rather than duplicates.
93
+ If both npm and plugin installs are present, Codex should still expose one loopx skill set rather than duplicates.
94
94
 
95
95
  ## Legacy Migration
96
96
 
97
97
  - legacy `.codex-helper/` runtime state is migrated through `loopx migrate`
98
- - mixed `.LoopX/` and `.codex-helper/` roots are treated as a repairable error
99
- - public docs, package, CLI, and skill names use `LoopX`
98
+ - mixed `.loopx/` and `.codex-helper/` roots are treated as a repairable error
99
+ - public docs, package, CLI, and skill names use `loopx`
100
100
 
101
101
  ## Verification
102
102
 
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@ai-content-space/loopx",
3
3
  "type": "module",
4
- "version": "0.1.0",
5
- "description": "Skill-first LoopX workflow product for Codex",
4
+ "version": "0.1.1",
5
+ "description": "Skill-first loopx workflow product for Codex",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/hugh-zhan9/loopx.git"
9
+ },
6
10
  "keywords": [
7
11
  "codex",
8
12
  "loopx",
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "loopx",
3
- "version": "0.1.0",
4
- "description": "Skill-first LoopX workflow product for Codex",
3
+ "version": "0.1.1",
4
+ "description": "Skill-first loopx workflow product for Codex",
5
5
  "skills": "./skills/",
6
6
  "interface": {
7
- "displayName": "LoopX",
8
- "shortDescription": "Thin plugin shell for the LoopX skill bundle.",
9
- "longDescription": "This plugin mirrors the canonical LoopX skills and routes plugin installs through the shared LoopX install/discovery core. It stays plugin-root-relative at the manifest boundary and does not define a second LoopX implementation.",
10
- "developerName": "LoopX",
7
+ "displayName": "loopx",
8
+ "shortDescription": "Thin plugin shell for the loopx skill bundle.",
9
+ "longDescription": "This plugin mirrors the canonical loopx skills and routes plugin installs through the shared loopx install/discovery core. It stays plugin-root-relative at the manifest boundary and does not define a second loopx implementation.",
10
+ "developerName": "loopx",
11
11
  "category": "Developer Tools"
12
12
  }
13
13
  }
@@ -17,12 +17,13 @@ const MANIFEST_PATH = join(PLUGIN_ROOT, '.codex-plugin', 'plugin.json');
17
17
  const INSTALL_SCRIPT = join(MODULE_DIR, 'plugin-install.mjs');
18
18
  const ROOT_SKILLS_DIR = join(REPO_ROOT, 'skills');
19
19
  const PLUGIN_SKILLS_DIR = join(PLUGIN_ROOT, 'skills');
20
+ const RALPLAN_SKILL_PATH = join(ROOT_SKILLS_DIR, 'ralplan', 'SKILL.md');
20
21
  const LOOPX_SKILLS = [
21
- 'loopx-clarify',
22
- 'loopx-plan',
23
- 'loopx-build',
24
- 'loopx-review',
25
- 'loopx-autopilot',
22
+ 'clarify',
23
+ 'plan',
24
+ 'build',
25
+ 'review',
26
+ 'autopilot',
26
27
  ];
27
28
 
28
29
  function loopxEnv(home) {
@@ -38,7 +39,7 @@ function loopxEnv(home) {
38
39
  };
39
40
  }
40
41
 
41
- describe('LoopX plugin shell', () => {
42
+ describe('loopx plugin shell', () => {
42
43
  it('defines a plugin manifest that only references plugin-root-relative assets', async () => {
43
44
  const manifest = JSON.parse(await readFile(MANIFEST_PATH, 'utf8'));
44
45
  const packageJson = JSON.parse(await readFile(join(REPO_ROOT, 'package.json'), 'utf8'));
@@ -48,7 +49,7 @@ describe('LoopX plugin shell', () => {
48
49
  assert.equal(manifest.name, 'loopx');
49
50
  assert.equal(manifest.version, packageJson.version);
50
51
  assert.equal(manifest.skills, './skills/');
51
- assert.equal(manifest.interface.displayName, 'LoopX');
52
+ assert.equal(manifest.interface.displayName, 'loopx');
52
53
 
53
54
  for (const key of ['skills', 'mcpServers', 'apps']) {
54
55
  if (typeof manifest[key] === 'string') {
@@ -57,14 +58,30 @@ describe('LoopX plugin shell', () => {
57
58
  }
58
59
  });
59
60
 
60
- it('mirrors the canonical LoopX skill payload into the plugin shell', async () => {
61
+ it('mirrors the canonical loopx skill payload into the plugin shell', async () => {
61
62
  for (const skillName of LOOPX_SKILLS) {
62
63
  const rootSkill = await readFile(join(ROOT_SKILLS_DIR, skillName, 'SKILL.md'), 'utf8');
63
64
  const pluginSkill = await readFile(join(PLUGIN_SKILLS_DIR, skillName, 'SKILL.md'), 'utf8');
65
+ assert.equal(rootSkill.startsWith('---\n'), true, `${skillName} root skill must start with YAML frontmatter`);
66
+ assert.equal(pluginSkill.startsWith('---\n'), true, `${skillName} plugin skill must start with YAML frontmatter`);
64
67
  assert.equal(pluginSkill, rootSkill, skillName);
65
68
  }
66
69
  });
67
70
 
71
+ it('locks plan as the canonical consensus-first planning contract', async () => {
72
+ const planSkill = await readFile(join(ROOT_SKILLS_DIR, 'plan', 'SKILL.md'), 'utf8');
73
+ const pluginPlanSkill = await readFile(join(PLUGIN_SKILLS_DIR, 'plan', 'SKILL.md'), 'utf8');
74
+ const ralplanSkill = await readFile(RALPLAN_SKILL_PATH, 'utf8');
75
+
76
+ assert.match(planSkill, /consensus-first/i);
77
+ assert.match(planSkill, /Planner -> Architect -> Critic/);
78
+ assert.match(planSkill, /Critic verdict is `approve`/);
79
+ assert.match(planSkill, /Default planning is consensus-first/);
80
+ assert.equal(pluginPlanSkill, planSkill);
81
+ assert.equal(ralplanSkill.includes('compatibility alias for `$plan`'), true);
82
+ assert.equal(ralplanSkill.includes('$plan --consensus'), false);
83
+ });
84
+
68
85
  it('reuses the shared install core while materializing skills from the plugin shell', async () => {
69
86
  const home = await mkdtemp(join(tmpdir(), 'loopx-plugin-home-'));
70
87
  const env = loopxEnv(home);
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: autopilot
3
+ description: Richer internal-phase loopx autonomous orchestration over the public clarify/plan/build/review flow.
4
+ argument-hint: "<workflow slug>"
5
+ ---
6
+
7
+ # loopx Autopilot
8
+
9
+ <Purpose>
10
+ `autopilot` is loopx's autonomous orchestration surface. It upgrades the current bounded composition model by adding richer internal phases while keeping loopx's public stage model authoritative.
11
+
12
+ Externally, the user still reasons about:
13
+
14
+ - `clarify`
15
+ - `plan`
16
+ - `build`
17
+ - `review`
18
+
19
+ Internally, `autopilot` may orchestrate richer phases such as expansion, planning, execution, QA, and validation.
20
+ </Purpose>
21
+
22
+ <Use_When>
23
+ - One owner wants loopx to run end-to-end with internal autonomous orchestration.
24
+ - A clarified or workflow-local spec already exists, or the workflow is ready to begin from loopx stages.
25
+ - The task benefits from richer internal planning/execution/QA/validation behavior without exposing a more complex public stage surface.
26
+ </Use_When>
27
+
28
+ <Do_Not_Use_When>
29
+ - The user wants manual control over each stage gate.
30
+ - The task should stop after planning or execution rather than run end-to-end.
31
+ - Requirements are too ambiguous for bounded autonomous orchestration.
32
+ </Do_Not_Use_When>
33
+
34
+ <Core_Principles>
35
+ - loopx public stage truth remains authoritative.
36
+ - Richer internal phases are allowed, but they stay internal.
37
+ - Internal stage approvals may be auto-consumed and must be recorded as control events.
38
+ - Canonical loopx artifacts remain the source of truth; `run.json` is an orchestration ledger.
39
+ - Reuse strengthened loopx stage runtimes rather than re-implementing contradictory truths.
40
+ </Core_Principles>
41
+
42
+ <Internal_Phases>
43
+ Suggested internal phase model:
44
+
45
+ - `expansion`
46
+ - `planning`
47
+ - `execution`
48
+ - `qa`
49
+ - `validation`
50
+
51
+ Phase-to-stage alignment:
52
+
53
+ - `expansion` -> clarified-spec reuse or clarify preparation
54
+ - `planning` -> loopx `plan`
55
+ - `execution` + `qa` -> loopx `build`
56
+ - `validation` -> pre-review validation plus loopx `review`
57
+ </Internal_Phases>
58
+
59
+ <Control_Plane>
60
+ - one autopilot invocation authorizes one bounded autopilot run
61
+ - autopilot may internally consume stage approvals for:
62
+ - `clarify -> plan`
63
+ - `plan -> build`
64
+ - `build -> review`
65
+ - `review -> done`
66
+ - these decisions must be recorded as internal control events
67
+ </Control_Plane>
68
+
69
+ <Artifact_Contract>
70
+ Canonical stage artifacts remain authoritative:
71
+
72
+ - clarify spec artifacts
73
+ - `.loopx/plans/prd-<slug>.md`
74
+ - `.loopx/plans/test-spec-<slug>.md`
75
+ - canonical build `execution-record.md`
76
+ - canonical review `review-report.md`
77
+
78
+ Autopilot also writes an orchestration ledger:
79
+
80
+ - `.loopx/autopilot/<slug>/run.json`
81
+
82
+ `run.json` may include internal phase progression, blockers, and control events, but it must not replace canonical stage artifacts as the source of truth.
83
+ </Artifact_Contract>
84
+
85
+ <Must_Not_Decide_Automatically>
86
+ - do not create a new public stage family
87
+ - do not bypass loopx canonical artifacts
88
+ - do not fork a second workflow truth that contradicts loopx stages
89
+ - do not literally port the parent autopilot where it conflicts with loopx runtime contracts
90
+ </Must_Not_Decide_Automatically>
@@ -0,0 +1,118 @@
1
+ ---
2
+ name: build
3
+ description: Ralph-style loopx execution runtime under the public build stage.
4
+ argument-hint: "[--no-deslop] <approved workflow slug>"
5
+ ---
6
+
7
+ # loopx Build
8
+
9
+ <Purpose>
10
+ `build` is loopx's canonical execution lane. It executes an approved plan with Ralph-style rigor while keeping the public loopx stage surface unchanged.
11
+
12
+ By default, `build` is not a one-shot draft writer. It is a persistence loop with internal parallel lanes, fresh verification, architect gating, deslop, and regression re-verification before `review` can start.
13
+ </Purpose>
14
+
15
+ <Use_When>
16
+ - `plan -> build` has already been explicitly approved.
17
+ - Canonical plan artifacts already exist and execution should now proceed.
18
+ - The task needs execution persistence, verification evidence, and explicit pre-review quality gates.
19
+ </Use_When>
20
+
21
+ <Do_Not_Use_When>
22
+ - Requirements or planning are still incomplete.
23
+ - The user wants to skip execution and only review or inspect the plan.
24
+ - A valid build run is already review-ready and the next action is `review`.
25
+ </Do_Not_Use_When>
26
+
27
+ <Core_Principles>
28
+ - Public surface stays `build`; internal strength can still match Ralph-style execution.
29
+ - Execution may parallelize internally without exposing a public `team` stage.
30
+ - `build` does not replace `review`.
31
+ - `execution-record.md` remains the sole canonical execution and verification artifact.
32
+ - Fresh evidence is required before review handoff.
33
+ - Deslop and regression re-verification are part of the default build path.
34
+ </Core_Principles>
35
+
36
+ <Preconditions>
37
+ `build` starts only when all of the following are true:
38
+
39
+ - approved `plan -> build` transition exists
40
+ - `.loopx/plans/prd-<slug>.md` exists
41
+ - `.loopx/plans/test-spec-<slug>.md` exists
42
+ - workflow-local planning artifacts required by the execution lane exist
43
+ </Preconditions>
44
+
45
+ <Execution_Model>
46
+ `build` should behave like a Ralph-style execution runtime:
47
+
48
+ 1. Initialize or resume build iteration state.
49
+ 2. Run internal execution / evidence / verification lanes in parallel.
50
+ 3. Aggregate lane results into canonical `execution-record.md`.
51
+ 4. Run fresh verification and read actual output.
52
+ 5. Run architect verification as a hard pre-review gate.
53
+ 6. Run deslop on build-owned changes.
54
+ 7. Re-run regression verification after deslop.
55
+ 8. Stop only when review handoff gates are satisfied or a real blocker remains.
56
+
57
+ `build` may persist support artifacts for runtime inspection, but they must not replace `execution-record.md`.
58
+ </Execution_Model>
59
+
60
+ <Runtime_State_Machine>
61
+ `build` should track at minimum:
62
+
63
+ - `build_run_id`
64
+ - `build_current_iteration`
65
+ - `build_max_iterations` (default `10`)
66
+ - `build_parallel_mode`
67
+ - `build_lane_statuses`
68
+ - `build_verification_status`
69
+ - `build_architect_verification_status`
70
+ - `build_deslop_status`
71
+ - `build_regression_status`
72
+ - `build_blockers`
73
+ - `build_progress_artifact_paths`
74
+ - `build_support_evidence_paths`
75
+ - `execution_record_status`
76
+
77
+ `build -> review` is blocked until:
78
+
79
+ - all internal lanes are complete
80
+ - fresh verification passes
81
+ - architect verification is approved
82
+ - deslop is complete, unless explicitly skipped
83
+ - post-deslop regression passes
84
+ - `execution-record.md` is complete
85
+ </Runtime_State_Machine>
86
+
87
+ <Artifact_Contract>
88
+ Canonical artifact:
89
+
90
+ - `execution-record.md`
91
+
92
+ Support artifacts may exist for:
93
+
94
+ - iteration progress
95
+ - lane evidence summaries
96
+ - architect gate summaries
97
+ - deslop summaries
98
+ - regression summaries
99
+
100
+ These support artifacts are runtime aids only. They must not become new canonical review inputs.
101
+ </Artifact_Contract>
102
+
103
+ <Review_Boundary>
104
+ - build-internal architect verification is an execution-quality gate
105
+ - review remains the final independent stage
106
+ - review continues to own provenance checks, evidence completeness checks, completion/rollback decisions, and code-review
107
+ </Review_Boundary>
108
+
109
+ <Flags>
110
+ - `--no-deslop`: skip the deslop pass and the post-deslop regression loop, while still requiring the latest successful pre-deslop verification evidence
111
+ </Flags>
112
+
113
+ <Must_Not_Decide_Automatically>
114
+ - do not self-approve review
115
+ - do not mark the workflow complete
116
+ - do not replace `execution-record.md` with support artifacts
117
+ - do not widen execution into public `team`, `ultrawork`, or `ralph` command surfaces
118
+ </Must_Not_Decide_Automatically>
@@ -0,0 +1,219 @@
1
+ ---
2
+ name: clarify
3
+ description: Comprehensive loopx clarify skill for requirements, boundaries, and design-ready specs.
4
+ ---
5
+
6
+ # loopx Clarify
7
+
8
+ <Purpose>
9
+ `clarify` is loopx's full pre-implementation clarification skill. It combines:
10
+
11
+ - the Socratic pressure and ambiguity control of `deep-interview`
12
+ - the design-shaping discipline of `brainstorming`
13
+
14
+ Its job is not just to ask questions. Its job is to turn a vague or overloaded request into a written clarify spec that is:
15
+
16
+ - explicit about intent
17
+ - explicit about non-goals and decision boundaries
18
+ - concrete enough to hand to `plan`
19
+ - structured enough that downstream execution does not re-discover the task from scratch
20
+ </Purpose>
21
+
22
+ <Use_When>
23
+ - The request is broad, ambiguous, or mixes problem, solution, and implementation detail.
24
+ - The user needs help defining scope, non-goals, acceptance criteria, or tradeoffs before planning.
25
+ - A design direction exists only implicitly and would otherwise be invented during implementation.
26
+ - The task will later be handed to `plan`, `build`, or `autopilot`, and you want a high-signal spec first.
27
+ </Use_When>
28
+
29
+ <Do_Not_Use_When>
30
+ - The task already has concrete file/symbol targets and clear acceptance criteria.
31
+ - A complete and approved spec/plan already exists for the same task.
32
+ - The user explicitly asks to skip clarification and execute immediately.
33
+ </Do_Not_Use_When>
34
+
35
+ <Why_This_Exists>
36
+ Most implementation drift happens before coding begins. Teams often think they need “more planning,” when the real problem is weaker intent clarity, hidden assumptions, fuzzy boundaries, or a design shape that was never made explicit. `clarify` exists to solve those upstream failures before `plan` or `build` magnifies them.
37
+ </Why_This_Exists>
38
+
39
+ <Core_Principles>
40
+ - Ask one question at a time.
41
+ - Prefer the highest-leverage unresolved question, not broad coverage.
42
+ - Keep digging on the same thread until one assumption, one boundary, or one tradeoff becomes clearer.
43
+ - Treat every answer as a claim to pressure-test, not a final truth to copy down.
44
+ - Make `Non-goals` and `Decision Boundaries` mandatory gates.
45
+ - Do not stop at “requirements”; shape the solution enough that the next stage has a coherent starting design.
46
+ </Core_Principles>
47
+
48
+ <Profiles>
49
+ - **Standard (`--standard`, default)**:
50
+ - default loopx clarify mode
51
+ - target threshold: `<= 0.20`
52
+ - max rounds: `15`
53
+ - **Deep (`--deep`)**:
54
+ - higher-rigor clarify mode with heavier pressure-testing and design shaping
55
+ - target threshold: `<= 0.10`
56
+ - max rounds: `25`
57
+
58
+ If no flag is provided, use **Standard**.
59
+ </Profiles>
60
+
61
+ <Runtime_State_Machine>
62
+ `clarify` must maintain these runtime fields in `.loopx/workflows/<slug>/state.json` and mirror them in the clarify spec frontmatter:
63
+
64
+ - `clarify_current_round` / `current_round`: starts at `0`; increments after each user-answer round.
65
+ - `clarify_ambiguity_score` / `ambiguity_score`: starts at `1`; must be `<= clarify_target_ambiguity_threshold` before handoff.
66
+ - `clarify_non_goals_resolved` / `non_goals_resolved`: `true` only after non-goals are explicit.
67
+ - `clarify_decision_boundaries_resolved` / `decision_boundaries_resolved`: `true` only after human-vs-agent decision boundaries are explicit.
68
+ - `clarify_pressure_pass_complete` / `pressure_pass_complete`: `true` only after at least one prior answer has been revisited with explicit pressure.
69
+
70
+ The `clarify -> plan` gate is blocked until all of the following are true:
71
+
72
+ - `unresolved_ambiguity_count` is `0`
73
+ - `clarify_current_round` is between `1` and `clarify_max_rounds`
74
+ - `clarify_ambiguity_score` is at or below the selected profile threshold
75
+ - non-goals are resolved
76
+ - decision boundaries are resolved
77
+ - pressure pass is complete
78
+
79
+ Do not mark a clarify spec handoff-ready by prose alone. Update the frontmatter fields so the runtime can enforce the same readiness decision.
80
+ </Runtime_State_Machine>
81
+
82
+ <Execution_Policy>
83
+ - Explore repo context before asking the user about internals.
84
+ - Prefer evidence-backed clarification in brownfield work:
85
+ - “I found X in Y. Should this clarify spec preserve that pattern?”
86
+ - Ask about intent and boundaries before implementation detail.
87
+ - Stay on the same thread when the answer is still weak instead of rotating dimensions just for coverage.
88
+ - Revisit at least one earlier answer with an explicit assumption, evidence, or tradeoff follow-up before crystallizing.
89
+ - If the task is too large for one coherent spec, decompose it before pretending it is ready.
90
+ - Keep user effort low: do not ask for facts that can be discovered directly.
91
+ </Execution_Policy>
92
+
93
+ <Dimensions>
94
+ - **Intent**: why the user wants this
95
+ - **Outcome**: what end state they actually want
96
+ - **Scope**: how far the change should go
97
+ - **Constraints**: what must remain true
98
+ - **Success Criteria**: how completion will be judged
99
+ - **Context**: how this fits the existing codebase (brownfield only)
100
+ </Dimensions>
101
+
102
+ <Pressure_Patterns>
103
+ When an answer is still weak, prefer one of these next:
104
+
105
+ 1. Ask for a concrete example or counterexample.
106
+ 2. Expose the hidden assumption that makes the answer true.
107
+ 3. Force a boundary:
108
+ - what should not happen
109
+ - what should be deferred
110
+ - what should be rejected
111
+ 4. If the answer is still describing symptoms, reframe toward root cause.
112
+ </Pressure_Patterns>
113
+
114
+ <Design_Shaping>
115
+ `clarify` should not stop at “what do you want?” Once the intent is understandable, it should also shape the task enough that the downstream plan is not starting from zero.
116
+
117
+ When there is a real design choice:
118
+
119
+ - propose 2-3 viable approaches
120
+ - lead with the recommended one
121
+ - explain tradeoffs briefly
122
+ - right-size the design to the task
123
+
124
+ The goal is not to produce a full architecture doc here. The goal is to make the clarify spec design-ready.
125
+ </Design_Shaping>
126
+
127
+ <Process>
128
+
129
+ ## 1. Explore Context
130
+
131
+ - Read relevant files, docs, and current patterns first.
132
+ - Classify the work as brownfield or greenfield.
133
+ - For brownfield work, collect concrete evidence before questioning.
134
+
135
+ ## 2. Interview
136
+
137
+ - Ask one question per round.
138
+ - After each answered round, update `current_round`, the ambiguity register, and `ambiguity_score`.
139
+ - Target the weakest unresolved dimension.
140
+ - Keep `Non-goals` and `Decision Boundaries` explicit from early in the process.
141
+ - Respect the selected profile:
142
+ - `standard`: stop only when the clarify spec is handoff-ready or `15` rounds are exhausted
143
+ - `deep`: stop only when the clarify spec is handoff-ready or `25` rounds are exhausted
144
+
145
+ ## 3. Pressure-Test
146
+
147
+ - Apply explicit follow-up pressure to at least one earlier answer.
148
+ - Set `pressure_pass_complete: true` only after the pressure follow-up is answered and reflected in the spec.
149
+ - Do not crystallize while assumptions are still hidden or boundaries are still fuzzy.
150
+ - In `deep`, expect more persistence on the same thread before moving on.
151
+
152
+ ## 4. Shape the Design
153
+
154
+ - Where needed, propose a small set of options.
155
+ - Recommend one approach.
156
+ - Clarify what that approach implies for scope and downstream execution.
157
+
158
+ ## 5. Write the Clarify Spec
159
+
160
+ Write the output to the loopx runtime namespace:
161
+
162
+ - `.loopx/specs/clarify-<slug>-<timestamp>.md`
163
+
164
+ The clarify spec should include:
165
+
166
+ - metadata
167
+ - runtime readiness frontmatter:
168
+ - `current_round`
169
+ - `ambiguity_score`
170
+ - `non_goals_resolved`
171
+ - `decision_boundaries_resolved`
172
+ - `pressure_pass_complete`
173
+ - `unresolved_ambiguity_count`
174
+ - intent
175
+ - desired outcome
176
+ - in-scope
177
+ - out-of-scope / non-goals
178
+ - decision boundaries
179
+ - constraints
180
+ - success criteria
181
+ - assumptions exposed and resolved
182
+ - brownfield evidence vs inference
183
+ - design direction / preferred approach
184
+ - explicit next handoff recommendation
185
+
186
+ ## 6. Handoff
187
+
188
+ After the clarify spec is ready:
189
+
190
+ - hand off to `plan` by default
191
+ - hand off to `build` only if the user explicitly wants direct execution and the task is already concrete enough
192
+ - hand off to `autopilot` only when the scope is sufficiently tight for a bounded end-to-end run
193
+
194
+ `clarify` itself does not implement the feature.
195
+
196
+ </Process>
197
+
198
+ <Readiness_Gates>
199
+ - `Non-goals` are explicit
200
+ - `Decision Boundaries` are explicit
201
+ - At least one pressure-pass follow-up has revisited an earlier answer
202
+ - A written clarify spec exists
203
+ - The task is small enough and clear enough for real downstream handoff
204
+ - The selected profile threshold is met:
205
+ - `standard`: weighted ambiguity `<= 0.20`
206
+ - `deep`: weighted ambiguity `<= 0.10`
207
+ </Readiness_Gates>
208
+
209
+ <Must_Not_Decide_Automatically>
210
+ - approval to move from clarify into plan
211
+ - implementation details that were never clarified or grounded
212
+ - widening the task because a broader redesign sounds cleaner
213
+ </Must_Not_Decide_Automatically>
214
+
215
+ <Output_Contract>
216
+ - primary artifact: a loopx clarify spec
217
+ - secondary artifact: an explicit ambiguity register and next-step recommendation
218
+ - preferred handoff: `plan`
219
+ </Output_Contract>