@williambeto/ai-workflow 2.2.7 → 2.3.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 (68) hide show
  1. package/AGENTS.md +27 -0
  2. package/CHANGELOG.md +34 -0
  3. package/dist-assets/agents/astra.md +74 -45
  4. package/dist-assets/agents/atlas.md +110 -152
  5. package/dist-assets/agents/nexus.md +64 -19
  6. package/dist-assets/agents/orion.md +72 -27
  7. package/dist-assets/agents/phoenix.md +64 -19
  8. package/dist-assets/agents/sage.md +67 -36
  9. package/dist-assets/commands/atlas.md +66 -6
  10. package/dist-assets/commands/audit.md +62 -4
  11. package/dist-assets/commands/deploy.md +66 -5
  12. package/dist-assets/commands/discover.md +72 -4
  13. package/dist-assets/commands/implement.md +66 -18
  14. package/dist-assets/commands/optimize-tokens.md +60 -4
  15. package/dist-assets/commands/plan.md +64 -4
  16. package/dist-assets/commands/release.md +76 -5
  17. package/dist-assets/commands/run.md +62 -16
  18. package/dist-assets/commands/spec-create.md +66 -4
  19. package/dist-assets/commands/spec-implement.md +68 -4
  20. package/dist-assets/commands/spec-review.md +63 -4
  21. package/dist-assets/commands/update-memory.md +62 -4
  22. package/dist-assets/commands/validate.md +70 -6
  23. package/dist-assets/docs/cli-reference.md +38 -10
  24. package/dist-assets/skills/architecture/SKILL.md +62 -7
  25. package/dist-assets/skills/backend-development/SKILL.md +62 -7
  26. package/dist-assets/skills/deployment/SKILL.md +62 -7
  27. package/dist-assets/skills/design-principles/SKILL.md +59 -7
  28. package/dist-assets/skills/documentation/SKILL.md +61 -7
  29. package/dist-assets/skills/frontend-development/SKILL.md +62 -7
  30. package/dist-assets/skills/full-stack-development/SKILL.md +62 -7
  31. package/dist-assets/skills/optimize-tokens/SKILL.md +61 -7
  32. package/dist-assets/skills/pr-workflow/SKILL.md +65 -7
  33. package/dist-assets/skills/product-discovery/SKILL.md +81 -7
  34. package/dist-assets/skills/product-planning/SKILL.md +62 -7
  35. package/dist-assets/skills/project-memory/SKILL.md +55 -22
  36. package/dist-assets/skills/prompt-engineer/SKILL.md +59 -7
  37. package/dist-assets/skills/qa-workflow/SKILL.md +72 -7
  38. package/dist-assets/skills/refactoring/SKILL.md +68 -7
  39. package/dist-assets/skills/release-workflow/SKILL.md +72 -7
  40. package/dist-assets/skills/spec-driven-development/SKILL.md +75 -7
  41. package/dist-assets/skills/technical-leadership/SKILL.md +61 -7
  42. package/dist-assets/skills/ui-ux-design/SKILL.md +60 -7
  43. package/docs/compatibility/provider-usage.md +46 -0
  44. package/docs/compatibility/runtime-matrix.md +31 -0
  45. package/docs/getting-started/DESKTOP_PROMPT.md +52 -0
  46. package/docs/getting-started/quickstart.md +17 -0
  47. package/docs/getting-started/upgrading-to-v2.md +55 -0
  48. package/package.json +20 -4
  49. package/read_only_safety_verification.md +48 -0
  50. package/src/cli.js +4 -2
  51. package/src/commands/collect-evidence.js +3 -39
  52. package/src/commands/doctor.js +16 -0
  53. package/src/commands/execute.js +312 -119
  54. package/src/core/delegation-controller.js +193 -0
  55. package/src/core/evidence/evidence-ledger.js +53 -0
  56. package/src/core/execution-planner.js +4 -1
  57. package/src/core/finalization/finalizer.js +77 -0
  58. package/src/core/finalization/workspace-snapshot.js +110 -0
  59. package/src/core/gates/branch-gate.js +23 -35
  60. package/src/core/healing/healer-engine.js +34 -1
  61. package/src/core/healing/runtime-remediation-executor.js +136 -0
  62. package/src/core/request-classifier.js +15 -5
  63. package/src/core/request-router.js +289 -0
  64. package/src/core/runtime/opencode-adapter.js +170 -62
  65. package/src/core/validation/evidence-collector.js +26 -3
  66. package/src/core/validation/stack-detector.js +65 -0
  67. package/src/core/validation/validation-planner.js +134 -0
  68. package/src/core/workspace/read-only-workspace.js +119 -0
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@williambeto/ai-workflow",
3
- "version": "2.2.7",
3
+ "version": "2.3.1",
4
4
  "description": "AI Workflow Kit — OpenCode-first software delivery workflow with agents, commands, skills, validation, and evidence",
