@multileaf/ai-workflow 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,24 @@ All notable changes to this project are documented in this file. The format foll
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.1.1] - 2026-09-12
8
+
9
+ ### Fixed
10
+
11
+ - Activate the complete bundled workflow package during installation instead of installing only `ai-init`.
12
+ - Preserve user edits during migration rollback and remove migration checkpoints during uninstall.
13
+ - Match Git ignore rules consistently when scanning projects.
14
+
15
+ ### Security
16
+
17
+ - Validate package manifests and resource paths, verify local package integrity, and redact credentials from scanned context.
18
+ - Track installed-file ownership so uninstall and migration only remove unchanged AI Workflow files.
19
+ - Require organization approval and explicit consent before loading remote package sources.
20
+
21
+ ### Changed
22
+
23
+ - Update runtime and development dependencies and expand install, migration, rollback, and security coverage.
24
+
7
25
  ## [0.1.0] - 2026-09-04
8
26
 
9
27
  ### Added
@@ -18,5 +36,6 @@ All notable changes to this project are documented in this file. The format foll
18
36
 
19
37
  - Path confinement, symlink protection, explicit permission gates, secret redaction, strict parsers, atomic migrations, and immutable execution checkpoints.
20
38
 
21
- [Unreleased]: https://github.com/MultiLeaf/aiw/compare/v0.1.0...HEAD
39
+ [Unreleased]: https://github.com/MultiLeaf/aiw/compare/v0.1.1...HEAD
40
+ [0.1.1]: https://github.com/MultiLeaf/aiw/releases/tag/v0.1.1
22
41
  [0.1.0]: https://github.com/MultiLeaf/aiw/releases/tag/v0.1.0
package/README.md CHANGED
@@ -1,32 +1,341 @@
1
1
  # AI Workflow
2
2
 
3
- Portable spec-driven development workflow for AI coding agents.
3
+ AI Workflow is a portable, spec-driven development system for AI coding agents. It gives a repository a repeatable path from discovery and brainstorming to requirements, implementation plans, code, and verification evidence without coupling the project to one AI provider.
4
+
5
+ It can configure Codex, Claude Code, Cursor, Gemini CLI, GitHub Copilot, or a provider-neutral layout from the same canonical project state.
6
+
7
+ ## Why AI Workflow
8
+
9
+ AI-assisted development often relies on implicit prompts, duplicated configuration, and tool-specific files that drift over time. AI Workflow makes that process explicit and reviewable:
10
+
11
+ - project facts are detected before recommendations are made;
12
+ - inferred conventions require confirmation before they drive generation;
13
+ - specifications and decisions remain the source of truth;
14
+ - skills, rules, agents, hooks, and templates are versioned resources;
15
+ - target-specific files are generated through adapters;
16
+ - quality gates and checkpoints provide completion evidence;
17
+ - context is filtered and loaded only when needed to reduce token usage;
18
+ - package-declared sensitive capabilities are evaluated by policy boundaries.
4
19
 
5
20
  ## Installation
6
21
 
22
+ The published package supports Node.js 18 or newer. Full development checks require Node.js 20.19 or newer for the current lint and test toolchain; CI runs on Node.js 20 and release validation runs on Node.js 24. Node.js 18 remains the declared runtime floor but is not currently in the release validation matrix.
23
+
7
24
  ```bash
8
25
  npx @multileaf/ai-workflow install --target codex
9
26
  ```
10
27
 
