@multileaf/ai-workflow 0.1.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 (165) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/LICENSE +21 -0
  3. package/README.md +32 -0
  4. package/dist/adapter-contract.d.ts +13 -0
  5. package/dist/adapter-contract.js +50 -0
  6. package/dist/adapter.d.ts +15 -0
  7. package/dist/adapter.js +62 -0
  8. package/dist/claude-layout.d.ts +9 -0
  9. package/dist/claude-layout.js +23 -0
  10. package/dist/cli.d.ts +4 -0
  11. package/dist/cli.js +30 -0
  12. package/dist/codex-layout.d.ts +10 -0
  13. package/dist/codex-layout.js +24 -0
  14. package/dist/confirmation.d.ts +9 -0
  15. package/dist/confirmation.js +41 -0
  16. package/dist/constants.d.ts +3 -0
  17. package/dist/constants.js +10 -0
  18. package/dist/context-cache.d.ts +8 -0
  19. package/dist/context-cache.js +17 -0
  20. package/dist/context-quality.d.ts +11 -0
  21. package/dist/context-quality.js +27 -0
  22. package/dist/context-retrieval.d.ts +3 -0
  23. package/dist/context-retrieval.js +13 -0
  24. package/dist/context-store.d.ts +9 -0
  25. package/dist/context-store.js +18 -0
  26. package/dist/copilot-layout.d.ts +9 -0
  27. package/dist/copilot-layout.js +24 -0
  28. package/dist/cursor-layout.d.ts +9 -0
  29. package/dist/cursor-layout.js +25 -0
  30. package/dist/dashboard.d.ts +37 -0
  31. package/dist/dashboard.js +251 -0
  32. package/dist/drift.d.ts +2 -0
  33. package/dist/drift.js +10 -0
  34. package/dist/evidence.d.ts +20 -0
  35. package/dist/evidence.js +32 -0
  36. package/dist/files.d.ts +2 -0
  37. package/dist/files.js +58 -0
  38. package/dist/gemini-layout.d.ts +9 -0
  39. package/dist/gemini-layout.js +23 -0
  40. package/dist/generator.d.ts +3 -0
  41. package/dist/generator.js +16 -0
  42. package/dist/intelligence.d.ts +2 -0
  43. package/dist/intelligence.js +13 -0
  44. package/dist/interpreter.d.ts +23 -0
  45. package/dist/interpreter.js +117 -0
  46. package/dist/lockfile.d.ts +12 -0
  47. package/dist/lockfile.js +59 -0
  48. package/dist/manifest.d.ts +15 -0
  49. package/dist/manifest.js +35 -0
  50. package/dist/migration.d.ts +22 -0
  51. package/dist/migration.js +50 -0
  52. package/dist/orchestration.d.ts +30 -0
  53. package/dist/orchestration.js +172 -0
  54. package/dist/organization-policy.d.ts +14 -0
  55. package/dist/organization-policy.js +47 -0
  56. package/dist/package-audit.d.ts +19 -0
  57. package/dist/package-audit.js +28 -0
  58. package/dist/package-contract.d.ts +30 -0
  59. package/dist/package-contract.js +93 -0
  60. package/dist/package-integrity.d.ts +8 -0
  61. package/dist/package-integrity.js +15 -0
  62. package/dist/package-updates.d.ts +11 -0
  63. package/dist/package-updates.js +32 -0
  64. package/dist/plugin-sdk.d.ts +20 -0
  65. package/dist/plugin-sdk.js +243 -0
  66. package/dist/policy-gate.d.ts +6 -0
  67. package/dist/policy-gate.js +20 -0
  68. package/dist/profile.d.ts +23 -0
  69. package/dist/profile.js +123 -0
  70. package/dist/providers.d.ts +20 -0
  71. package/dist/providers.js +67 -0
  72. package/dist/quality-gates.d.ts +2 -0
  73. package/dist/quality-gates.js +40 -0
  74. package/dist/recommendations.d.ts +12 -0
  75. package/dist/recommendations.js +63 -0
  76. package/dist/registry.d.ts +11 -0
  77. package/dist/registry.js +27 -0
  78. package/dist/scanner.d.ts +9 -0
  79. package/dist/scanner.js +83 -0
  80. package/dist/selection.d.ts +3 -0
  81. package/dist/selection.js +11 -0
  82. package/dist/self-validation.d.ts +9 -0
  83. package/dist/self-validation.js +9 -0
  84. package/dist/services.d.ts +42 -0
  85. package/dist/services.js +1 -0
  86. package/dist/team-configuration.d.ts +23 -0
  87. package/dist/team-configuration.js +104 -0
  88. package/dist/telemetry.d.ts +20 -0
  89. package/dist/telemetry.js +95 -0
  90. package/dist/token-usage.d.ts +9 -0
  91. package/dist/token-usage.js +38 -0
  92. package/dist/traceability.d.ts +23 -0
  93. package/dist/traceability.js +51 -0
  94. package/dist/types.d.ts +22 -0
  95. package/dist/types.js +1 -0
  96. package/dist/universal-layout.d.ts +9 -0
  97. package/dist/universal-layout.js +21 -0
  98. package/dist/vercel-skills.d.ts +17 -0
  99. package/dist/vercel-skills.js +49 -0
  100. package/dist/workflow.d.ts +4 -0
  101. package/dist/workflow.js +1130 -0
  102. package/docs/README.md +20 -0
  103. package/docs/adapter-model.md +16 -0
  104. package/docs/architecture.md +66 -0
  105. package/docs/backlog.md +93 -0
  106. package/docs/orchestration.md +50 -0
  107. package/docs/package-model.md +53 -0
  108. package/docs/plugin-authoring.md +31 -0
  109. package/docs/product-requirements.md +57 -0
  110. package/docs/product-vision.md +26 -0
  111. package/docs/project-intelligence.md +59 -0
  112. package/docs/quality.md +32 -0
  113. package/docs/release-backlog.md +7 -0
  114. package/docs/release-process.md +38 -0
  115. package/docs/security.md +18 -0
  116. package/docs/telemetry.md +28 -0
  117. package/docs/token-efficiency.md +16 -0
  118. package/package.json +76 -0
  119. package/resources/README.md +4 -0
  120. package/resources/agents/adapter-engineer.md +4 -0
  121. package/resources/agents/documentation-writer.md +4 -0
  122. package/resources/agents/quality-reviewer.md +4 -0
  123. package/resources/agents/requirements-analyst.md +4 -0
  124. package/resources/agents/security-reviewer.md +4 -0
  125. package/resources/agents/technical-architect.md +4 -0
  126. package/resources/agents/test-engineer.md +4 -0
  127. package/resources/agents/typescript-engineer.md +4 -0
  128. package/resources/hooks/post-change.md +4 -0
  129. package/resources/hooks/post-implementation.md +4 -0
  130. package/resources/hooks/pre-commit.md +4 -0
  131. package/resources/hooks/pre-implementation.md +4 -0
  132. package/resources/hooks/pre-release.md +4 -0
  133. package/resources/package.yaml +36 -0
  134. package/resources/rules/architecture-policy.md +4 -0
  135. package/resources/rules/completion-validation.md +19 -0
  136. package/resources/rules/dependency-policy.md +4 -0
  137. package/resources/rules/documentation-policy.md +4 -0
  138. package/resources/rules/generated-files.md +4 -0
  139. package/resources/rules/language-policy.md +4 -0
  140. package/resources/rules/quality-gates.md +4 -0
  141. package/resources/rules/security-policy.md +4 -0
  142. package/resources/rules/self-validation.md +12 -0
  143. package/resources/rules/tdd-policy.md +4 -0
  144. package/resources/skills/adapter-development.md +9 -0
  145. package/resources/skills/brainstorming.md +9 -0
  146. package/resources/skills/code-review.md +9 -0
  147. package/resources/skills/documentation-maintenance.md +9 -0
  148. package/resources/skills/implementation-planning.md +9 -0
  149. package/resources/skills/project-init.md +9 -0
  150. package/resources/skills/requirements-specification.md +9 -0
  151. package/resources/skills/security-review.md +9 -0
  152. package/resources/skills/skill-authoring.md +9 -0
  153. package/resources/skills/tdd-development.md +9 -0
  154. package/resources/skills/technical-design.md +9 -0
  155. package/resources/skills/verification.md +9 -0
  156. package/resources/templates/brainstorm.md +16 -0
  157. package/resources/templates/decision-record.md +12 -0
  158. package/resources/templates/implementation-plan.md +12 -0
  159. package/resources/templates/migration-report.md +14 -0
  160. package/resources/templates/security-review.md +14 -0
  161. package/resources/templates/specification.md +23 -0
  162. package/resources/templates/task.md +14 -0
  163. package/resources/templates/technical-design.md +14 -0
  164. package/resources/templates/test-plan.md +12 -0
  165. package/resources/templates/verification-report.md +12 -0