5
5
  "license": "MIT",
6
6
  "author": "José Willams",
7
7
  "type": "module",
8
8
  "private": false,
9
+ "publishConfig": {
10
+ "access": "public",
11
+ "registry": "https://registry.npmjs.org/"
12
+ },
9
13
  "engines": {
10
14
  "node": ">=20.11"
11
15
  },
@@ -34,7 +38,11 @@
34
38
  "PUBLISH_MANIFEST.json",
35
39
  "README.md",
36
40
  "LICENSE",
37
- "CHANGELOG.md"
41
+ "CHANGELOG.md",
42
+ "AGENTS.md",
43
+ "read_only_safety_verification.md",
44
+ "docs/getting-started",
45
+ "docs/compatibility"
38
46
  ],
39
47
  "scripts": {
40
48
  "build": "node internal/validate/build-publish.mjs",
@@ -48,18 +56,26 @@
48
56
  "validate:workflow": "node internal/validate/validate-workflow.mjs",
49
57
  "validate:schemas": "node internal/validate/validate-schemas.mjs",
50
58
  "validate:skills": "node internal/validate/validate-skills.mjs",
59
+ "validate:subagents": "node internal/validate/validate-subagents.mjs",
60
+ "validate:commands": "node internal/validate/validate-commands.mjs",
61
+ "validate:agents": "node internal/validate/validate-agents.mjs",
51
62
  "validate:policy-refs": "node internal/validate/validate-policy-refs.mjs",
52
63
  "validate:privacy-gate": "node internal/validate/validate-privacy-gate.mjs",
53
64
  "validate:ui-evidence": "node internal/validate/validate-ui-evidence-gate.mjs",
54
65
  "validate:delegation": "node internal/validate/validate-delegation.mjs",
66
+ "validate:routing": "node internal/validate/validate-routing-consistency.mjs",
55
67
  "validate:cli-smoke": "node internal/validate/validate-cli-smoke.mjs",
56
68
  "validate:cli-docs": "node internal/validate/validate-cli-docs.mjs",
57
69
  "lint:md": "markdownlint \"**/*.md\"",
58
70
  "validate:registry": "node internal/validate/validate-registry-integrity.mjs",
71
+ "clean:verify": "node -e \"const fs = require('fs'); fs.rmSync('dist', { recursive: true, force: true }); fs.readdirSync('.').filter(f => f.endsWith('.tgz')).forEach(f => fs.rmSync(f, { force: true }));\"",
59
72
  "test": "npm run test:unit",
60
- "test:unit": "vitest run",
73
+ "test:unit": "vitest run tests/unit/",
61
74
  "test:watch": "vitest",
62
- "test:e2e": "node tests/validate-e2e.mjs",
75
+ "test:e2e": "node tests/validate-e2e.mjs && vitest run tests/e2e/consumer-workflow.test.js",
76
+ "test:e2e:runtime": "AI_WORKFLOW_RELEASE=1 vitest run tests/e2e/consumer-workflow.test.js -t \"Real OpenCode Smoke Test\"",
77
+ "release:verify": "npm run clean:verify && npm test && npm run test:e2e && npm run validate && npm run pack:verify && npm run test:e2e:runtime",
78
+ "pack:verify": "node tests/e2e/verify-packed-consumer.mjs",
63
79
  "pack:safe": "node internal/validate/pack-safe.mjs",
64
80
  "validate:behavioral-contracts": "node internal/validate/validate-behavioral-contracts.mjs",
65
81
  "validate:token-economy": "node internal/validate/validate-token-economy.mjs",
@@ -0,0 +1,48 @@
1
+ # Read-Only Safety, Sage Validation, and OpenCode Retest Verification Report
2
+
3
+ This report documents the resolution of all blocking items identified to reach the `PASS — publish ready` status.
4
+
5
+ ## 1. Summary of Resolved Items
6
+
7
+ ### State Machine Transition Correction
8
+ - Updated [execute.js](src/commands/execute.js) to transition the state machine sequentially through:
9
+ `IMPLEMENTING -> IMPLEMENTED -> VALIDATING -> COMPLETED`
10
+ instead of attempting a direct jump from `IMPLEMENTING` to `COMPLETED` during read-only runs.
11
+
12
+ ### Snapshot Comparison Bug Fix
13
+ - Corrected [compareReadOnlyState](src/commands/execute.js) to compare `.snapshot.files` rather than `.snapshot` directly.
14
+ - Standardized comparisons on `.sha256` instead of `.hash`.
15
+
16
+ ### Physical File Write Prevention
17
+ - Prevented physical file creation of handoff markdown files and execution ledgers inside the repository when running under a read-only request.
18
+ - Moved the final ledger logs and handoffs into memory and routed them to `stdout`.
19
+ - Declared the block-scoped `plan` variable outside the `try` block so it is properly evaluated in the `finally` block of `runExecute` to suppress file saving.
20
+
21
+ ### E2E Test Suite Enhancements
22
+ - Added a new E2E test case `16. Read-only válido -> COMPLETED; sem mutações, nenhum handoff ou ledger gravado` inside [consumer-workflow.test.js](tests/e2e/consumer-workflow.test.js) asserting that a valid read-only execution maintains branch, HEAD, and files identically while leaving the `.ai-workflow/` history and handoff directories empty.
23
+ - Injected a local controlled OpenCode mock in [verify-packed-consumer.mjs](tests/e2e/verify-packed-consumer.mjs) before running doctor checks, removing dependencies on host/CI global executables.
24
+
25
+ ### Integration of Real OpenCode Smoke Test
26
+ - Updated `package.json` to link the real OpenCode smoke test (`test:e2e:runtime` with `AI_WORKFLOW_RELEASE=1`) directly into the final `release:verify` command.
27
+ - Verified that the smoke test runs and passes successfully on this host environment where the real `opencode` CLI is available.
28
+
29
+ ### Sage validation agent for full mode
30
+ - Modified [validate](src/core/delegation-controller.js) in the delegation controller to execute validation via the `Sage` agent when the task mode is `"full"`.
31
+ - Added unit tests in [delegation-ledger.test.js](tests/unit/delegation-ledger.test.js) to assert that Sage events (`validation_start`, `validation_complete`) are logged.
32
+ - Mocked Sage agent capabilities in the E2E framework ([fake-opencode.js](tests/e2e/helpers/fake-opencode.js)) to support a fail-once revalidation scenario.
33
+ - Created E2E test case `17. Alto risco / Full -> Astra e Sage executados; com finding, Phoenix e Sage revalidação` to prove the full multi-agent loop:
34
+ `Astra -> Sage -> Phoenix -> Sage`
35
+
36
+ ---
37
+
38
+ ## 2. Verification Evidence
39
+
40
+ All consolidated validation checks run and exit with code `0`.
41
+
42
+ | Test Run | Command | Result | Details |
43
+ | --- | --- | --- | --- |
44
+ | **Unit Tests** | `npm run test:unit` | **PASS (142/142)** | All unit tests completed successfully (including the new Sage validation event logging) |
45
+ | **E2E Tests** | `npm run test:e2e` | **PASS (18/18)** | All E2E test cases pass successfully, including the new read-only safety validation (16) and multi-agent coordination (17) |
46
+ | **All Gates** | `npm run validate` | **PASS (18/18)** | 18 validation checks completed successfully |
47
+ | **Packaging** | `npm run pack:verify` | **PASS** | Doctor and Init runs successfully verified against packed tarball |
48
+ | **Integrity** | `npm run release:verify` | **PASS (Exit 0)** | Consolidated clean, test, e2e, validate, pack:verify, and real OpenCode smoke tests |
package/src/cli.js CHANGED
@@ -74,12 +74,14 @@ export async function runCli(args) {
74
74
  const flags = parseFlags(args.slice(1));
75
75
  const positionals = args.slice(1).filter((arg) => !arg.startsWith("-"));
76
76
  const request = flags.request || positionals.join(" ");
77
- await runExecute({
77
+ const result = await runExecute({
78
78
  cwd: process.cwd(),
79
79
  naturalRequest: request,
80
- override: args.includes("--override") ? "authorized-override-token" : undefined,
81
80
  taskSlug: flags.taskSlug
82
81
  });
82
+ if (result && (result.overallStatus === "FAIL_QUALITY_GATE" || result.overallStatus === "BLOCKED" || result.overallStatus === "FAIL")) {
83
+ process.exit(1);
84
+ }
83
85
  return;
84
86
  }
85
87
 
@@ -1,50 +1,14 @@
1
1
  import { EvidenceCollector } from "../core/validation/evidence-collector.js";
2
2
  import { QualityGuard } from "../core/validation/quality-guard.js";
3
+ import { ValidationPlanner } from "../core/validation/validation-planner.js";
3
4
  import { buildDeliverySummary, formatDeliverySummary } from "../core/validation/canonical-finalization.js";
4
5
  import fs from "node:fs/promises";
5
6
  import path from "node:path";
6
7
 
7
- function isNoOpScript(script = "") {
8
- const value = String(script).trim().toLowerCase();
9
- return /^(echo\b|true$|exit\s+0$|node\s+-e\s+["']?console\.log)/.test(value) || value.includes("tests-pass");
10
- }
11
-
12
- function addScriptTask(tasks, scripts, name, command, { rejectNoOp = false } = {}) {
13
- const script = scripts[name];
14
- if (!script) return;
15
- if (!rejectNoOp && name === "test" && isNoOpScript(script)) return;
16
- if (rejectNoOp && isNoOpScript(script)) {
17
- tasks.push({ name, command, kind: name === "test" ? "test" : name, presetStatus: "FAIL_QUALITY_GATE", summary: `Configured ${name} script is a no-op: ${script}` });
18
- return;
19
- }
20
- tasks.push({ name, command, kind: name === "test" ? "test" : name });
21
- }
22
-
23
- function isManagedValidationPath(file = "") {
24
- return /(^|\/)(node_modules|vendor|dist|coverage|\.cache)(\/|$)/.test(String(file).replaceAll("\\", "/"));
25
- }
26
-
27
8
  export async function runCollectEvidence({ cwd, exitOnError = true, taskSlug = null, mode = null, dryRun = false, profile = "generic", branchRecovery = "NOT_RECORDED" }) {
28
- const tasks = [];
29
9
  const qualityGuard = new QualityGuard({ cwd, taskSlug, mode });
30
- try {
31
- const pkg = JSON.parse(await fs.readFile(path.join(cwd, "package.json"), "utf8"));
32
- const scripts = pkg.scripts || {};
33
- const executableBehavior = await qualityGuard.hasExecutableBehaviorChanges();
34
- addScriptTask(tasks, scripts, "lint", "npm run lint");
35
- addScriptTask(tasks, scripts, "test", "npm test", { rejectNoOp: executableBehavior });
36
- addScriptTask(tasks, scripts, "build", "npm run build");
37
- addScriptTask(tasks, scripts, "typecheck", "npm run typecheck");
38
- if (scripts.validate && !String(scripts.validate).includes("ai-workflow collect-evidence")) addScriptTask(tasks, scripts, "validate", "npm run validate");
39
-
40
- const changed = qualityGuard.getChangedFiles().filter((file) => !isManagedValidationPath(file));
41
- const hasTs = changed.some((file) => /\.(ts|tsx)$/.test(file)) || await fs.access(path.join(cwd, "tsconfig.json")).then(() => true).catch(() => false);
42
- if (hasTs && !scripts.typecheck) {
43
- tasks.push({ name: "typecheck", command: "npm run typecheck", kind: "typecheck", presetStatus: "FAIL_QUALITY_GATE", summary: "TypeScript detected but no typecheck script is configured." });
44
- }
45
- } catch {
46
- // Non-Node projects can still supply validation through project-specific commands.
47
- }
10
+ const planner = new ValidationPlanner({ cwd, qualityGuard });
11
+ const tasks = await planner.plan(profile);
48
12
 
49
13
  const persist = !dryRun && mode === "full";
50
14
  const collector = new EvidenceCollector({ cwd, timeout: 60000, taskSlug, mode, profile, branchRecovery });
@@ -1,6 +1,7 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { exists, readJson, readJsonc } from "../core/filesystem.js";
4
+ import { OpenCodeAdapter } from "../core/runtime/opencode-adapter.js";
4
5
 
5
6
  const REQUIRED_FILES = [
6
7
  ".ai-workflow",
@@ -23,6 +24,21 @@ export async function runDoctor({ cwd }) {
23
24
 
24
25
  console.log("Doctor report:");
25
26
 
27
+ // Check OpenCode runtime
28
+ const adapter = new OpenCodeAdapter({ cwd });
29
+ const inspection = await adapter.inspect();
30
+ if (inspection.available) {
31
+ console.log("PASS opencode CLI is available");
32
+ const supportedStr = Object.entries(inspection.supports)
33
+ .filter(([_, v]) => v)
34
+ .map(([k, _]) => k)
35
+ .join(", ");
36
+ console.log(`PASS opencode capabilities detected: ${supportedStr || "none"}`);
37
+ } else {
38
+ hasFailure = true;
39
+ console.log("FAIL opencode CLI is not installed or not available in PATH");
40
+ }
41
+
26
42
  for (const relativePath of REQUIRED_FILES) {
27
43
  const ok = await exists(path.join(cwd, relativePath));
28
44