11
- Replace `codex` with `claude`, `cursor`, `gemini`, `copilot`, or `universal` when needed. Every command follows `npx @multileaf/ai-workflow <command> <options>`.
28
+ Supported targets are `codex`, `claude`, `cursor`, `gemini`, `copilot`, and `universal`. Every command uses the same entry point:
29
+
30
+ ```bash
31
+ npx @multileaf/ai-workflow <command> <options>
32
+ ```
33
+
34
+ The initial installation creates workflow state and a target-specific `ai-init` skill. Run it in a repository that does not already use the reserved paths shown below: first installation currently writes the base ADR index and target `ai-init` file at those paths. Reinstallation detects existing AI Workflow state and preserves it.
35
+
36
+ ## What gets created
37
+
38
+ For a Codex installation, the base layout is:
39
+
40
+ ```text
41
+ .agents/
42
+ └── skills/
43
+ ├── ai-init/SKILL.md
44
+ ├── brainstorming/SKILL.md
45
+ ├── requirements-specification/SKILL.md
46
+ ├── tdd-development/SKILL.md
47
+ └── ...
48
+ .agents/agents/ # specialist agent definitions
49
+ .agents/hooks/ # lifecycle guidance and compatibility resources
50
+ .agents/rules/ # quality, security, and project rules
51
+ .agents/templates/ # SDD artifact templates
52
+ .context/
53
+ └── adrs/
54
+ └── INDEX.md
55
+ .aiw/
56
+ ├── checkpoints/
57
+ ├── context/
58
+ ├── generated/
59
+ │ ├── artifacts/
60
+ │ ├── docs/
61
+ │ ├── plans/
62
+ │ └── specs/
63
+ ├── lock.yml
64
+ ├── manifest.yml
65
+ └── profile.yml
66
+ ```
67
+
68
+ `.aiw/` stores the provider-neutral manifest, profile, lockfile, checkpoints, and generated working artifacts. ADRs are stored under `.context/adrs/`. The initial `ai-init` resource is rendered directly to the selected target; installed neutral package resources can be rendered through adapters to paths such as `.claude/skills`, `.cursor/rules`, or `.github/copilot-instructions.md`.
69
+
70
+ The installer activates the bundled workflow package for the selected target, including its skills, rules, agents, hooks, and templates. `ai-init` guides the agent through scanning, recommendations, user selection, synchronization, and the SDD gates. Existing conflicting target resources stop first installation with an actionable error; review or move those files before retrying. Hook resources are rendered according to each adapter's native or compatibility support.
71
+
72
+ The installer does not modify `.gitignore`. Add `.aiw/generated/` yourself if generated specifications, plans, and artifacts should remain local. Versioned files under `.aiw/checkpoints/` are designed to remain reviewable project history.
73
+
74
+ ### Installation and configuration flow
75
+
76
+ ```mermaid
77
+ flowchart TD
78
+ A[Run aiw install] --> B{Target provided?}
79
+ B -->|Yes| C[Validate selected target]
80
+ B -->|No| D[Detect installed AI tools]
81
+ D --> E{One supported target?}
82
+ E -->|Yes| C
83
+ E -->|No| F[Request or require target selection]
84
+ F --> C
85
+
86
+ C --> G[Create base directories]
87
+ G --> H[Write manifest, profile, and lock state]
88
+ H --> I[Create ADR index]
89
+ I --> J[Render ai-init through target adapter]
90
+ J --> K[Installed project]
91
+
92
+ K --> L[Run ai-init or aiw scan]
93
+ L --> M[Ignore-aware deterministic scan]
94
+ M --> N[Optional filtered AI interpretation]
95
+ N --> O[Write confirmed and inferred facts to profile.yml]
96
+ O --> P[Generate recommendations.yml]
97
+ P --> Q{User selection and confirmation}
98
+ Q -->|Accept or edit| R[Resolve packages and resources]
99
+ Q -->|Reject| S[Persist override decision]
100
+ R --> T[Update lock.yml]
101
+ T --> U[Generate project-specific resources]
102
+ U --> V[Render resources through active adapter]
103
+ V --> W[Record applicable checkpoint evidence]
104
+
105
+ K --> X[Run aiw target TARGET]
106
+ X --> Y[Dry-run and conflict review]
107
+ Y --> Z[Write migration checkpoint]
108
+ Z --> AA[Render destination resources]
109
+ AA --> AB[Update active target in manifest.yml]
110
+ AB --> AC{Rollback requested?}
111
+ AC -->|Yes| AD[Restore files and manifest from checkpoint]
112
+ AC -->|No| AE[Continue with new target]
113
+
114
+ H -. project state .-> STATE[(.aiw/*.yml)]
115
+ W -. session and validation history .-> LOGS[(.aiw/checkpoints/)]
116
+ I -. decisions index .-> ADRS[(.context/adrs/INDEX.md)]
117
+ ```
118
+
119
+ ## The SDD workflow
120
+
121
+ AI Workflow supports an end-to-end specification-driven development cycle:
122
+
123
+ ```mermaid
124
+ flowchart TD
125
+ A[Project request] --> B[Scan repository]
126
+ B --> C[(.aiw/profile.yml)]
127
+ C --> D[Recommend capabilities]
128
+ D --> E[(.aiw/recommendations.yml)]
129
+ E --> F{User confirms scope}
130
+ F -->|Revise| B
131
+ F -->|Proceed| G[Brainstorm]
132
+
133
+ G --> H[(generated/specs/brainstorm.md)]
134
+ H --> I{Brainstorm gate}
135
+ I -->|Incomplete| G
136
+ I -->|Complete| J[Write specification]
137
+
138
+ J --> K[(generated/specs/specification.md)]
139
+ K --> L{Specification gate}
140
+ L -->|Incomplete| J
141
+ L -->|Complete| M{Architecture decision needed?}
142
+
143
+ M -->|Yes| N[Create ADR]
144
+ N --> O[(.context/adrs/ADR-NNN-title.md)]
145
+ O --> P[Update ADR index]
146
+ P --> Q[(.context/adrs/INDEX.md)]
147
+ M -->|No| R[Create implementation plan]
148
+ Q --> R
149
+
150
+ R --> S[(generated/plans/implementation-plan.md)]
151
+ S --> T{Plan gate}
152
+ T -->|Incomplete| R
153
+ T -->|Ready| U[Implement tasks with TDD]
154
+
155
+ U --> V[Write code and tests]
156
+ V --> W[Run task validation commands]
157
+ W --> X{Validation passes?}
158
+ X -->|No| U
159
+ X -->|Yes| Y[Record completion evidence]
160
+
161
+ Y --> Z[(generated/artifacts and checkpoint evidence)]
162
+ Z --> AA[Verify declared evidence]
163
+ AA --> AB{Verification gate}
164
+ AB -->|Missing evidence| U
165
+ AB -->|Complete| AC[Build traceability graph]
166
+
167
+ AC --> AD[Requirement → ADR → Task → Code → Test → Evidence]
168
+ AD --> AE[(generated artifacts and trace output)]
169
+ AE --> AF[Run repository self-validation]
170
+ AF --> AG[(.aiw/checkpoints/self-validation-TICKET.yml)]
171
+ AG --> AH{Review outcome}
172
+ AH -->|Changes required| U
173
+ AH -->|Accepted| AI[Commit and independent integration validation]
174
+
175
+ B -. command history and evidence .-> LOGS[(.aiw/checkpoints/)]
176
+ D -. command history and evidence .-> LOGS
177
+ U -. implementation session evidence .-> LOGS
178
+ AI -. final validation result .-> LOGS
179
+ ```
180
+
181
+ ```bash
182
+ # Detect the repository stack, tools, scripts, and conventions.
183
+ npx @multileaf/ai-workflow scan
184
+
185
+ # Review recommendations interactively in a TTY.
186
+ npx @multileaf/ai-workflow recommend
187
+
188
+ # In CI, provide comma-separated recommendation IDs detected for that project.
189
+ npx @multileaf/ai-workflow recommend --select=typescript-quality,vitest-testing
190
+
191
+ # Create structured product artifacts.
192
+ npx @multileaf/ai-workflow brainstorm --title="Feature name"
193
+ npx @multileaf/ai-workflow spec --title="Feature requirements"
194
+ npx @multileaf/ai-workflow adr --id=001 --title="Technical decision"
195
+ npx @multileaf/ai-workflow plan --title="Implementation plan"
196
+
197
+ # Fill the generated scaffold sections before running their quality gates.
198
+ npx @multileaf/ai-workflow gate specification
199
+ npx @multileaf/ai-workflow verify
200
+ npx @multileaf/ai-workflow trace
201
+ ```
202
+
203
+ Scaffold commands write deterministic files at fixed paths and a repeated invocation replaces that scaffold. Complete and review each artifact before advancing. Requirements use stable identifiers and Given/When/Then acceptance criteria. Plans link tasks to requirements, tests, risks, dependencies, and expected evidence. `gate` performs textual completeness checks, `verify` validates the expected verification fields rather than running a test command, and `trace` records declared links between requirements, decisions, tasks, code, tests, and evidence.
204
+
205
+ ## Project intelligence
206
+
207
+ Analysis uses two complementary layers:
208
+
209
+ 1. Deterministic detectors identify observable facts such as languages, package managers, workspaces, frameworks, scripts, tests, linters, CI, and configuration files.
210
+ 2. An optional provider-neutral AI interpreter examines a filtered context to suggest architecture conventions and capabilities.
211
+
212
+ Detected facts cannot be replaced by conflicting AI output. Inferred facts remain unconfirmed until the user accepts, rejects, or edits them. Context selection excludes known sensitive filenames, binaries, dependencies, Git internals, generated output, and checkpoints, then applies pattern-based redaction. This is a defense-in-depth filter, not a general secret scanner; review eligible text before enabling an external AI provider.
213
+
214
+ ## Resource packages and recommendations
215
+
216
+ Resources are distributed as versioned packages that may contain:
217
+
218
+ - skills for repeatable workflows;
219
+ - rules for project and organization policy;
220
+ - specialist agent definitions;
221
+ - lifecycle hooks;
222
+ - artifact templates;
223
+ - dependencies, permissions, target support, and provenance metadata.
224
+
225
+ ```bash
226
+ npx @multileaf/ai-workflow registry
227
+ npx @multileaf/ai-workflow skills search --query=react
228
+
229
+ # Install locally before addressing files inside the package's node_modules path.
230
+ npm install --save-dev @multileaf/ai-workflow
231
+ npx @multileaf/ai-workflow audit-package \
232
+ --package=node_modules/@multileaf/ai-workflow/resources/package.yaml
233
+ npx @multileaf/ai-workflow resolve \
234
+ --package=node_modules/@multileaf/ai-workflow/resources/package.yaml
235
+ ```
236
+
237
+ The registry can combine local packages, configured private registries, and Vercel Skills metadata. Vercel operations invoke the external `npx skills` CLI and therefore require network access outside AI Workflow's package-permission gate. Lock entries record the provider, reported version, source, permissions, and available integrity metadata. Local package entries contain a SHA-256 digest of the manifest and declared resource bytes; upstream providers may use their own integrity format.
238
+
239
+ ## Switching AI targets
240
+
241
+ The neutral state can be rendered for another supported agent:
242
+
243
+ ```bash
244
+ npx @multileaf/ai-workflow target claude --dry-run
245
+ npx @multileaf/ai-workflow target claude
246
+ ```
247
+
248
+ Migration provides a deterministic dry-run, reports malformed neutral resources and conflicts, writes a rollback checkpoint, and handles the active `ai-init` transition. Neutral package resources are rendered to the destination adapter. It removes obsolete target files only when `.aiw/ownership.yml` proves AIW created them and their bytes are unchanged; unowned or modified files are preserved and reported. Older installations without ownership records cannot safely clean up legacy target files, so review the dry-run and resolve conflicts before migrating. If needed:
249
+
250
+ ```bash
251
+ npx @multileaf/ai-workflow rollback
252
+ ```
253
+
254
+ Use `capabilities --target=<target>` to inspect aggregate supported resource types, lifecycle events, and whether the target uses fallback compatibility. See [Adapter Model](docs/adapter-model.md) for the native and compatibility path matrix.
255
+
256
+ ## Health, recovery, and visibility
257
+
258
+ ```bash
259
+ npx @multileaf/ai-workflow status
260
+ npx @multileaf/ai-workflow doctor
261
+ npx @multileaf/ai-workflow repair
262
+ npx @multileaf/ai-workflow uninstall --dry-run
263
+ npx @multileaf/ai-workflow uninstall
264
+ npx @multileaf/ai-workflow ui
265
+ ```
266
+
267
+ Install records hashes for the neutral and target resources it creates in `.aiw/ownership.yml`. Uninstall's dry-run lists files it would remove and modified or unsafe files it would preserve. Uninstall deletes only resources whose current bytes still match the inventory, removes the migration rollback checkpoint, then removes AIW state; modified resources are preserved and reported. For older installations without an ownership inventory, uninstall refuses to delete target resources because their ownership cannot be established. The local dashboard binds only to `127.0.0.1`, reads project state from `.aiw/`, and requires the exact `MIGRATE` confirmation before changing targets. `doctor` checks the required installation structure, ownership inventory, manifest schema, and active target. `repair` recreates a defined subset of required directories and files; it does not repair arbitrary malformed profile or lock content, and a missing profile may still require reinstallation or regeneration.
268
+
269
+ ## Multi-agent orchestration
270
+
271
+ AI Workflow can preview and execute a strict, versioned task graph:
272
+
273
+ Create `orchestration.yml` using the schema in [Multi-agent Orchestration](docs/orchestration.md), then preview it:
274
+
275
+ ```bash
276
+ npx @multileaf/ai-workflow orchestrate --plan=orchestration.yml
277
+ npx @multileaf/ai-workflow orchestrate --plan=orchestration.yml --execute --max-parallel=4
278
+ ```
279
+
280
+ Preview is deterministic and read-only. Execution is opt-in and requires an application host to inject an `AgentOrchestrator`; the standalone CLI does not configure one, so its `--execute` form fails clearly until integrated by a host. Dependencies, bounded concurrency, failure propagation, replay protection, and checkpoint evidence are handled by the orchestration domain. The typed contract is exported from `@multileaf/ai-workflow/orchestration`.
281
+
282
+ ## Plugins and SDK
12
283
 