package/docs/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # AI Workflow Documentation
2
+
3
+ AI Workflow is a portable, spec-driven development system for AI coding agents. It installs reusable capabilities, profiles each repository, generates project-specific configuration, and preserves a neutral source of truth across agent targets.
4
+
5
+ ## Documents
6
+
7
+ - [Product vision](product-vision.md)
8
+ - [Product requirements](product-requirements.md)
9
+ - [Architecture](architecture.md)
10
+ - [Package and resource model](package-model.md)
11
+ - [Adapter model](adapter-model.md)
12
+ - [Security and trust](security.md)
13
+ - [Quality and testing](quality.md)
14
+ - [Token efficiency](token-efficiency.md)
15
+ - [Project intelligence](project-intelligence.md)
16
+ - [Release process](release-process.md)
17
+ - [Release backlog](release-backlog.md)
18
+ - [Backlog](backlog.md)
19
+
20
+ All generated AI Workflow artifacts are written in English unless the user explicitly requests another language.
@@ -0,0 +1,16 @@
1
+ # Adapter Model
2
+
3
+ Adapters translate the neutral resource model into a target agent's conventions.
4
+
5
+ ```text
6
+ Neutral skill → Codex SKILL.md
7
+ Neutral rule → Cursor .mdc / Claude instruction / AGENTS.md
8
+ Neutral agent → Target agent declaration or best-effort prompt
9
+ Neutral hook → Native hook, command, or documented fallback
10
+ ```
11
+
12
+ Each adapter must declare supported resource types and lifecycle events. Adapters must never silently discard unsupported resources. They must emit warnings and retain the neutral source.
13
+
14
+ ## Migration
15
+
16
+ `aiw target <target>` performs a dry-run analysis, reports additions, removals, conflicts, fallbacks, and unsupported features, then renders the new target after confirmation. User-modified generated files require explicit conflict handling.
@@ -0,0 +1,66 @@
1
+ # Architecture
2
+
3
+ ```text
4
+ CLI
5
+ └── Core runtime
6
+ ├── Package manager
7
+ ├── Project scanner and profiler
8
+ ├── AI project interpreter
9
+ ├── Recommendation engine
10
+ ├── Personalization engine
11
+ ├── Resource registry
12
+ ├── Validation and evidence engine
13
+ ├── Opt-in telemetry boundary
14
+ ├── Plugin authoring SDK
15
+ ├── Local dashboard
16
+ ├── Multi-agent scheduler
17
+ └── Adapter manager
18
+ ├── Codex
19
+ ├── Claude Code
20
+ ├── Cursor
21
+ ├── Gemini CLI
22
+ ├── GitHub Copilot
23
+ └── Universal
24
+ ```
25
+
26
+ ## Source of truth
27
+
28
+ `.aiw/` contains the neutral manifest, lockfile, project profile, selected resources, and versioned checkpoints. Generated specifications, plans, docs, and artifacts live under `.aiw/generated/`.
29
+
30
+ Target files such as `.cursor/rules`, `.claude/skills`, or Codex skill directories are generated by adapters and must not be treated as canonical state.
31
+
32
+ ## Runtime lifecycle
33
+
34
+ 1. Discover the project.
35
+ 2. Build or update the project profile.
36
+ 3. Resolve package dependencies.
37
+ 4. Recommend capabilities.
38
+ 5. Request user decisions.
39
+ 6. Generate personalized resources.
40
+ 7. Render target-specific files.
41
+ 8. Validate configuration and evidence.
42
+ 9. Record the operation.
43
+
44
+ Project analysis is hybrid: deterministic detectors establish observable facts, while a scoped AI interpreter explains conventions and produces recommendations. AI output is never confirmed project state without user approval.
45
+
46
+ ## Modularity
47
+
48
+ The CLI is an entry point, not the business layer. Filesystem, package providers, scanners, recommendation engines, generators, validators, and adapters must be replaceable through interfaces and dependency injection.
49
+
50
+ ## Telemetry
51
+
52
+ Telemetry is disabled by default and separated from command execution through an injectable client. The core emits only user-approved aggregate fields and does not own a network transport. Collector failures are isolated from workflow results.
53
+
54
+ ## Local dashboard
55
+
56
+ `aiw ui` starts an HTTP server bound exclusively to `127.0.0.1`. It projects the neutral `.aiw/` state into an English HTML dashboard and JSON read model. The page uses no external assets or client-side scripts. Migration posts require the exact `MIGRATE` confirmation and delegate to the existing target command, preserving its conflict, backup, and rollback behavior.
57
+
58
+ ## Multi-agent orchestration
59
+
60
+ The orchestration domain parses a strict, versioned task graph and schedules dependency waves with bounded parallelism. Preview is deterministic and read-only. Execution requires the explicit `--execute` flag and an injected `AgentOrchestrator`; this keeps Codex, Claude, Gemini, Orca, and future runtimes outside the core. Failed tasks block only their descendants, while independent work continues. Completed outcomes are recorded once in a versioned `.aiw/checkpoints/orchestration-<plan>.yml` checkpoint.
61
+
62
+ ## Self-hosting
63
+
64
+ The repository uses the `multileaf/aiw-self-hosting` package. This package supplies the workflow resources required to develop AI Workflow itself, including SDD skills, quality rules, specialist agents, lifecycle hooks, and artifact templates.
65
+
66
+ Behavioral changes are validated against this repository with `aiw self-validate --ticket=TYPE-000`. The command runs the complete project quality pipeline and writes deterministic evidence to `.aiw/checkpoints/self-validation-<ticket>.yml`, including required AIW state and the generated artifacts inspected during the run. Checkpoints are reviewable project history and are not part of the ignored `.aiw/generated` tree.
@@ -0,0 +1,93 @@
1
+ # Product Backlog
2
+
3
+ Priority levels: **P0** blocks the product or makes it unsafe; **P1** is required for a usable product; **P2** improves scale, quality, or portability; **P3** is an advanced or ecosystem feature.
4
+
5
+ ## Foundation — P0
6
+
7
+ - [x] **FND-001** Define and validate the neutral `manifest.yaml` schema. _Acceptance:_ invalid manifests produce actionable errors; schema is versioned and tested.
8
+ - [x] **FND-002** Define `package.yaml` and resource contracts. _Acceptance:_ skills, rules, agents, hooks, templates, policies, dependencies, permissions, and provenance are representable.
9
+ - [x] **FND-003** Define adapter contract and capability matrix. _Acceptance:_ adapters report supported resources and lifecycle events.
10
+ - [x] **FND-004** Introduce structured domain types and service interfaces. _Acceptance:_ CLI contains no business logic; services are dependency-injected and unit-testable.
11
+ - [x] **FND-005** Add complete TDD quality pipeline. _Acceptance:_ `check` runs format, lint, typecheck, tests, and security checks.
12
+ - [x] **FND-006** Add CI workflow. _Acceptance:_ every pull request runs all required checks.
13
+
14
+ ## Installation and lifecycle — P0/P1
15
+
16
+ - [x] **INS-001** Make installation idempotent and non-destructive. _Acceptance:_ repeated installation preserves overrides and reports state.
17
+ - [x] **INS-002** Implement target selection and detection. _Acceptance:_ supported installed agents are detected and user can override detection.
18
+ - [x] **INS-003** Install and register the base `ai-init` skill. _Acceptance:_ generated artifact is valid for every supported target.
19
+ - [x] **INS-004** Implement `status`, `doctor`, and actionable diagnostics. _Acceptance:_ missing, stale, conflicting, and unsupported state is explained.
20
+ - [x] **INS-005** Implement package resolution and lockfile generation. _Acceptance:_ same lockfile produces the same resources.
21
+ - [x] **INS-006** Implement uninstall and repair safely. _Acceptance:_ only AIW-owned generated files are removed or restored.
22
+
23
+ ## Project intelligence — P1
24
+
25
+ - [x] **SCAN-001** Build ignore-aware repository scanner. _Acceptance:_ respects `.gitignore`, excludes secrets, and has deterministic output.
26
+ - [x] **SCAN-002** Detect languages, frameworks, package managers, scripts, tests, linters, formatters, CI, and workspace structure. _Acceptance:_ fixtures cover common project types.
27
+ - [x] **SCAN-003** Store confidence and evidence for detected facts. _Acceptance:_ each inferred fact points to a source and confidence score.
28
+ - [x] **SCAN-005** Define the hybrid intelligence contract. _Acceptance:_ detected, inferred, and confirmed states are represented and AI inference cannot silently replace deterministic facts.
29
+ - [x] **SCAN-006** Implement scoped AI project interpreter. _Acceptance:_ interpreter receives filtered context and produces structured insights requiring confirmation when uncertain.
30
+ - [x] **SCAN-007** Add interpreter privacy and token guardrails. _Acceptance:_ secrets, dependencies, generated files, Git internals, and checkpoints are excluded and token usage is measured.
31
+ - [x] **SCAN-004** Add interactive confirmation and overrides. _Acceptance:_ users can accept, reject, or edit inferred facts.
32
+ - [x] **REC-001** Build capability recommendation engine. _Acceptance:_ recommendations include rationale, evidence, permissions, conflicts, and confidence.
33
+ - [x] **REC-002** Add interactive capability selection. _Acceptance:_ users select packages and individual resources before installation.
34
+ - [x] **GEN-001** Generate project-specific rules, agents, hooks, and context. _Acceptance:_ generated content uses confirmed profile data and English artifacts.
35
+ - [x] **GEN-002** Preserve manual overrides and detect drift. _Acceptance:_ regeneration never silently overwrites user changes.
36
+
37
+ ## SDD workflow — P1
38
+
39
+ - [x] **SDD-001** Implement brainstorming artifact and facilitator skill. _Acceptance:_ goals, users, assumptions, constraints, and open questions are captured.
40
+ - [x] **SDD-002** Implement specification skill and template. _Acceptance:_ requirements have stable IDs and acceptance criteria.
41
+ - [x] **SDD-003** Implement design and architecture decision records. _Acceptance:_ alternatives, decisions, and rationale are linked.
42
+ - [x] **SDD-004** Implement implementation planning. _Acceptance:_ tasks link to requirements and validation commands.
43
+ - [x] **SDD-005** Implement verification skill. _Acceptance:_ missing evidence and untested requirements are reported.
44
+ - [x] **SDD-006** Implement requirement-to-evidence traceability graph. _Acceptance:_ requirement → decision → task → code → test → evidence is queryable.
45
+ - [x] **SDD-007** Add quality gates between workflow stages. _Acceptance:_ incomplete artifacts block progression with actionable feedback.
46
+
47
+ ## Adapters and migration — P1/P2
48
+
49
+ - [x] **ADP-001** Complete Codex adapter. _Acceptance:_ skills, rules, agents, hooks, and context render correctly where supported.
50
+ - [x] **ADP-002** Implement Claude Code adapter.
51
+ - [x] **ADP-003** Implement Cursor adapter.
52
+ - [x] **ADP-004** Implement Gemini CLI adapter.
53
+ - [x] **ADP-005** Implement GitHub Copilot adapter.
54
+ - [x] **ADP-006** Implement universal fallback adapter.
55
+ - [x] **MIG-001** Implement `aiw target <target>` migration. _Acceptance:_ neutral resources are rendered to the new target and manifest is updated.
56
+ - [x] **MIG-002** Add migration dry-run, conflict report, backup, and rollback. _Acceptance:_ failed migration leaves the previous target intact.
57
+ - [x] **MIG-003** Add adapter contract and fixture tests. _Acceptance:_ each adapter passes common rendering and degradation scenarios.
58
+
59
+ ## External ecosystem — P2
60
+
61
+ - [x] **PKG-001** Implement local and Git package providers.
62
+ - [x] **PKG-002** Integrate Vercel Skills as an external provider. _Acceptance:_ search, inspect, install, lock, and update are represented in AIW state.
63
+ - [x] **PKG-003** Add package audit and permission review before installation.
64
+ - [x] **PKG-004** Add update, compatibility, and dependency conflict workflows.
65
+ - [x] **PKG-005** Create a curated Multileaf package registry.
66
+ - [x] **PKG-006** Add package signing, checksums, and provenance verification.
67
+
68
+ ## Context and cost — P2
69
+
70
+ - [x] **CTX-001** Build layered project context store.
71
+ - [x] **CTX-002** Add task-scoped context retrieval and delta loading.
72
+ - [x] **CTX-003** Add summary cache and freshness invalidation.
73
+ - [x] **CTX-004** Add per-stage token budgets and usage reporting.
74
+ - [x] **CTX-005** Add context quality metrics and regression tests.
75
+
76
+ ## Enterprise and ecosystem — P3
77
+
78
+ - [x] **ENT-001** Add organization policies and approved package sources.
79
+ - [x] **ENT-002** Add team-shared presets and private registries.
80
+ - [x] **ENT-003** Add policy enforcement in CI and pull requests.
81
+ - [x] **ENT-004** Add telemetry opt-in with privacy controls. _Acceptance:_ telemetry is disabled by default, users independently control aggregate command/outcome fields, sensitive execution data is never serialized, and collector failures cannot affect workflow results.
82
+ - [x] **ENT-005** Add plugin SDK and package authoring tooling. _Acceptance:_ authors can deterministically scaffold and validate portable packages through the CLI and typed SDK, unsafe paths and overwrites fail atomically, and generated resources are English and contract-valid.
83
+ - [x] **ENT-006** Add web UI for project profile, recommendations, traceability, and migrations. _Acceptance:_ `aiw ui` serves a local-only, responsive and accessible dashboard from packaged project state; profile, recommendations, and requirement evidence are visible; migrations require explicit confirmation and delegate to the existing workflow.
84
+ - [x] **ENT-007** Add multi-agent orchestration and parallel task execution. _Acceptance:_ strict versioned task graphs support deterministic preview, explicit adapter-backed execution, bounded parallelism, dependency-aware failure isolation, and immutable checkpoint evidence.
85
+
86
+ ## Backlog rules
87
+
88
+ - [x] **FND-009** Add self-validation workflow. _Acceptance:_ changes affecting AIW behavior execute against this repository and record generated-output evidence.
89
+ - Every item must have tests or explicit validation evidence before completion.
90
+ - Every item must validate all affected layers; domain tests alone cannot mark an externally visible feature as complete.
91
+ - New work must identify its affected contract and dependencies.
92
+ - P0 work takes precedence over feature expansion.
93
+ - A task may move to Done only when implementation, tests, documentation, and quality checks pass.
@@ -0,0 +1,50 @@
1
+ # Multi-agent Orchestration
2
+
3
+ AI Workflow represents coordinated work as a strict, versioned task graph. The core scheduler is provider-neutral: a host integrates Codex, Claude, Gemini, Orca, or another runtime through the exported `AgentOrchestrator` interface.
4
+
5
+ ## Plan format
6
+
7
+ ```yaml
8
+ schema: 1
9
+ id: release-readiness
10
+ tasks:
11
+ - id: TASK-001
12
+ agent: codex
13
+ prompt: "Implement the approved specification."
14
+ depends_on: []
15
+ - id: TASK-002
16
+ agent: claude
17
+ prompt: "Review the implementation and tests."
18
+ depends_on: [TASK-001]
19
+ - id: TASK-003
20
+ agent: gemini
21
+ prompt: "Validate documentation and traceability."
22
+ depends_on: [TASK-001]
23
+ ```
24
+
25
+ Plan identifiers use lowercase letters, numbers, and hyphens. Task identifiers use `TASK-###`. Prompts are JSON-quoted strings, dependencies must reference tasks in the same plan, and cycles are rejected before execution.
26
+
27
+ ## Commands
28
+
29
+ ```bash
30
+ aiw orchestrate --plan=orchestration.yml
31
+ aiw orchestrate --plan=orchestration.yml --execute --max-parallel=2
32
+ ```
33
+
34
+ The first command prints deterministic execution waves and does not invoke an agent or mutate project state. `--execute` requires a host-provided adapter. Parallelism must be an integer from 1 through 16. A failed or unavailable agent marks its task as failed; dependent tasks are blocked, while unrelated tasks continue.
35
+
36
+ Each executed plan writes one `.aiw/checkpoints/orchestration-<plan-id>.yml` result. Existing checkpoints are never overwritten: use a new plan identifier for a new run. Agent result details are bounded and serialized safely.
37
+
38
+ ## Adapter contract
39
+
40
+ ```ts
41
+ import type { AgentOrchestrator, OrchestrationTask } from "@multileaf/ai-workflow/orchestration";
42
+
43
+ const orchestrator: AgentOrchestrator = {
44
+ async run(task: OrchestrationTask) {
45
+ return { success: true, detail: `${task.id} completed by ${task.agent}` };
46
+ },
47
+ };
48
+ ```
49
+
50
+ The adapter owns runtime authentication, process isolation, completion detection, and permission enforcement. It must resolve only after the delegated agent has finished. AI Workflow owns graph validation, scheduling, failure propagation, result ordering, and checkpoint persistence.
@@ -0,0 +1,53 @@
1
+ # Package and Resource Model
2
+
3
+ An AI Workflow package is a versioned collection of capabilities.
4
+
5
+ ```text
6
+ package/
7
+ ├── package.yaml
8
+ ├── skills/
9
+ ├── rules/
10
+ ├── agents/
11
+ ├── hooks/
12
+ ├── templates/
13
+ ├── policies/
14
+ └── adapters/
15
+ ```
16
+
17
+ ## Resource types
18
+
19
+ - **Skill**: procedural knowledge for an agent.
20
+ - **Rule**: constraint or project policy.
21
+ - **Agent**: specialized role with inputs and outputs.
22
+ - **Hook**: lifecycle-triggered action.
23
+ - **Template**: structure for a project artifact.
24
+ - **Policy**: permissions, quality gates, or governance.
25
+ - **Adapter**: target-specific rendering metadata.
26
+
27
+ Packages may come from local paths, Git repositories, npm-compatible providers, Vercel Skills, or a future Multileaf registry.
28
+
29
+ Local directories and Git repositories are resolved with `aiw resolve --source=<source>`. A local source may be a package directory or its `package.yaml`; relative paths are resolved from the project. Git sources support `git+https`, HTTPS, SSH, and `file://` URLs. Git packages are cloned into an isolated temporary checkout, validated before the lockfile is changed, and removed after resolution. The lockfile records the selected provider and normalized source rather than trusting those fields from the fetched manifest. The legacy `--package=<path>` form remains available for direct manifest resolution.
30
+
31
+ Vercel Skills is exposed through `aiw skills search`, `inspect`, `install`, `check`, and `update`. AIW delegates to the official `npx skills` CLI with argument arrays, requires explicit `network:external` permission for network-mutating/check operations, and records installed skills and upstream integrity in `.aiw/lock.yml`. Update output is inspected for upstream failure text because some CLI releases may report failures with a successful process exit code.
32
+
33
+ Use `aiw audit-package --package=<path>` before resolution or installation to review requested permissions and their risk levels. Every permission must belong to AIW's known permission catalog, and every requested permission requires an exact `--allow=<permission>` approval. Unknown permissions are rejected even when passed through `--allow`; denied audits and approvals must not modify package state.
34
+
35
+ Organizations can install a versioned policy with `aiw organization-policy --file=<path>`. The policy defines approved provider/source patterns and denied permissions. A trailing `*` performs an explicit prefix match; all other entries require an exact match. Once configured, AIW validates the provider and source before loading a package, so unapproved Git sources are rejected before a clone or temporary checkout is created. Permissions are validated after the package manifest is loaded and before project state or the lockfile changes; temporary checkouts created for approved Git sources are removed when permission validation fails. Replacing an existing policy requires the explicit `--replace` flag.
36
+
37
+ Repositories enforce the tracked policy in CI with `aiw policy-check --package=<path>`. The gate validates declared package permissions, every package source in the lockfile, and configured private registries. It fails when the organization policy is missing, malformed, or violated and is intended to run on pushes and pull requests after the normal quality pipeline.
38
+
39
+ Teams can commit a portable preset with package requirements and named registry references, then install it with `aiw preset --file=<path>`. AIW writes a deterministic copy to `.aiw/team-preset.yml`; replacing it requires `--replace`. Presets contain no credentials.
40
+
41
+ Private registries are configured with `aiw registry configure --file=<path>`. Each HTTPS registry entry stores a name, URL, and environment-variable reference such as `AIW_ENGINEERING_TOKEN`; inline secrets, URL credentials, query strings, and fragments are rejected. The complete document is validated before an atomic replacement, so malformed entries cannot apply a valid subset or overwrite the previous configuration. `aiw registry --private=<name> --search=<query>` reads the credential only at execution time, applies organization source and `network:external` policy before the request, validates the response and known permissions, and never serializes the token. Registry configuration is stored in `.aiw/registries.yml` and requires `--replace` for updates.
42
+
43
+ Every package must declare an identifier, package version, provider, source, engine compatibility, resources, dependencies, supported targets, permissions, and provenance. Each resource has its own stable identifier, version, and path.
44
+
45
+ The project manifest stores requested version ranges. The lockfile stores the exact resolved version, provider, source, integrity information, requested permissions, and resource versions used by the project. The CI policy gate parses every lock entry strictly and evaluates it independently from package manifests, including entries with matching identifiers. Updates compare the requested range with the resolved lockfile version and never rely on a filename or list position.
46
+
47
+ ```yaml
48
+ packages:
49
+ - id: multileaf/sdd-core
50
+ requested: ^1.2.0
51
+ provider: vercel-skills
52
+ source: vercel-labs/agent-skills
53
+ ```
@@ -0,0 +1,31 @@
1
+ # Plugin SDK and Package Authoring
2
+
3
+ AI Workflow plugins use the same neutral package contract as built-in resources. A plugin can contain skills, rules, agents, hooks, and templates while adapters remain responsible for target-specific rendering.
4
+
5
+ ## Create a plugin
6
+
7
+ ```bash
8
+ aiw plugin create \
9
+ --directory=plugins/example \
10
+ --id=acme/example \
11
+ --version=1.0.0 \
12
+ --description="Provide an example workflow."
13
+
14
+ aiw plugin validate --directory=plugins/example
15
+ ```
16
+
17
+ Creation writes an English `README.md`, a valid `package.yaml`, and a starter skill. Output is deterministic. Destinations must remain inside the project, invalid definitions are rejected before writes, and existing scaffold files are never overwritten.
18
+
19
+ Validation checks the package contract and every declared resource path. It does not execute plugin content or grant permissions.
20
+
21
+ ## TypeScript SDK
22
+
23
+ The package exports `@multileaf/ai-workflow/plugin-sdk` with:
24
+
25
+ - `definePlugin` for a typed, immutable package definition;
26
+ - `createPluginScaffold` for deterministic in-memory authoring;
27
+ - `writePluginScaffold` for conflict-safe persistence;
28
+ - `validatePluginDirectory` for project-root-confined contract and resource validation;
29
+ - `resolvePluginDirectory` for project-confined paths.
30
+
31
+ The filesystem boundary is injected, so hosts can test authoring without disk access. Package permissions and organization policies are still enforced by the normal installation and resolution workflow.
@@ -0,0 +1,57 @@
1
+ # Product Requirements
2
+
3
+ ## Functional requirements
4
+
5
+ ### Installation
6
+
7
+ - The CLI must install with `npx @multileaf/ai-workflow install`.
8
+ - Installation must support Codex, Claude Code, Cursor, Gemini CLI, GitHub Copilot, and a universal target over time.
9
+ - Installation must be idempotent and preserve user overrides.
10
+ - Installation must create a neutral `.aiw/` source of truth.
11
+ - Generated specifications, plans, docs, and artifacts must live under `.aiw/generated/` and be ignored by Git.
12
+ - Checkpoints must live under `.aiw/checkpoints/` and remain versioned.
13
+
14
+ ### Initialization
15
+
16
+ - `/ai-init` must scan a repository safely.
17
+ - The scanner must identify languages, frameworks, package managers, commands, tests, linters, formatters, CI, and project structure.
18
+ - The analysis pipeline must combine deterministic detectors with a scoped AI interpreter.
19
+ - Facts and inferences must be stored separately with evidence, confidence, method, and confirmation state.
20
+ - The interpreter must receive filtered context and exclude secrets, dependencies, generated files, Git internals, and checkpoints by default.
21
+ - Recommendations must explain their evidence, capabilities, permissions, and conflicts.
22
+ - The user must select which capabilities to install.
23
+ - Selected resources must be customized using confirmed project facts.
24
+
25
+ ### Development workflow
26
+
27
+ - The product must support brainstorming, specification, design, planning, implementation, and verification stages.
28
+ - Requirements, decisions, tasks, code changes, tests, and evidence must be traceable.
29
+ - A task must not be considered complete without configured validation evidence.
30
+
31
+ ### Portability
32
+
33
+ - `aiw target <target>` must migrate generated resources to another target.
34
+ - Unsupported features must be reported and preserved in neutral form.
35
+ - Migration must support dry-run, conflict detection, backups, and rollback.
36
+
37
+ ### Governance
38
+
39
+ - Packages must declare versions, dependencies, permissions, supported targets, and provenance.
40
+ - Generated files must be distinguishable from user-owned files.
41
+ - Lockfiles must make installations reproducible.
42
+
43
+ ### Local dashboard
44
+
45
+ - `aiw ui` must expose project profile, recommendations, traceability, and target migration from a loopback-only web interface.
46
+ - The dashboard must render project data safely without external assets, third-party scripts, telemetry, or a separate source of truth.
47
+ - Target migration must require explicit confirmation and use the same workflow service as the CLI.
48
+ - Read-only dashboard requests must not mutate project state.
49
+
50
+ ## Non-functional requirements
51
+
52
+ - TypeScript code must pass formatting, linting, type checking, and tests.
53
+ - Core services must be independently unit-testable.
54
+ - Scanner access must exclude secrets and ignored paths by default.
55
+ - The runtime must provide useful behavior when an adapter has reduced capabilities.
56
+ - Token budgets and context usage must be observable.
57
+ - Changes must be validated against the AI Workflow repository itself when the relevant capability exists.
@@ -0,0 +1,26 @@
1
+ # Product Vision
2
+
3
+ ## Summary
4
+
5
+ AI Workflow makes AI-assisted software development reproducible, inspectable, and portable. It turns brainstorming into specifications, specifications into implementation plans, and implementation into verifiable evidence.
6
+
7
+ ## Problem
8
+
9
+ AI coding tools often depend on implicit prompts, fragmented configuration, repeated context, and vendor-specific files. Teams need a consistent development process without committing to one agent or manually maintaining every integration.
10
+
11
+ ## Product principles
12
+
13
+ 1. Specifications and decisions are the source of truth.
14
+ 2. Generated target files are derived artifacts.
15
+ 3. The user approves recommendations and meaningful changes.
16
+ 4. Every requirement should have validation evidence.
17
+ 5. Project artifacts are English by default.
18
+ 6. Context is loaded just in time to control token cost.
19
+ 7. Unsafe capabilities require explicit permission.
20
+
21
+ ## Product outcomes
22
+
23
+ - A new repository can be configured through one guided initialization.
24
+ - The same AI development environment can migrate between agents.
25
+ - Project-specific rules are generated from detected and confirmed facts.
26
+ - Teams can review AI behavior through versioned files and traceability.
@@ -0,0 +1,59 @@
1
+ # Project Intelligence
2
+
3
+ AI Workflow uses a hybrid analysis pipeline.
4
+
5
+ ```text
6
+ Deterministic detectors → Detected project profile → Relevant context selection
7
+ → AI interpreter → Insights and recommendations → User confirmation
8
+ → Confirmed project profile
9
+ ```
10
+
11
+ ## Deterministic layer
12
+
13
+ Detectors establish observable facts: files, dependencies, versions, package managers, scripts, frameworks, quality tools, tests, CI, workspaces, ignored paths, and configuration files. Each fact includes its source and detection method.
14
+
15
+ ```yaml
16
+ fact: tool.eslint
17
+ value: true
18
+ source: eslint.config.js
19
+ method: deterministic
20
+ confidence: 1.0
21
+ ```
22
+
23
+ ## AI interpretation layer
24
+
25
+ The interpreter handles architecture conventions, naming patterns, testing style, implicit policies, documentation consistency, contradictions, and capability recommendations. It receives filtered context rather than the entire repository.
26
+
27
+ The runtime exposes a provider-neutral `AiProvider` interface. Provider adapters receive an English system instruction, a scoped prompt, a token ceiling, and a JSON response requirement. The interpreter validates and normalizes that response into evidence facts; provider output cannot choose evidence state or cite a file outside the supplied context.
28
+
29
+ ```yaml
30
+ fact: architecture.style
31
+ value: feature-based
32
+ sources: [src/features]
33
+ confidence: 0.78
34
+ method: ai-inference
35
+ requires_confirmation: true
36
+ ```
37
+
38
+ ## Evidence states
39
+
40
+ - `detected`: observed by a deterministic detector.
41
+ - `inferred`: proposed by the AI interpreter.
42
+ - `confirmed`: accepted or edited by the user.
43
+
44
+ Only detected and confirmed data may drive automatic generation. Inferred data requires confirmation when it changes generated behavior.
45
+
46
+ ## Context controls
47
+
48
+ The interpreter excludes secrets, binaries, generated output, dependencies, Git internals, and checkpoints by default. It receives only files relevant to the active analysis task.
49
+
50
+ The request contract also carries a positive `maxTokens` ceiling and a deterministic `estimatedTokens` measurement capped at that ceiling. Provider calls receive the same ceiling, while token usage can be recorded through the per-stage usage ledger.
51
+
52
+ Before a provider call, the interpreter:
53
+
54
+ - normalizes and filters relative paths;
55
+ - reads only eligible text files inside the project root;
56
+ - redacts common credential assignments, bearer tokens, and private keys;
57
+ - rejects inferred evidence that cites any file outside the scoped request.
58
+
59
+ The workflow accepts an injected interpreter service. A configured interpreter runs during `aiw scan`, and its structured facts are stored in `.aiw/profile.yml` alongside deterministic facts. Facts below the confidence threshold are marked `requires_confirmation: true`. Without a configured provider, scans remain deterministic and do not make a network request.
@@ -0,0 +1,32 @@
1
+ # Quality and Testing
2
+
3
+ Development follows TDD:
4
+
5
+ ```text
6
+ Red → Green → Refactor → Verify
7
+ ```
8
+
9
+ ## Required checks
10
+
11
+ - Unit tests for pure functions and domain services.
12
+ - Integration tests for filesystem and package workflows.
13
+ - Contract tests for every adapter.
14
+ - End-to-end tests for install, init, sync, migration, and rollback.
15
+ - ESLint for code quality.
16
+ - Prettier for formatting.
17
+ - TypeScript strict compilation.
18
+ - Dependency and code security scans.
19
+
20
+ No feature is complete without tests for its happy path, invalid input, conflicts, and safe failure behavior.
21
+
22
+ ## Completion validation
23
+
24
+ A feature is complete only when all affected layers are validated: domain, module integration, CLI or adapter integration, generated artifacts, end-to-end behavior, documentation, traceability, and security. Domain tests alone are insufficient for changes that affect external behavior or generated project state.
25
+
26
+ Externally visible tasks also require an isolated integration run by an AI subagent in a separate worktree. That run must use the packaged or executable workflow, record its outcomes, and leave the validation worktree clean.
27
+
28
+ Every launched subagent must be instructed to send a direct Orca orchestration message to the coordinator terminal when it finishes; a mailbox-only notification is insufficient. The message must include its status, validation summary, failures, and worktree cleanliness.
29
+
30
+ ## Self-validation
31
+
32
+ AI Workflow must use itself to validate changes whenever the current capabilities support the task. Changes affecting installation, scanning, generation, migration, adapters, or project configuration must be executed against this repository and their generated output must be inspected. Unit tests alone are not sufficient for these changes.
@@ -0,0 +1,7 @@
1
+ # Release Backlog
2
+
3
+ ## Version 0.1.0
4
+
5
+ - [x] **REL-001** Prepare a reproducible release candidate. _Acceptance:_ metadata, changelog, package allowlist, clean compilation, automated release checks, exact-tarball smoke tests, and provenance-ready CI are present and validated.
6
+ - [x] **REL-002** Approve the public package license and configure secure npm publishing for `MultiLeaf/aiw`. _Acceptance:_ MIT is approved, the granular bootstrap token is stored only as an environment secret, and the protected GitHub `npm` environment requires review, rejects administrative bypass, and accepts only version tags.
7
+ - [ ] **REL-003** Publish and verify version `0.1.0`. _Acceptance:_ the signed Git tag, GitHub release, npm package, provenance statement, clean `npx` installation, and post-publication smoke tests all agree on the immutable version.
@@ -0,0 +1,38 @@
1
+ # Release Process
2
+
3
+ AI Workflow releases are reproducible, evidence-backed, and published only from a clean protected branch.
4
+
5
+ ## Preconditions
6
+
7
+ - The release version follows Semantic Versioning and matches the intended Git tag.
8
+ - `CHANGELOG.md` contains the release date and user-visible changes.
9
+ - The package declares the approved MIT License.
10
+ - The npm account is authenticated and authorized for the `@multileaf` scope.
11
+ - The GitHub `npm` environment requires release approval and the tagged commit belongs to `origin/main`.
12
+ - `main` is clean, synchronized with `origin/main`, and the complete backlog remains validated.
13
+
14
+ ## Validation
15
+
16
+ ```bash
17
+ npm ci
18
+ npm run release:check
19
+ ```
20
+
21
+ The release check runs formatting, linting, strict type checks, a build, tests, dependency audit, organization policy enforcement, and package-content validation. The package validator rejects internal state, source files, test output, fixtures, or nested tarballs and requires the executable, public declarations, resources, documentation, README, and changelog.
22
+
23
+ Install the exact candidate tarball in a new temporary project and exercise at least installation, help, doctor, scan, target migration dry-run, and the public SDK exports. Record its SHA-256 digest in the release evidence.
24
+
25
+ ## Publication
26
+
27
+ After human review of the package contents and legal license, create and push a signed version tag. The release workflow validates the exact tagged source and publishes with npm trusted publishing and provenance:
28
+
29
+ ```bash
30
+ git tag -s v0.1.0 -m "AI Workflow v0.1.0"
31
+ git push origin v0.1.0
32
+ ```
33
+
34
+ For the first publication only, create a short-lived granular npm token scoped to `@multileaf/ai-workflow` with package read/write access and add it as the `NPM_TOKEN` secret in the protected GitHub `npm` environment. The token is exposed only to the publish step, which still generates provenance from the GitHub-hosted runner. Do not store the token in project files, shell history, workflow output, or documentation.
35
+
36
+ After `0.1.0` exists, configure organization `MultiLeaf`, repository `aiw`, workflow `release.yml`, and environment `npm` as a trusted publisher in the package settings. Publish a subsequent release through OIDC and verify its provenance on npm before deleting the GitHub bootstrap secret and revoking the granular token. A saved publisher configuration alone is insufficient evidence because npm validates it only during publication.
37
+
38
+ The workflow uses Node 24 and npm 11.5.1 or newer, strictly validates Semantic Versioning, checks that the tag is `v<package-version>`, requires the approved license, and verifies ancestry from `origin/main`. Publish each tag only once; never reuse, move, or overwrite a published version.
@@ -0,0 +1,18 @@
1
+ # Security and Trust
2
+
3
+ AI Workflow can install instructions and execute hooks, so packages are supply-chain inputs.
4
+
5
+ ## Controls
6
+
7
+ - Validate manifests before installation.
8
+ - Pin resolved versions in `lock.yaml`.
9
+ - Record source and checksums where available.
10
+ - Declare filesystem, shell, network, and secret permissions.
11
+ - Require confirmation for privileged hooks.
12
+ - Exclude secret files and ignored paths from scans.
13
+ - Provide `--dry-run`, audit output, and rollback.
14
+ - Run dependency and code security scans in CI.
15
+ - Enforce the tracked organization policy on every push and pull request with `npm run policy:check`.
16
+ - Keep telemetry disabled by default and exclude arguments, paths, content, output, errors, credentials, and identifiers from its event contract.
17
+
18
+ Packages with critical or high vulnerabilities, malicious provenance, archival status, or stale maintenance should be rejected or require an explicit documented override.
@@ -0,0 +1,28 @@
1
+ # Telemetry and Privacy
2
+
3
+ AI Workflow telemetry is disabled by default. No event is recorded unless a user explicitly runs `aiw telemetry enable` and a host application provides a telemetry client.
4
+
5
+ ## Controls
6
+
7
+ ```bash
8
+ aiw telemetry status
9
+ aiw telemetry enable --commands=include --outcomes=include
10
+ aiw telemetry enable --commands=exclude --outcomes=include
11
+ aiw telemetry disable
12
+ ```
13
+
14
+ Preferences are stored in `.aiw/telemetry.yml`. Command and outcome collection can be enabled or excluded independently. Disabling telemetry takes effect before the next event can be recorded.
15
+
16
+ Rejected telemetry administration commands never produce telemetry events, even when a previous valid configuration enabled collection. This keeps malformed consent or privacy changes outside the telemetry stream.
17
+
18
+ ## Data contract
19
+
20
+ An event contains only:
21
+
22
+ - schema version;
23
+ - the top-level command name, when allowed;
24
+ - success or failure, when allowed.
25
+
26
+ Events never contain command arguments, file paths, project names, file contents, environment variables, prompts, output, error messages, credentials, or stable user/project identifiers. Invalid command names are reported as `unknown` instead of being copied into an event.
27
+
28
+ The telemetry subsystem does not define a network endpoint or transport. Delivery is provided exclusively through the injectable `TelemetryClient` boundary. Other product features, such as private registries, have separate network boundaries and are not telemetry transports. Missing or failing telemetry collectors cannot change a workflow command's result.
@@ -0,0 +1,16 @@
1
+ # Token Efficiency
2
+
3
+ Token efficiency is a runtime concern, not only a prompt-writing concern.
4
+
5
+ ## Strategies
6
+
7
+ - Store facts, decisions, and conversation summaries separately.
8
+ - Load context by task and dependency rather than sending the whole repository.
9
+ - Use stable identifiers for requirements and decisions.
10
+ - Send deltas after the first context load.
11
+ - Cache project profiles and generated summaries.
12
+ - Track context freshness and invalidate stale summaries.
13
+ - Apply budgets by workflow stage.
14
+ - Measure tokens per agent, package, task, and verification cycle.
15
+
16
+ The runtime should prefer references such as `AUTH-REQ-04` and retrieve their content only when needed.