abelworkflow 1.1.3 → 1.2.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 (98) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -29
  3. package/extensions/gpt-responses-compat.ts +213 -0
  4. package/extensions/k2think-compat.ts +40 -0
  5. package/lib/cli/args.mjs +5 -19
  6. package/lib/cli/main.mjs +105 -72
  7. package/lib/cli/prompts.mjs +9 -2
  8. package/lib/config/dotenv.mjs +1 -1
  9. package/lib/config/jsonc.mjs +1 -1
  10. package/lib/config/store.mjs +197 -45
  11. package/lib/config/toml.mjs +147 -453
  12. package/lib/installer/assets.mjs +67 -45
  13. package/lib/installer/install.mjs +202 -45
  14. package/lib/installer/links.mjs +124 -101
  15. package/lib/installer/lock.mjs +82 -0
  16. package/lib/installer/state.mjs +14 -21
  17. package/lib/paths.mjs +9 -9
  18. package/lib/providers/claude.mjs +58 -114
  19. package/lib/providers/codex.mjs +101 -198
  20. package/lib/providers/pi.mjs +331 -496
  21. package/lib/providers/skills.mjs +88 -68
  22. package/lib/providers/url.mjs +35 -0
  23. package/lib/templates/workflow/commands/abel-design.md +23 -161
  24. package/lib/templates/workflow/commands/abel-diagnose.md +30 -56
  25. package/lib/templates/workflow/commands/abel-implement.md +30 -150
  26. package/lib/templates/workflow/commands/abel-init.md +1 -1
  27. package/lib/tools/cli-installer.mjs +29 -190
  28. package/package.json +7 -9
  29. package/skills/context7-auto-research/context7-api.cjs +75 -17
  30. package/skills/dev-browser/SKILL.md +15 -1
  31. package/skills/dev-browser/dist/scripts/start.d.ts +0 -1
  32. package/skills/dev-browser/dist/scripts/start.js +8 -36
  33. package/skills/dev-browser/dist/src/client.d.ts +3 -4
  34. package/skills/dev-browser/dist/src/client.js +117 -117
  35. package/skills/dev-browser/dist/src/entrypoint.d.ts +1 -1
  36. package/skills/dev-browser/dist/src/entrypoint.js +38 -31
  37. package/skills/dev-browser/dist/src/index.d.ts +0 -1
  38. package/skills/dev-browser/dist/src/index.js +0 -1
  39. package/skills/dev-browser/dist/src/page-api.d.ts +0 -1
  40. package/skills/dev-browser/dist/src/page-api.js +0 -1
  41. package/skills/dev-browser/dist/src/relay.d.ts +0 -1
  42. package/skills/dev-browser/dist/src/relay.js +53 -7
  43. package/skills/dev-browser/dist/src/runtime.d.ts +3 -14
  44. package/skills/dev-browser/dist/src/runtime.js +5 -15
  45. package/skills/dev-browser/dist/src/snapshot/browser-script.d.ts +0 -1
  46. package/skills/dev-browser/dist/src/snapshot/browser-script.js +0 -1
  47. package/skills/dev-browser/dist/src/snapshot/index.d.ts +0 -1
  48. package/skills/dev-browser/dist/src/snapshot/index.js +0 -1
  49. package/skills/dev-browser/dist/src/snapshot/inject.d.ts +0 -1
  50. package/skills/dev-browser/dist/src/snapshot/inject.js +0 -1
  51. package/skills/dev-browser/dist/src/standalone.d.ts +0 -1
  52. package/skills/dev-browser/dist/src/standalone.js +2 -3
  53. package/skills/dev-browser/dist/src/startup.d.ts +3 -12
  54. package/skills/dev-browser/dist/src/startup.js +6 -10
  55. package/skills/dev-browser/dist/src/target-registry.d.ts +0 -1
  56. package/skills/dev-browser/dist/src/target-registry.js +0 -1
  57. package/skills/dev-browser/dist/src/types.d.ts +0 -1
  58. package/skills/dev-browser/dist/src/types.js +0 -1
  59. package/skills/dev-browser/package-lock.json +1 -1
  60. package/skills/dev-browser/package.json +2 -2
  61. package/skills/grok-search/.env.example +1 -1
  62. package/skills/grok-search/SKILL.md +13 -16
  63. package/skills/grok-search/scripts/_dotenv.py +1 -1
  64. package/skills/grok-search/scripts/groksearch_cli.py +271 -195
  65. package/skills/time/SKILL.md +5 -2
  66. package/skills/time/scripts/time_cli.py +61 -22
  67. package/extensions/pi-gpt-responses-compat/index.ts +0 -25
  68. package/lib/templates/codex/config-base.toml +0 -103
  69. package/skills/dev-browser/dist/scripts/start.d.ts.map +0 -1
  70. package/skills/dev-browser/dist/scripts/start.js.map +0 -1
  71. package/skills/dev-browser/dist/src/client.d.ts.map +0 -1
  72. package/skills/dev-browser/dist/src/client.js.map +0 -1
  73. package/skills/dev-browser/dist/src/entrypoint.d.ts.map +0 -1
  74. package/skills/dev-browser/dist/src/entrypoint.js.map +0 -1
  75. package/skills/dev-browser/dist/src/index.d.ts.map +0 -1
  76. package/skills/dev-browser/dist/src/index.js.map +0 -1
  77. package/skills/dev-browser/dist/src/page-api.d.ts.map +0 -1
  78. package/skills/dev-browser/dist/src/page-api.js.map +0 -1
  79. package/skills/dev-browser/dist/src/relay.d.ts.map +0 -1
  80. package/skills/dev-browser/dist/src/relay.js.map +0 -1
  81. package/skills/dev-browser/dist/src/runtime.d.ts.map +0 -1
  82. package/skills/dev-browser/dist/src/runtime.js.map +0 -1
  83. package/skills/dev-browser/dist/src/snapshot/browser-script.d.ts.map +0 -1
  84. package/skills/dev-browser/dist/src/snapshot/browser-script.js.map +0 -1
  85. package/skills/dev-browser/dist/src/snapshot/index.d.ts.map +0 -1
  86. package/skills/dev-browser/dist/src/snapshot/index.js.map +0 -1
  87. package/skills/dev-browser/dist/src/snapshot/inject.d.ts.map +0 -1
  88. package/skills/dev-browser/dist/src/snapshot/inject.js.map +0 -1
  89. package/skills/dev-browser/dist/src/standalone.d.ts.map +0 -1
  90. package/skills/dev-browser/dist/src/standalone.js.map +0 -1
  91. package/skills/dev-browser/dist/src/startup.d.ts.map +0 -1
  92. package/skills/dev-browser/dist/src/startup.js.map +0 -1
  93. package/skills/dev-browser/dist/src/target-registry.d.ts.map +0 -1
  94. package/skills/dev-browser/dist/src/target-registry.js.map +0 -1
  95. package/skills/dev-browser/dist/src/types.d.ts.map +0 -1
  96. package/skills/dev-browser/dist/src/types.js.map +0 -1
  97. package/skills/grok-search/gitignore.template +0 -4
  98. package/skills/grok-search/scripts/groksearch_entry.py +0 -131
