@multileaf/ai-workflow 0.1.0 → 0.1.2

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,32 @@ All notable changes to this project are documented in this file. The format foll
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.1.2] - 2026-09-12
8
+
9
+ ### Fixed
10
+
11
+ - Keep first install limited to the `ai-init` bootstrap and neutral AI Workflow state; install optional capabilities only after the project scan and explicit user selection.
12
+ - Materialize only selected skills, rules, agents, hooks, and templates, and personalize supported rules with detected project commands.
13
+ - Allow non-interactive recommendation previews without silently selecting or installing capabilities.
14
+
15
+ ## [0.1.1] - 2026-09-12
16
+
17
+ ### Fixed
18
+
19
+ - Activate the complete bundled workflow package during installation instead of installing only `ai-init`.
20
+ - Preserve user edits during migration rollback and remove migration checkpoints during uninstall.
21
+ - Match Git ignore rules consistently when scanning projects.
22
+
23
+ ### Security
24
+
25
+ - Validate package manifests and resource paths, verify local package integrity, and redact credentials from scanned context.
26
+ - Track installed-file ownership so uninstall and migration only remove unchanged AI Workflow files.
27
+ - Require organization approval and explicit consent before loading remote package sources.
28
+
29
+ ### Changed
30
+
31
+ - Update runtime and development dependencies and expand install, migration, rollback, and security coverage.
32
+
7
33
  ## [0.1.0] - 2026-09-04
8
34
 
9
35
  ### Added
@@ -18,5 +44,7 @@ All notable changes to this project are documented in this file. The format foll
18
44
 
19
45
  - Path confinement, symlink protection, explicit permission gates, secret redaction, strict parsers, atomic migrations, and immutable execution checkpoints.
20
46
 
21
- [Unreleased]: https://github.com/MultiLeaf/aiw/compare/v0.1.0...HEAD
47
+ [Unreleased]: https://github.com/MultiLeaf/aiw/compare/v0.1.2...HEAD
48
+ [0.1.2]: https://github.com/MultiLeaf/aiw/compare/v0.1.1...v0.1.2
49
+ [0.1.1]: https://github.com/MultiLeaf/aiw/releases/tag/v0.1.1
22
50
  [0.1.0]: https://github.com/MultiLeaf/aiw/releases/tag/v0.1.0
package/README.md CHANGED
@@ -1,32 +1,335 @@
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
+ Then run `/ai-init` in Codex. The bootstrap scans the repository, explains project-specific recommendations, and waits for the user's selections before installing optional resources.
12
29
 
13
- ## Development
30
+ Supported targets are `codex`, `claude`, `cursor`, `gemini`, `copilot`, and `universal`. Every command uses the same entry point:
14
31
 