13
- ## Development
284
+ Create portable extensions without coupling them to the CLI implementation:
14
285
 
15
286
  ```bash
16
- npm install
17
- npm run build
18
- node dist/cli.js install --target codex
19
- node dist/cli.js ui
287
+ npx @multileaf/ai-workflow plugin create \
288
+ --directory=plugins/plugin-name \
289
+ --id=owner/plugin-name \
290
+ --version=1.0.0 \
291
+ --description="Provide a portable workflow."
292
+ npx @multileaf/ai-workflow plugin validate --directory=plugins/plugin-name
20
293
  ```
21
294
 
22
- The project configuration lives in `.aiw/`; target-specific files are generated by adapters.
295
+ The typed SDK is available from `@multileaf/ai-workflow/plugin-sdk`. It exports scaffold and validation helpers that accept an injected filesystem boundary. Those helpers validate project-relative paths and preflight scaffold conflicts; AI Workflow does not currently host arbitrary plugin runtime code or inject a filesystem into executing plugins. See [Plugin Authoring](docs/plugin-authoring.md).
23
296
 
24
- Telemetry is disabled by default. Use `aiw telemetry status`, `enable`, or `disable` to manage explicit privacy preferences. See [Telemetry and Privacy](docs/telemetry.md).
297
+ ## Privacy and security
298
+
299
+ Telemetry is disabled by default and requires explicit consent. It records only approved aggregate fields through an injectable transport.
300
+
301
+ ```bash
302
+ npx @multileaf/ai-workflow telemetry status
303
+ npx @multileaf/ai-workflow telemetry enable
304
+ npx @multileaf/ai-workflow telemetry disable
305
+ ```
306
+
307
+ Package contracts, declared permissions, and organization policy are validated at documented workflow boundaries, but not every external subprocess is covered by one global preflight. In particular, Vercel Skills delegates to `npx skills`, and Git sources may be checked out before their package manifest can be inspected. Treat third-party sources as untrusted and review dry-runs and package audits. Published npm releases include registry signatures and SLSA provenance that consumers can verify with `npm audit signatures`. See [Security and Trust](docs/security.md) and [Telemetry and Privacy](docs/telemetry.md).
308
+
309
+ ## Developing this repository
310
+
311
+ This project uses itself to validate its own workflow. Product changes follow TDD, pass the complete quality pipeline, run against this repository, and produce ticket-specific checkpoint evidence.
312
+
313
+ ```bash
314
+ npm ci
315
+ npm run check
316
+ node dist/cli.js self-validate --ticket=TYPE-000
317
+ ```
318
+
319
+ Release candidates additionally require:
320
+
321
+ ```bash
322
+ npm run release:check
323
+ ```
25
324
 