@@ -3,100 +3,120 @@ import { join } from "node:path";
3
3
  import * as p from "@clack/prompts";
4
4
  import { readDotenvFile, updateDotenvFile } from "../config/store.mjs";
5
5
  import { pathToLabel } from "../paths.mjs";
6
+ import { normalizeHttpBaseUrl } from "./url.mjs";
6
7
 
7
8
  const grokDefaults = Object.freeze(JSON.parse(readFileSync(
8
9
  new URL("../../skills/grok-search/defaults.json", import.meta.url),
9
10
  "utf8"
10
11
  )));
11
12
 
12
- function readSkillEnvFile(path) {
13
- return readDotenvFile(path, { sensitive: true });
13
+ function readSkillEnvFile(path, safeRoot) {
14
+ return readDotenvFile(path, { safeRoot, sensitive: true });
14
15
  }
15
16
 
16
- async function updateSkillEnvFile(path, updates) {
17
- return updateDotenvFile(path, updates, { sensitive: true });
17
+ async function updateSkillEnvFile(path, updates, safeRoot) {
18
+ return updateDotenvFile(path, updates, { safeRoot, sensitive: true });
18
19
  }
19
20
 
20
- async function configureGrokSearchEnv(paths, ensureSkillPresent = async () => {}, promptApi) {
21
+ function validateHttpBaseUrl(value) {
22
+ try {
23
+ normalizeHttpBaseUrl(value);
24
+ } catch (error) {
25
+ return error.message;
26
+ }
27
+ }
28
+
29
+ async function configureGrokSearchEnv(paths, withSkillPresent, promptApi, runtime = {}) {
21
30
  const {
22
31
  assertNotCancelled,
23
32
  confirmOrCancel,
24
33
  passwordOrExisting,
25
34
  required
26
35
  } = promptApi;
27
- await ensureSkillPresent(paths);
28
- const envPath = join(paths.agentsDir, "skills", "grok-search", ".env");
29
- const existing = await readSkillEnvFile(envPath);
30
- const baseUrl = await p.text({
31
- message: "Grok API URL",
32
- initialValue: existing.GROK_API_URL || "https://api.x.ai/v1",
33
- validate: required()
34
- });
35
- assertNotCancelled(baseUrl);
36
+ const text = runtime.text ?? p.text;
37
+ const log = runtime.log ?? p.log;
38
+ return withSkillPresent(paths, async (guard) => {
39
+ await guard();
40
+ const envPath = join(paths.agentsDir, "skills", "grok-search", ".env");
41
+ const existing = await readSkillEnvFile(envPath, paths.agentsDir);
42
+ const baseUrlInput = await text({
43
+ message: "Grok API URL",
44
+ initialValue: existing.GROK_API_URL || "https://api.x.ai/v1",
45
+ validate: validateHttpBaseUrl
46
+ });
47
+ assertNotCancelled(baseUrlInput);
48
+ const baseUrl = normalizeHttpBaseUrl(baseUrlInput);
36
49
 
37
- const finalApiKey = await passwordOrExisting({
38
- message: "Grok API Key",
39
- existingValue: existing.GROK_API_KEY,
40
- requiredMessage: "Grok API Key 不能为空"
41
- });
50
+ const finalApiKey = await passwordOrExisting({
51
+ message: "Grok API Key",
52
+ existingValue: existing.GROK_API_KEY,
53
+ requiredMessage: "Grok API Key 不能为空"
54
+ });
42
55
 
43
- const model = await p.text({
44
- message: "Grok 默认模型",
45
- initialValue: existing.GROK_MODEL || grokDefaults.model,
46
- validate: required()
47
- });
48
- assertNotCancelled(model);
56
+ const model = await text({
57
+ message: "Grok 默认模型",
58
+ initialValue: existing.GROK_MODEL || grokDefaults.model,
59
+ validate: required()
60
+ });
61
+ assertNotCancelled(model);
49
62
 
50
- const useTavily = await confirmOrCancel({
51
- message: "是否同时配置 Tavily 作为额外搜索源?",
52
- initialValue: Boolean(existing.TAVILY_API_KEY)
53
- });
63
+ const useTavily = await confirmOrCancel({
64
+ message: "是否同时配置 Tavily 作为额外搜索源?",
65
+ initialValue: Boolean(existing.TAVILY_API_KEY)
66
+ });
54
67
 
55
- const tavilyUrl = useTavily
56
- ? await p.text({
57
- message: "Tavily API URL",
58
- initialValue: existing.TAVILY_API_URL || "https://api.tavily.com",
59
- validate: required()
60
- })
61
- : null;
62
- if (useTavily) assertNotCancelled(tavilyUrl);
63
-
64
- const finalTavilyKey = useTavily
65
- ? await passwordOrExisting({
66
- message: "Tavily API Key",
67
- existingValue: existing.TAVILY_API_KEY,
68
- requiredMessage: "Tavily API Key 不能为空"
69
- })
70
- : null;
71
-
72
- await updateSkillEnvFile(envPath, {
73
- GROK_API_URL: baseUrl,
74
- GROK_API_KEY: finalApiKey,
75
- GROK_MODEL: model,
76
- TAVILY_API_URL: tavilyUrl,
77
- TAVILY_API_KEY: finalTavilyKey,
78
- TAVILY_ENABLED: useTavily ? "true" : null
79
- });
68
+ const tavilyUrl = useTavily
69
+ ? await text({
70
+ message: "Tavily API URL",
71
+ initialValue: existing.TAVILY_API_URL || "https://api.tavily.com",
72
+ validate: validateHttpBaseUrl
73
+ })
74
+ : null;
75
+ if (useTavily) assertNotCancelled(tavilyUrl);
76
+ const normalizedTavilyUrl = useTavily ? normalizeHttpBaseUrl(tavilyUrl) : null;
80
77
 
81
- p.log.step(`已写入 ${pathToLabel(envPath)}`);
78
+ const finalTavilyKey = useTavily
79
+ ? await passwordOrExisting({
80
+ message: "Tavily API Key",
81
+ existingValue: existing.TAVILY_API_KEY,
82
+ requiredMessage: "Tavily API Key 不能为空"
83
+ })
84
+ : null;
85
+
86
+ await guard();
87
+ await updateSkillEnvFile(envPath, {
88
+ GROK_API_URL: baseUrl,
89
+ GROK_API_KEY: finalApiKey,
90
+ GROK_MODEL: String(model).trim(),
91
+ TAVILY_API_URL: normalizedTavilyUrl,
92
+ TAVILY_API_KEY: finalTavilyKey,
93
+ TAVILY_ENABLED: useTavily ? "true" : null
94
+ }, paths.agentsDir);
95
+
96
+ log.step(`已写入 ${pathToLabel(envPath)}`);
97
+ });
82
98
  }
83
99
 
84
- async function configureContext7Env(paths, ensureSkillPresent = async () => {}, promptApi) {
100
+ async function configureContext7Env(paths, withSkillPresent, promptApi, runtime = {}) {
85
101
  const { passwordOrExisting } = promptApi;
86
- await ensureSkillPresent(paths);
87
- const envPath = join(paths.agentsDir, "skills", "context7-auto-research", ".env");
88
- const existing = await readSkillEnvFile(envPath);
89
- const finalApiKey = await passwordOrExisting({
90
- message: "Context7 API Key(可选)",
91
- existingValue: existing.CONTEXT7_API_KEY,
92
- requiredMessage: null
93
- });
102
+ const log = runtime.log ?? p.log;
103
+ return withSkillPresent(paths, async (guard) => {
104
+ await guard();
105
+ const envPath = join(paths.agentsDir, "skills", "context7-auto-research", ".env");
106
+ const existing = await readSkillEnvFile(envPath, paths.agentsDir);
107
+ const finalApiKey = await passwordOrExisting({
108
+ message: "Context7 API Key(可选)",
109
+ existingValue: existing.CONTEXT7_API_KEY,
110
+ requiredMessage: null
111
+ });
94
112
 
95
- await updateSkillEnvFile(envPath, {
96
- CONTEXT7_API_KEY: finalApiKey
97
- });
113
+ await guard();
114
+ await updateSkillEnvFile(envPath, {
115
+ CONTEXT7_API_KEY: finalApiKey
116
+ }, paths.agentsDir);
98
117
 
99
- p.log.step(`已写入 ${pathToLabel(envPath)}`);
118
+ log.step(`已写入 ${pathToLabel(envPath)}`);
119
+ });
100
120
  }
101
121
 
102
122
  export {
@@ -0,0 +1,35 @@
1
+ const invalidBaseUrlMessage = "Base URL 必须是无凭据的有效绝对 HTTP(S) URL";
2
+
3
+ function parseHttpBaseUrl(value) {
4
+ const input = String(value || "").trim();
5
+ if (!/^https?:\/\/\S+$/iu.test(input)) throw new TypeError(invalidBaseUrlMessage);
6
+
7
+ let url;
8
+ try {
9
+ url = new URL(input);
10
+ } catch {
11
+ throw new TypeError(invalidBaseUrlMessage);
12
+ }
13
+ if (!url.hostname
14
+ || (url.protocol !== "http:" && url.protocol !== "https:")
15
+ || url.username
16
+ || url.password) {
17
+ throw new TypeError(invalidBaseUrlMessage);
18
+ }
19
+ return { input, url };
20
+ }
21
+
22
+ function normalizeHttpBaseUrl(value) {
23
+ return parseHttpBaseUrl(value).input;
24
+ }
25
+
26
+ function normalizeOpenAiBaseUrl(value) {
27
+ const { url } = parseHttpBaseUrl(value);
28
+ let pathname = url.pathname.replace(/\/+$/u, "")
29
+ .replace(/\/v1\/(?:chat\/completions|responses)$/u, "/v1");
30
+ if (!pathname.endsWith("/v1")) pathname = `${pathname}/v1`;
31
+ url.pathname = pathname;
32
+ return url.toString();
33
+ }
34
+
35
+ export { normalizeHttpBaseUrl, normalizeOpenAiBaseUrl };
@@ -1,175 +1,37 @@
1
1
  ---
2
2
  name: abel-design
3
- description: Transform requirements into implementation-ready, traceable specs via gated clarification.
3
+ description: Transform requirements into implementation-ready OpenSpec artifacts.
4
4
  category: abel
5
- tags: [abel, design, constraints, PBT, subagents]
5
+ tags: [abel, design, openspec]
6
6
  argument-hint: [requirement | --change <change_name>]
7
7
  ---
8
8
 
9
9
  <!-- ABEL:START -->
10
+ # abel-design
10
11
 
11
- # abel-design Gated Design Mode (Specs Only, No Implementation)
12
+ Turn a requirement into a validated, traceable OpenSpec change. This command is design only; do not implement product code.
12
13
 
13
- ## Non-Negotiable Rules (Highest Priority)
14
- 1. DESIGN MODE ONLY — you MUST NOT generate implementation code.
15
- 2. WRITE SCOPE:
16
- - Before Gate A: strictly read-only; persist nothing.
17
- - After Gate A: write ONLY inside the resolved `changeRoot`. Create only ready artifacts; edit a done artifact only when an approved loop-back/consistency repair explicitly targets it.
18
- 3. NEVER assume or guess — every blocking decision goes to the user (see Decision Model).
19
- 4. Final output: a schema-valid, fully traceable OpenSpec change with BLOCKING_DECISIONS = 0, READY_TO_IMPLEMENT.
14
+ ## Rules
20
15
 
21
- **Skill Integration**: See `Stage Skill Matrix` (Design column)
16
+ - Follow the repository instructions and the Design column of its Stage Skill Matrix.
17
+ - Before any write, state assumptions and unknowns explicitly. If a critical unknown could change scope, behavior, architecture, data handling, security, or an irreversible action, stop and ask the user.
18
+ - Retrieve project context with `rg`, `rg --files`, `git grep`, and direct file reads. Use only project evidence and research sources allowed by the repository instructions.
19
+ - Use unified diff patches for proposed and applied changes. Write only inside the resolved OpenSpec `changeRoot`.
20
+ - Do not create runtime approval or resume state.
22
21
 
23
- ---
24
-
25
- ## Decision Model
26
- - Maintain an in-session Decision Ledger with: `id`, `class`, `question`, `evidence`, `options`, `recommendation`, `resolution`, `status`, `affected_artifacts`.
27
- - `BLOCKING_DECISIONS` is the count of unresolved, non-mechanical decisions in that ledger.
28
- - Behavior decisions answer WHAT: observable outcomes, scope/non-goals, scenarios, failure behavior, data/security/privacy/compatibility policies and success criteria.
29
- - Technical decisions answer HOW: interfaces, data flow, dependencies, storage/algorithms, implementation error mechanisms and key technical parameters.
30
- - MUST be approved by the user: goal, scope, non-goals and observable success behavior; data, security, privacy, compatibility and migration rules; new dependencies, cross-module architecture, irreversible changes; any technical choice with substantive trade-offs, including key parameters.
31
- - MAY be decided mechanically by the agent: naming, file locations and local structure uniquely determined by existing repo conventions; easily reversible details with no external behavior change; test placement and execution order derived directly from the approved design.
32
- - Record mechanical decisions and never re-ask them. Two or more viable options with substantive differences → escalate to a blocking decision.
33
- - Do NOT create a runtime ledger or approval-state file. Materialize approved decisions only in schema artifacts.
34
-
35
- ## Phase 0 — Entry, Mode & Readiness (read-only)
36
- - Verify an initialized OpenSpec root and the required CLI capabilities: `new change`, `list --json`, `schemas --json`, `schema which --json`, `schema validate --json`, `templates --json`, `status --json`, `instructions --json`, and `validate --strict`. If unavailable, STOP with actionable `/abel-init` remediation; do not initialize or update from this command.
37
- - Resolve mode:
38
- - Explicit `--change <name>` → Resume. If that change does not exist, STOP and ask the user to correct the name or choose New mode.
39
- - Otherwise, an exact existing-change match → Resume.
40
- - Otherwise → New mode; do not silently interpret an explicit/resume-like typo as a requirement.
41
- - Resolve the effective schema by precedence: explicit schema choice, existing change metadata, project config, then `spec-driven`; verify it appears in `openspec schemas --json`.
42
- - Before creating a change, run `openspec schema which <schema> --json` and `openspec schema validate <schema> --json`, inspect its definition and `openspec templates --schema <schema> --json`, and perform a preliminary behavior/technical/mixed dependency check. Implementation compatibility also requires a non-empty concrete `apply.tracks` that matches exactly one artifact's `generates`. An incompatible schema must fail closed before creation.
43
- - New mode minimum intake before ANY exploration:
44
- - Problem/goal statement, AND
45
- - Scope anchor (which module/directory is involved).
46
- - If either intake item is missing, ask the user concisely before proceeding.
47
- - Generate a provisional kebab-case change name and check `openspec list --changes --json`. Recompute and confirm it from the final Gate A scope before creation. Persist nothing yet.
48
-
49
- ## Phase 1 — Evidence Exploration (read-only)
50
- - Use local codebase retrieval with `rg`, `rg --files`, `git grep`, and direct file reads.
51
- - Single context boundary → main agent explores directly.
52
- - Multiple independent context boundaries, when the platform permits → dispatch parallel Explore subagents:
53
- - Divide by context boundary (NOT functional role); each boundary self-contained.
54
- - Each subagent receives: mandatory use of the codebase retrieval policy, a clear scope, and the mandatory JSON output schema:
55
- {
56
- "module_name": "所探索的上下文边界",
57
- "existing_structures": ["关键结构/模式"],
58
- "existing_conventions": ["约定/标准"],
59
- "constraints_discovered": ["硬约束"],
60
- "open_questions": ["需用户输入的歧义"],
61
- "dependencies": ["跨模块依赖"],
62
- "risks": ["风险/阻碍"],
63
- "success_criteria_hints": ["可观察的成功行为"]
64
- }
65
- - Validate every subagent JSON before aggregation; aggregate constraints, dependencies, risks, conflicts and questions into the Decision Ledger.
66
- - Audit existing codebase patterns:
67
- Use `rg`, `rg --files`, `git grep`, and direct file reads to validate against existing codebase patterns.
68
- - On-demand /context7-auto-research: verify candidate libraries/APIs against official contracts.
69
- - On-demand /grok-search: architectural patterns and best practices for candidate directions.
70
- - PBT boundary screening: probe empty input, idempotency, ordering, size/value bounds, state-transition legality → feed the question list for Phase 2.
71
- - Reference: Inspect codebase structure with `rg --files`, `git grep`, and direct file reads.
72
-
73
- ## Phase 2 — Behavior Clarification Loop (multiple rounds allowed)
74
- - Cover WHAT only: goal, scope, non-goals, observable scenarios/success criteria, failure behavior, and data/security/privacy/compatibility policies.
75
- - Do not choose libraries, protocols, algorithms, storage, topology or implementation parameters in this phase; route them to Phase 4.
76
- - Each round asks ONLY the current highest-impact blocking questions, grouped concisely, each with evidence, impact and a recommended default.
77
- - Anti-patterns (flag and reject):
78
- - Observable behavior deferred to implementation ("error behavior decided while coding")
79
- - Technical mechanisms smuggled in as product requirements
80
- - Target behavior patterns:
81
- - "Lock the account for 30 minutes after 5 consecutive failed logins."
82
- - "Retain audit records for 30 days and never expose secrets in responses."
83
- - "For an empty query, return an empty result within the approved latency bound."
84
- - An answer that widens modules, scenarios or data boundaries → return to Phase 1 for INCREMENTAL exploration only.
85
- - Loop until unresolved behavior decisions = 0.
86
-
87
- ## ⛔ Gate A — Approve Behavior Contract
88
- - Present the behavior contract and affected Decision Ledger entries; the user explicitly approves goal, scope/non-goals, scenarios/success criteria and policies.
89
- - Recompute the change name from the approved scope and recheck duplicates.
90
- - New mode: ONLY NOW create the change with `openspec new change <change-name>` (add `--schema <schema>` only for an explicit non-default choice).
91
- - Build the Artifact Plan, then materialize only behavior-class artifacts that are safe and ready.
92
-
93
- ## Artifact Plan & Write Protocol
94
- - Before New-mode creation, build a preliminary compatibility map from the resolved schema definition/templates. After creation or in Resume mode, build the final Artifact Plan from `status --json` and available `instructions --json`. Record the schema's `apply.tracks`; for every artifact record capture id/output paths, dependencies/status, substantive decision class (`behavior|technical|mixed`), write Gate, and affected decisions. Mechanical impact information alone does not make an artifact mixed.
95
- - Classify by the decisions the artifact carries, never by a hardcoded artifact name:
96
- - behavior → Gate A
97
- - technical or mixed → Gate B
98
- - behavior depending on a Gate B artifact → defer until after Gate B and then follow the DAG
99
- - If the schema requires a write before Gate A, a write outside `changeRoot`, or an unapproved technical decision to unlock behavior, STOP before New-mode creation and ask the user to select a compatible schema/mapping. Schema order never overrides decision approval.
100
- - Mandatory loop for EVERY artifact write:
101
- 1. Run `openspec status --change <change-name> --json`; verify `schemaName`, `changeRoot`, `artifactPaths`, status/dependencies and `applyRequires`. `existingOutputPaths` may be empty and is not a new-file target.
102
- 2. Run `openspec instructions <artifact-id> --change <change-name> --json`; follow its template/rules/dependencies.
103
- 3. Read dependencies and existing outputs; check consistency in both directions.
104
- 4. Prepare content in memory and show the decision summary or unified diff before the corresponding Gate. If materialization reveals a new substantive decision, return to the relevant loop and re-approve it.
105
- 5. After Gate approval, create exactly one ready artifact, or edit one done artifact explicitly targeted by an approved loop-back/consistency repair. Rerun status after every write and process newly unlocked artifacts topologically.
106
-
107
- ## Phase 3 — Technical Derivation
108
- - Derive the technical design from the Gate A contract, existing codebase patterns and official API contracts.
109
- - Mechanical decisions → record directly in the design. Substantive trade-offs → Phase 4.
110
-
111
- ## Phase 4 — Technical Decision & Verification Loop
112
- - Cover HOW: interfaces, data flow, implementation error mechanisms, dependencies/algorithms and key parameters. Examples include JWT vs session design and an approved bcrypt cost factor.
113
- - Apply the same evidence/options/recommendation format to every substantive technical decision; update the Decision Ledger.
114
- - PBT applicability rule (screen with the six categories: commutativity/associativity, idempotency, round-trip, invariant preservation, monotonicity, bounds):
115
- - Behavior with invariants, round-trips, idempotency, ordering, bounds or state transitions → MUST extract a property + falsification strategy.
116
- - Behavior unsuited to PBT → use example/E2E/static verification and record why PBT does not apply. Do NOT force every requirement through every category.
117
- - Give every scenario a stable reference: `<spec-path>#<requirement-heading>/<scenario-heading>` and require those headings to be unique within the spec; maintain Requirement → Scenario → Verification → Task.
118
- - Every task has exactly one schema checkbox and a verification contract using ordinary indented bullets, NEVER nested `- [ ]`/`- [x]` lines:
119
- - Task ID / dependencies
120
- - Requirement + stable Scenario reference
121
- - Verification type: property | example | E2E | static
122
- - Red command + expected failure reason
123
- - Green expected behavior
124
- - Affected-suite verification command
125
- - Target scope/files
126
- - For a non-behavior-change task, the Red command is a pre-change executable static verification. Manual-only verification is not implementation-ready and MUST NOT pass Gate B or Exit; reshape the task until it has executable property/example/E2E/static verification.
127
- - Loop until unresolved technical decisions = 0; prepare proposed remaining artifact contents/unified diffs in memory.
128
-
129
- ## ⛔ Gate B — Approve Implementation Contract
130
- - Verify Phase 3/4 faithfully expand the Gate A contract; no unapproved new decisions introduced.
131
- - Present substantive technical decisions, task/verification mapping and artifact materialization preview.
132
- - The user explicitly approves that implementation contract.
133
- - Write the remaining ready artifacts one at a time per the Artifact Plan & Write Protocol.
134
-
135
- ## Loop-Back Rules
136
- - A user answer widens modules, scenarios or data boundaries → return to Phase 1.
137
- - Technical analysis overturns the behavior contract → return to Phase 2; re-approve ONLY the affected decisions and synchronize all affected artifacts.
138
- - Gate B finds the materialization unfaithful → return to Phase 3/4; unaffected Gate A decisions remain approved.
139
- - Strict validation, verification-contract or traceability failure → return to the earliest phase that introduced the inconsistency.
140
- - Never hide a late-discovered blocking question.
141
-
142
- ## Resume Rules
143
- - Never infer user approval from artifact existence: `status` reporting `done` proves file completion only, not Gate approval.
144
- - Never resume by fixed file names or file existence alone; the active schema decides.
145
- - Algorithm:
146
- 1. Run `openspec status --change <change-name> --json`.
147
- 2. Use its `schemaName`, `changeRoot`, `artifactPaths` and statuses; read all `existingOutputPaths` and dependencies.
148
- 3. Check `openspec validate <change-name> --strict --type change`, template completeness, cross-artifact consistency, traceability and verification contracts.
149
- 4. Rebuild Gate A/B summaries and the Artifact Plan. Re-confirm every Gate approval that cannot be proven in the current conversation.
150
- 5. Choose the next step:
151
- - Explicit Resume change not found (`change_error`) → STOP for spelling/New-mode confirmation; never create silently.
152
- - Artifacts incomplete → repair/confirm the nearest safe Gate, then handle the artifacts the schema reports ready.
153
- - Artifacts complete but validation/traceability fails → earliest inconsistent phase.
154
- - Every artifact id listed in `applyRequires` is `done` → re-confirm any unproven Gate, then run the Exit audit.
155
- - Only in-session, un-persisted analysis exists → no mid-loop resume; re-run the read-only analysis.
156
- - Do NOT create runtime approval-state files; re-confirming the Gate summary IS the resume mechanism.
22
+ ## Process
157
23
 
158
- ## Exit Criteria
159
- - [ ] `openspec validate <change-name> --strict --type change` returns zero issues
160
- - [ ] Every artifact id in `applyRequires` has status `done`
161
- - [ ] Schema `apply.tracks` resolves to the generated task artifact inside `changeRoot`
162
- - [ ] Artifacts are consistent and traceable; every task has a valid verification contract
163
- - [ ] Every task has executable property/example/E2E/static verification; no task is manual-only
164
- - [ ] BLOCKING_DECISIONS = 0
165
- - [ ] User has explicitly approved the reconstructed/current Gate A and Gate B summaries in this conversation
166
- - [ ] Status: READY_TO_IMPLEMENT
24
+ 1. Resolve the input as a new requirement or an explicit `--change <change-name>`. Never silently create a mistyped explicit change.
25
+ 2. Verify the OpenSpec project and CLI. Use `openspec context --json`, `openspec list --changes --json`, and `openspec schemas --json`; direct missing setup to `/abel-init`.
26
+ 3. Resolve the schema from the existing change, explicit choice, project configuration, or the OpenSpec default. Inspect it with `openspec schema which <schema> --json`, `openspec schema validate <schema> --json`, and `openspec templates --schema <schema> --json`.
27
+ 4. Confirm the schema exposes a concrete `apply.tracks` path generated by one artifact. For an existing change, read `schemaName`, `changeRoot`, `artifactPaths`, `applyRequires`, and artifact states from `openspec status --change <change-name> --json`.
28
+ 5. Explore the affected code and nearby tests. Summarize current behavior, constraints, dependencies, risks, assumptions, and unknowns with file evidence.
29
+ 6. Clarify the smallest set of unresolved behavior and technical decisions. Ask only questions whose answers materially affect the design, and include evidence, impact, options, and a recommended default.
30
+ 7. Define scope, non-goals, observable scenarios, failure behavior, data/security/privacy effects, interfaces, dependencies, and verification. Keep the Requirement → Scenario → Verification → Task chain explicit.
31
+ 8. For a new change, choose a kebab-case name, check for conflicts, show the planned artifact changes as a unified diff, then run `openspec new change <change-name>`; add `--schema <schema>` only for an explicit non-default choice.
32
+ 9. Materialize artifacts in schema dependency order. Before each artifact, run `openspec status --change <change-name> --json` and `openspec instructions <artifact-id> --change <change-name> --json`, read its dependencies and existing output, then apply the smallest consistent patch.
33
+ 10. Give each implementation task its target files, dependencies, requirement/scenario reference, Red command and expected failure, minimal Green behavior, and affected/final verification commands.
34
+ 11. Run `openspec validate <change-name> --strict --type change`. Finish only when validation passes, every `applyRequires` artifact is done, `apply.tracks` resolves inside `changeRoot`, artifacts agree, and no critical unknown remains.
167
35
 
168
- ## Reference
169
- - `openspec context --json` / `openspec schemas --json`
170
- - `openspec view` / `openspec list --changes --json` / `openspec list --specs` (conflicts with existing specs)
171
- - `openspec status --change <change-name> --json` / `openspec instructions <artifact-id> --change <change-name> --json`
172
- - `openspec new change <change-name>` (Gate A only)
173
- - `openspec show <change-name> --json --deltas-only` when validation fails
174
- - `rg -n "Constraint:|MUST|MUST NOT|INVARIANT:|PROPERTY:" openspec/` before defining new ones
36
+ Report the change name, decisions made, artifacts changed, validation evidence, and any non-blocking residual risks.
175
37
  <!-- ABEL:END -->
@@ -1,63 +1,37 @@
1
1
  ---
2
2
  name: abel-diagnose
3
- description: Parallel diagnosis with batch fix reporting via systematic root cause analysis.
3
+ description: Diagnose bugs from evidence and apply minimal regression-tested fixes.
4
4
  category: abel
5
- tags: [abel, diagnosis, bugfix]
5
+ tags: [abel, diagnosis, bugfix, TDD]
6
6
  argument-hint: <problem-description>
7
7
  ---
8
+
8
9
  <!-- ABEL:START -->
9
- **Arguments**
10
- - Required: `<problem-description>` (one or more bug descriptions; comma-separated supported)
11
-
12
- **Guardrails**
13
- - Root cause first; never fix symptoms only
14
- - Verify root cause hypothesis with evidence before fix
15
- - Only fixes with evidence-verified root cause may be applied
16
- - Every fix must include a regression test
17
- - Keep changes minimal and scoped
18
- - If verification fails, rollback and iterate
19
-
20
- **Execution Model**
21
- - Run detection and root-cause analysis for all issues in parallel
22
- - Infer scope automatically from problem text, traces, and retrieved code context
23
- - Build dependency/conflict order before any fix application
24
- - Same file: force sequential fix order; same symbol: merge when compatible, otherwise sequential
25
- - Independent scopes: parallel-safe
26
- - Fix generation for READY issues runs fully in parallel via subagents with forked/minimal context; main agent only aggregates and resolves conflicts
27
- - Patch application and final verification must run strictly sequential by dependency order
28
- - Always output one consolidated batch report
29
-
30
- **Skill Integration**: See `Stage Skill Matrix` (Diagnose column)
31
-
32
- **Steps**
33
- 1. Parse input, infer scope, and split into issue list (single or multiple).
34
- 2. For each issue in parallel: collect logs/traces and locate code via the configured codebase retrieval policy.
35
- 3. For each issue in parallel: perform root cause analysis; for multi-component chains, decompose the failure chain step by step with evidence.
36
- 4. Build dependency/conflict graph across issues and compute safe fix order.
37
- 5. Verify each issue's root cause against collected evidence; only issues with a verified root cause can move to fix generation.
38
- 6. Spawn one subagent per READY issue to generate `unified diff patch` and regression test with minimal scoped context.
39
- 7. Main agent reviews/merges subagent outputs by dependency order and outputs one batch report with all issue statuses and patches.
40
- 8. Apply merged patches strictly sequentially by dependency order.
41
- 9. Run final verification strictly sequentially by the same dependency order and output verification matrix.
42
-
43
- **Batch Output**
44
- ```text
45
- ## /abel-diagnose Batch Report
46
-
47
- ### Batch Summary
48
- Total: {n} | ReadyToFix: {n_ready} | Blocked: {n_blocked}
49
-
50
- ### Issue Results
51
- - [{id}] Classification: {category}/{severity} | Root Cause: {summary} | Verified: {yes|no} | Subagent: {agent_id|none} | Status: {READY|BLOCKED}
52
-
53
- ### Patch Queue (dependency order)
54
- 1. [{id}] [subagent:{agent_id}] {file_list}
55
- {unified_diff_patch}
56
-
57
- ### Verification Matrix
58
- - [{id}] Regression: {passed|failed} | Affected Suite: {passed|failed}
59
-
60
- ### Final Status
61
- {FIXED|PARTIAL|NEEDS_REVIEW|BLOCKED}
62
- ```
10
+ # abel-diagnose
11
+
12
+ Find the verified root cause of the reported problem, then fix it with a regression test and minimal patch.
13
+
14
+ ## Rules
15
+
16
+ - Follow the repository instructions and the Diagnose column of its Stage Skill Matrix.
17
+ - State assumptions and unknowns before any write. If a critical unknown prevents reliable reproduction, changes fix scope, or affects safety, stop and ask the user.
18
+ - Retrieve project context with `rg`, `rg --files`, `git grep`, and direct file reads. Use logs, traces, tests, and project evidence before forming conclusions.
19
+ - Do not apply a fix until evidence supports the root cause. Do not broaden scope to speculative cleanup.
20
+ - Use unified diff patches for every change.
21
+
22
+ ## Process
23
+
24
+ 1. Restate the observed failure and expected behavior. Identify the smallest affected boundary and relevant verification command.
25
+ 2. Reproduce the problem when safe. Record the command, environment facts, output, and failure identity. If it cannot be reproduced, distinguish missing evidence from disproven hypotheses.
26
+ 3. Trace the failing path through callers, state transitions, data boundaries, and nearby tests. Compare working and failing cases.
27
+ 4. Form the smallest falsifiable root-cause hypothesis and test it against the evidence. For multiple issues, identify dependencies or file conflicts before editing.
28
+ 5. Red: add or update a focused regression test and run it before the fix; require failure for the verified root cause. If no meaningful executable regression is possible, state why and stop for direction.
29
+ 6. Green: apply the smallest fix and rerun the regression test. Preserve unrelated behavior and user-owned state.
30
+ 7. Refactor only if needed for clarity, keeping the regression and affected tests green.
31
+
32
+ ## Final Verification
33
+
34
+ - Run the regression test, affected suite, and any proportionate broader suite.
35
+ - Review the complete diff for scope, side effects, security, secrets, and runtime state accidentally added to the repository.
36
+ - Report the verified root cause with evidence, modified files, Red/Green results, final verification commands, and residual risks or unresolved issues.
63
37
  <!-- ABEL:END -->