15
32
  ```bash
16
- npm install
17
- npm run build
18
- node dist/cli.js install --target codex
19
- node dist/cli.js ui
33
+ npx @multileaf/ai-workflow <command> <options>
34
+ ```
35
+
36
+ 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 bootstrap 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.
37
+
38
+ ## What gets created
39
+
40
+ For a Codex installation, the base layout is:
41
+
42
+ ```text
43
+ .agents/
44
+ └── skills/
45
+ └── ai-init/SKILL.md
46
+ .context/
47
+ └── adrs/
48
+ └── INDEX.md
49
+ .aiw/
50
+ ├── checkpoints/
51
+ ├── context/
52
+ ├── generated/
53
+ │ ├── artifacts/
54
+ │ ├── docs/
55
+ │ ├── plans/
56
+ │ └── specs/
57
+ ├── lock.yml
58
+ ├── manifest.yml
59
+ └── profile.yml
60
+ ```
61
+
62
+ `.aiw/` stores the provider-neutral manifest, profile, lockfile, checkpoints, bootstrap skill, selected resources, and generated working artifacts. ADRs are stored under `.context/adrs/`. The installer intentionally adds only `ai-init` and the base project state.
63
+
64
+ Run `/ai-init` in the selected coding agent to scan the project and review evidence-based recommendations for skills, rules, agents, hooks, and templates. AI Workflow installs only the resources the user selects, then generates project-specific quality guidance from the detected stack and tools. Existing user files are preserved; conflicts are reported instead of overwritten. Hook resources are rendered according to each adapter's native or compatibility support.
65
+
66
+ 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.
67
+
68
+ ### Installation and configuration flow
69
+
70
+ ```mermaid
71
+ flowchart TD
72
+ A[Run aiw install] --> B{Target provided?}
73
+ B -->|Yes| C[Validate selected target]
74
+ B -->|No| D[Detect installed AI tools]
75
+ D --> E{One supported target?}
76
+ E -->|Yes| C
77
+ E -->|No| F[Request or require target selection]
78
+ F --> C
79
+
80
+ C --> G[Create base directories]
81
+ G --> H[Write manifest, profile, and lock state]
82
+ H --> I[Create ADR index]
83
+ I --> J[Render ai-init through target adapter]
84
+ J --> K[Installed project]
85
+
86
+ K --> L[Run ai-init or aiw scan]
87
+ L --> M[Ignore-aware deterministic scan]
88
+ M --> N[Optional filtered AI interpretation]
89
+ N --> O[Write confirmed and inferred facts to profile.yml]
90
+ O --> P[Generate recommendations.yml]
91
+ P --> Q{User selection and confirmation}
92
+ Q -->|Accept or edit| R[Resolve packages and resources]
93
+ Q -->|Reject| S[Persist override decision]
94
+ R --> T[Update lock.yml]
95
+ T --> U[Generate project-specific resources]
96
+ U --> V[Render resources through active adapter]
97
+ V --> W[Record applicable checkpoint evidence]
98
+
99
+ K --> X[Run aiw target TARGET]
100
+ X --> Y[Dry-run and conflict review]
101
+ Y --> Z[Write migration checkpoint]
102
+ Z --> AA[Render destination resources]
103
+ AA --> AB[Update active target in manifest.yml]
104
+ AB --> AC{Rollback requested?}
105
+ AC -->|Yes| AD[Restore files and manifest from checkpoint]
106
+ AC -->|No| AE[Continue with new target]
107
+
108
+ H -. project state .-> STATE[(.aiw/*.yml)]
109
+ W -. session and validation history .-> LOGS[(.aiw/checkpoints/)]
110
+ I -. decisions index .-> ADRS[(.context/adrs/INDEX.md)]
20
111
  ```
21
112
 