26
- Create portable plugins with `aiw plugin create` and validate them with `aiw plugin validate`. The typed SDK is exported from `@multileaf/ai-workflow/plugin-sdk`; see [Plugin Authoring](docs/plugin-authoring.md).
325
+ ## Documentation
27
326
 
28
- Inspect project state in the local dashboard with `aiw ui`. It binds to `127.0.0.1`, loads only `.aiw/` project state, and requires explicit confirmation before target migration.
327
+ - [Documentation index](docs/README.md)
328
+ - [Product vision](docs/product-vision.md)
329
+ - [Product requirements](docs/product-requirements.md)
330
+ - [Architecture](docs/architecture.md)
331
+ - [Project intelligence](docs/project-intelligence.md)
332
+ - [Package and resource model](docs/package-model.md)
333
+ - [Adapter model](docs/adapter-model.md)
334
+ - [Quality and testing](docs/quality.md)
335
+ - [Token efficiency](docs/token-efficiency.md)
336
+ - [Multi-agent orchestration](docs/orchestration.md)
337
+ - [Release process](docs/release-process.md)
29
338
 
30
- Preview a versioned multi-agent task graph with `aiw orchestrate --plan=orchestration.yml`. Execution is opt-in through `--execute`, uses a host-provided agent adapter, limits concurrency with `--max-parallel`, and records results under `.aiw/checkpoints/`. The scheduler and adapter contract are exported from `@multileaf/ai-workflow/orchestration`; see [Multi-agent Orchestration](docs/orchestration.md).
339
+ ## License
31
340
 
32
- Release candidates must pass `npm run release:check`. AI Workflow is available under the MIT License.
341
+ [MIT](LICENSE) © 2026 MultiLeaf
package/dist/adapter.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { ResourceType } from "./package-contract.js";
3
3
  export declare function isTarget(value: string): value is Target;
4
4
  export declare function detectTarget(root: string, fs: FileSystem): Target | undefined;
5
5
  export declare function generateAiInit(root: string, target: string, fs: FileSystem): void;
6
+ export declare function renderAiInit(target: string): string;
6
7
  export declare function renderAiInitPath(target: Target): string;
7
8
  export declare function renderResourcePath(target: Target, type: ResourceType, id: string): string;
8
9
  export type AdapterResourceType = ResourceType | "context";
package/dist/adapter.js CHANGED
@@ -21,10 +21,46 @@ export function detectTarget(root, fs) {
21
21
  return markers.find(([, marker]) => fs.exists(join(root, marker)))?.[0];
22
22
  }
23
23
  export function generateAiInit(root, target, fs) {
24
+ if (!isTarget(target))
25
+ throw new Error(`Unsupported target: ${target}`);
26
+ fs.write(join(root, renderAiInitPath(target)), renderAiInit(target));
27
+ }
28
+ export function renderAiInit(target) {
24
29
  if (!isTarget(target))
25
30
  throw new Error(`Unsupported target: ${target}`);
26
31
  getAdapterCapabilities(target);
27
- fs.write(join(root, renderAiInitPath(target)), `---\nname: ai-init\ndescription: Analyze the project and configure AI Workflow.\n---\n\n# AI Init\n\nAnalyze the repository safely and recommend project-specific capabilities.\n\n## Language Policy\n\nAll generated AI Workflow artifacts must be written in English unless the user explicitly requests another language.\n`);
32
+ return `---
33
+ name: ai-init
34
+ description: Initialize AI Workflow and run its specification-driven development setup.
35
+ ---
36
+
37
+ # AI Workflow Initialization
38
+
39
+ Set up the repository's AI-assisted development workflow. Do not stop after scanning or writing configuration: activate the installed skills, rules, agents, hooks, and templates, then guide the user through the project gates.
40
+
41
+ Analyze the repository safely, confirm uncertain facts, and recommend project-specific capabilities.
42
+
43
+ ## First-run setup
44
+
45
+ 1. Inspect the repository and existing AI instructions. Preserve user-authored files and ask before replacing conflicts.
46
+ 2. Run \`aiw scan\` and review detected facts and evidence. Confirm uncertain inferences with the user before treating them as project policy.
47
+ 3. Run \`aiw recommend\`. Explain each recommendation and its permissions, then install only the capabilities the user selects. Do not approve network or shell permissions implicitly.
48
+ 4. Run \`aiw sync\` to generate the selected project-specific resources. Resolve drift or conflicts with the user instead of overwriting them.
49
+ 5. Show the available workflow resources and explain how to use them: brainstorming → specification → architecture decision when needed → implementation plan → implementation with tests → verification → traceability → review.
50
+ 6. Before advancing each stage, run its matching \`aiw gate <stage>\`. Record validation evidence with \`aiw verify\` and link requirements, decisions, tasks, code, tests, and evidence with \`aiw trace\`.
51
+
52
+ ## For each feature request
53
+
54
+ - Start with the brainstorming skill when scope, users, constraints, or assumptions are unclear.
55
+ - Create and complete a specification with stable requirement IDs and Given/When/Then acceptance criteria; pass \`aiw gate specification\` before planning.
56
+ - Record consequential architecture choices as ADRs. Create an implementation plan that links tasks to requirements, tests, risks, and validation commands; pass \`aiw gate plan\` before coding.
57
+ - Follow the TDD policy and project quality rules. Use specialist agents for requirements, architecture, implementation, tests, security, documentation, and review when useful.
58
+ - Run the declared checks, then \`aiw verify\`, \`aiw trace\`, and the review gate. Do not claim completion without evidence.
59
+
60
+ ## Language policy
61
+
62
+ All generated AI Workflow artifacts must be written in English unless the user explicitly requests another language.
63
+ `;
28
64
  }