22
- The project configuration lives in `.aiw/`; target-specific files are generated by adapters.
113
+ ## The SDD workflow
114
+
115
+ AI Workflow supports an end-to-end specification-driven development cycle:
116
+
117
+ ```mermaid
118
+ flowchart TD
119
+ A[Project request] --> B[Scan repository]
120
+ B --> C[(.aiw/profile.yml)]
121
+ C --> D[Recommend capabilities]
122
+ D --> E[(.aiw/recommendations.yml)]
123
+ E --> F{User confirms scope}
124
+ F -->|Revise| B
125
+ F -->|Proceed| G[Brainstorm]
126
+
127
+ G --> H[(generated/specs/brainstorm.md)]
128
+ H --> I{Brainstorm gate}
129
+ I -->|Incomplete| G
130
+ I -->|Complete| J[Write specification]
131
+
132
+ J --> K[(generated/specs/specification.md)]
133
+ K --> L{Specification gate}
134
+ L -->|Incomplete| J
135
+ L -->|Complete| M{Architecture decision needed?}
23
136
 
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).
137
+ M -->|Yes| N[Create ADR]
138
+ N --> O[(.context/adrs/ADR-NNN-title.md)]
139
+ O --> P[Update ADR index]
140
+ P --> Q[(.context/adrs/INDEX.md)]
141
+ M -->|No| R[Create implementation plan]
142
+ Q --> R
143
+
144
+ R --> S[(generated/plans/implementation-plan.md)]
145
+ S --> T{Plan gate}
146
+ T -->|Incomplete| R
147
+ T -->|Ready| U[Implement tasks with TDD]
148
+
149
+ U --> V[Write code and tests]
150
+ V --> W[Run task validation commands]
151
+ W --> X{Validation passes?}
152
+ X -->|No| U
153
+ X -->|Yes| Y[Record completion evidence]
154
+
155
+ Y --> Z[(generated/artifacts and checkpoint evidence)]
156
+ Z --> AA[Verify declared evidence]
157
+ AA --> AB{Verification gate}
158
+ AB -->|Missing evidence| U
159
+ AB -->|Complete| AC[Build traceability graph]
160
+
161
+ AC --> AD[Requirement → ADR → Task → Code → Test → Evidence]
162
+ AD --> AE[(generated artifacts and trace output)]
163
+ AE --> AF[Run repository self-validation]
164
+ AF --> AG[(.aiw/checkpoints/self-validation-TICKET.yml)]
165
+ AG --> AH{Review outcome}
166
+ AH -->|Changes required| U
167
+ AH -->|Accepted| AI[Commit and independent integration validation]
168
+
169
+ B -. command history and evidence .-> LOGS[(.aiw/checkpoints/)]
170
+ D -. command history and evidence .-> LOGS
171
+ U -. implementation session evidence .-> LOGS
172
+ AI -. final validation result .-> LOGS
173
+ ```
174
+
175
+ ```bash
176
+ # Detect the repository stack, tools, scripts, and conventions.
177
+ npx @multileaf/ai-workflow scan
178
+
179
+ # Review recommendations interactively in a TTY.
180
+ npx @multileaf/ai-workflow recommend
181
+
182
+ # In CI, provide comma-separated recommendation IDs detected for that project.
183
+ npx @multileaf/ai-workflow recommend --select=typescript-quality,vitest-testing
184
+
185
+ # Create structured product artifacts.
186
+ npx @multileaf/ai-workflow brainstorm --title="Feature name"
187
+ npx @multileaf/ai-workflow spec --title="Feature requirements"
188
+ npx @multileaf/ai-workflow adr --id=001 --title="Technical decision"
189
+ npx @multileaf/ai-workflow plan --title="Implementation plan"
190
+
191
+ # Fill the generated scaffold sections before running their quality gates.
192
+ npx @multileaf/ai-workflow gate specification
193
+ npx @multileaf/ai-workflow verify
194
+ npx @multileaf/ai-workflow trace
195
+ ```
196
+
197
+ 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.
198
+
199
+ ## Project intelligence
200
+
201
+ Analysis uses two complementary layers:
202
+
203
+ 1. Deterministic detectors identify observable facts such as languages, package managers, workspaces, frameworks, scripts, tests, linters, CI, and configuration files.
204
+ 2. An optional provider-neutral AI interpreter examines a filtered context to suggest architecture conventions and capabilities.
205
+
206
+ 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.
207
+
208
+ ## Resource packages and recommendations
209
+
210
+ Resources are distributed as versioned packages that may contain:
211
+
212
+ - skills for repeatable workflows;
213
+ - rules for project and organization policy;
214
+ - specialist agent definitions;
215
+ - lifecycle hooks;
216
+ - artifact templates;
217
+ - dependencies, permissions, target support, and provenance metadata.
218
+
219
+ ```bash
220
+ npx @multileaf/ai-workflow registry
221
+ npx @multileaf/ai-workflow skills search --query=react
222
+
223
+ # Install locally before addressing files inside the package's node_modules path.
224
+ npm install --save-dev @multileaf/ai-workflow
225
+ npx @multileaf/ai-workflow audit-package \
226
+ --package=node_modules/@multileaf/ai-workflow/resources/package.yaml
227
+ npx @multileaf/ai-workflow resolve \
228
+ --package=node_modules/@multileaf/ai-workflow/resources/package.yaml
229
+ ```
230
+
231
+ 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.
232
+
233
+ ## Switching AI targets
234
+
235
+ The neutral state can be rendered for another supported agent:
236
+
237
+ ```bash
238
+ npx @multileaf/ai-workflow target claude --dry-run
239
+ npx @multileaf/ai-workflow target claude
240
+ ```
241
+
242
+ 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:
243
+
244
+ ```bash
245
+ npx @multileaf/ai-workflow rollback
246
+ ```
247
+
248
+ 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.
249
+
250
+ ## Health, recovery, and visibility
251
+
252
+ ```bash
253
+ npx @multileaf/ai-workflow status
254
+ npx @multileaf/ai-workflow doctor
255
+ npx @multileaf/ai-workflow repair
256
+ npx @multileaf/ai-workflow uninstall --dry-run
257
+ npx @multileaf/ai-workflow uninstall
258
+ npx @multileaf/ai-workflow ui
259
+ ```
260
+
261
+ 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.
262
+
263
+ ## Multi-agent orchestration
264
+
265
+ AI Workflow can preview and execute a strict, versioned task graph:
266
+
267
+ Create `orchestration.yml` using the schema in [Multi-agent Orchestration](docs/orchestration.md), then preview it:
268
+
269
+ ```bash
270
+ npx @multileaf/ai-workflow orchestrate --plan=orchestration.yml
271
+ npx @multileaf/ai-workflow orchestrate --plan=orchestration.yml --execute --max-parallel=4
272
+ ```
273
+
274
+ 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`.
275
+
276
+ ## Plugins and SDK
277
+
278
+ Create portable extensions without coupling them to the CLI implementation:
279
+
280
+ ```bash
281
+ npx @multileaf/ai-workflow plugin create \
282
+ --directory=plugins/plugin-name \
283
+ --id=owner/plugin-name \
284
+ --version=1.0.0 \
285
+ --description="Provide a portable workflow."
286
+ npx @multileaf/ai-workflow plugin validate --directory=plugins/plugin-name
287
+ ```
288
+
289
+ 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).
290
+
291
+ ## Privacy and security
292
+
293
+ Telemetry is disabled by default and requires explicit consent. It records only approved aggregate fields through an injectable transport.
294
+
295
+ ```bash
296
+ npx @multileaf/ai-workflow telemetry status
297
+ npx @multileaf/ai-workflow telemetry enable
298
+ npx @multileaf/ai-workflow telemetry disable
299
+ ```
300
+
301
+ 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).
302
+
303
+ ## Developing this repository
304
+
305
+ 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.
306
+
307
+ ```bash
308
+ npm ci
309
+ npm run check
310
+ node dist/cli.js self-validate --ticket=TYPE-000
311
+ ```
312
+
313
+ Release candidates additionally require:
314
+
315
+ ```bash
316
+ npm run release:check
317
+ ```
25
318
 
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).
319
+ ## Documentation
27
320
 
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.
321
+ - [Documentation index](docs/README.md)
322
+ - [Product vision](docs/product-vision.md)
323
+ - [Product requirements](docs/product-requirements.md)
324
+ - [Architecture](docs/architecture.md)
325
+ - [Project intelligence](docs/project-intelligence.md)
326
+ - [Package and resource model](docs/package-model.md)
327
+ - [Adapter model](docs/adapter-model.md)
328
+ - [Quality and testing](docs/quality.md)
329
+ - [Token efficiency](docs/token-efficiency.md)
330
+ - [Multi-agent orchestration](docs/orchestration.md)
331
+ - [Release process](docs/release-process.md)
29
332
 
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).
333
+ ## License
31
334
 
32
- Release candidates must pass `npm run release:check`. AI Workflow is available under the MIT License.
335
+ [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
+ This skill is the bootstrap for AI Workflow. The installer intentionally installs only this skill and the provider-neutral project state. Do not copy or activate the full resource package automatically.
40
+
41
+ ## First-run setup
42
+
43
+ 1. Inspect the repository's existing AI instructions and project structure. Preserve user-authored files and do not expose secrets.
44
+ 2. Run \`aiw scan\`. Explain the detected facts and their evidence; ask the user to confirm uncertain inferences before they influence generated content.
45
+ 3. Run \`aiw recommend\`, then read \`.aiw/recommendations.yml\` and \`.aiw/profile.yml\`. Explain why each suggested skill, rule, agent, hook, or template fits and identify external permissions. Ask which capabilities to install, and ask separately before granting an external permission such as \`network:external\`.
46
+ 4. Record the user's choices with \`aiw recommend --select=id,id\`; use \`aiw recommend --select=\` when all recommendations are declined. If at least one capability is selected, run \`aiw sync\`; when the user separately approved external network access, pass \`--allow=network:external\`. Sync installs only selected resources and fills supported project rules with detected stack and quality-tool details. Do not add unselected resources or overwrite existing files.
47
+ 5. Review the installed resource list and the generated project-specific files with the user. Ask before changing project policy or tailoring any other skill/rule.
48
+ 6. Introduce the selected workflow gates: brainstorming → specification → architecture decision when needed → implementation plan → implementation with tests → verification → traceability → review. Use only gates supported by the resources the user chose.
49
+
50
+ If the user declines all recommendations, leave the project with only the bootstrap skill and scan state. Do not treat scanning or recommendation as consent to install.
51
+
52
+ ## For each feature request after setup
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 loadBundledResources(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 loadBundledResources(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;