29
65
  export function renderAiInitPath(target) {
30
66
  const paths = {
@@ -0,0 +1,9 @@
1
+ import { type ResourceType } from "./package-contract.js";
2
+ import type { Target } from "./types.js";
3
+ export type BootstrapResource = {
4
+ type: ResourceType;
5
+ id: string;
6
+ path: string;
7
+ content: string;
8
+ };
9
+ export declare function loadBootstrapResources(target: Target): BootstrapResource[];
@@ -0,0 +1,29 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { dirname, join, relative, resolve, sep } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { renderResourcePath } from "./adapter.js";
5
+ import { RESOURCE_TYPES, validatePackageContract } from "./package-contract.js";
6
+ const resourceRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../resources");
7
+ export function loadBootstrapResources(target) {
8
+ const manifestPath = join(resourceRoot, "package.yaml");
9
+ const manifest = readFileSync(manifestPath, "utf8");
10
+ const contract = validatePackageContract(manifest, (path) => {
11
+ const candidate = resolve(resourceRoot, path);
12
+ const rel = relative(resourceRoot, candidate);
13
+ return rel !== ".." && !rel.startsWith(`..${sep}`) && existsSync(candidate);
14
+ });
15
+ if (contract.targets && !contract.targets.includes(target))
16
+ throw new Error(`The bundled workflow resources do not support target: ${target}`);
17
+ return RESOURCE_TYPES.flatMap((type) => contract.resources[type].map(({ id, path }) => {
18
+ const source = resolve(resourceRoot, path);
19
+ const rel = relative(resourceRoot, source);
20
+ if (rel === ".." || rel.startsWith(`..${sep}`))
21
+ throw new Error(`Bundled resource path escapes the package: ${path}`);
22
+ return {
23
+ type,
24
+ id,
25
+ path: renderResourcePath(target, type, id),
26
+ content: readFileSync(source, "utf8"),
27
+ };
28
+ }));
29
+ }
package/dist/constants.js CHANGED
@@ -6,5 +6,6 @@ export const BASE_DIRECTORIES = [
6
6
  "generated/docs",
7
7
  "generated/artifacts",
8
8
  "context",
9
+ "resources",
9
10
  ];
10
11
  export const INSTALL_USAGE = "aiw install [--target target] | scan | status | target <target> | validate";
package/dist/files.d.ts CHANGED
@@ -1,2 +1,12 @@
1
1
  import type { FileSystem } from "./types.js";
2
2
  export declare const nodeFileSystem: FileSystem;
3
+ export type ProjectFileWrite = {
4
+ path: string;
5
+ content: string;
6
+ };
7
+ /** Apply project containment and symlink checks to every workflow filesystem mutation. */
8
+ export declare function withSafeProjectWrites(fs: FileSystem, projectRoot: string): FileSystem;
9
+ /** Reject writes that escape the project or cross any existing/dangling symbolic link. */
10
+ export declare function assertSafeProjectPath(fs: FileSystem, projectRoot: string, destination: string): void;
11
+ /** Create a set of new project files as one rollback-capable transaction. */
12
+ export declare function writeProjectFilesAtomically(fs: FileSystem, projectRoot: string, writes: readonly ProjectFileWrite[], requiredDirectories?: readonly string[]): void;