@multileaf/ai-workflow 0.16.0 → 0.17.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.
- package/CHANGELOG.md +12 -0
- package/README.md +8 -1
- package/dist/blocking-reasons.d.ts +1 -1
- package/dist/blocking-reasons.js +6 -0
- package/dist/recommendations.js +11 -0
- package/dist/update.d.ts +42 -0
- package/dist/update.js +89 -0
- package/dist/workflow.js +112 -4
- package/docs/backlog.md +8 -0
- package/docs/continuation-inventory.md +24 -23
- package/package.json +1 -1
- package/resources/package.yaml +1 -0
- package/resources/skills/research.md +64 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ All notable changes to this project are documented in this file. The format foll
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.17.0] - 2026-11-27
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Bounded `research` skill (RES-001): evidence-first, budget-capped investigations from a single question — scope gate with human confirmation, stop conditions and escalation, verifiable citations (`file:line` / log line / URL + consultation date) with fact/hypothesis/unverified states, secret redaction before host-side external queries, and a durable workflow-scoped `research.md` artifact recorded through light-lane evidence. Offered as the advisory `bounded-research` recommendation; covered by the packaged-skill eval contracts.
|
|
12
|
+
- Bundled-resource update command (UPD-001): `aiw update [--dry-run] [--add=type/id,...]` diffs installed resources against the CLI's catalog (updated/new/unchanged), replaces only files whose ownership checksum proves they are unmodified (manual edits are preserved as typed `update_conflict` blocks with continuations), installs catalog resources additively via `--add` without re-running the recommendation wizard, and is non-interactive, deterministic, and idempotent.
|
|
13
|
+
- `aiw adr` now defaults to monotonic unix-time (millisecond) ids — chronological, collision-resistant numbering for parallel or rapid ADR creation; explicit `--id=` is unchanged.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- Blocking errors from the new update flow are returned as typed results like every other blocking path (latent `return` vs `return await` in the update branch).
|
|
18
|
+
|
|
7
19
|
## [0.16.0] - 2026-11-18
|
|
8
20
|
|
|
9
21
|
### Added
|
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ For a Codex installation, the base layout is:
|
|
|
64
64
|
|
|
65
65
|
`.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.
|
|
66
66
|
|
|
67
|
-
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. Syncing a non-empty selection also renders a root context file for the active target — `AGENTS.md` (Codex/Cursor), `CLAUDE.md` (Claude Code), `GEMINI.md` (Gemini CLI) — with the confirmed profile, quality commands, and pointers to `.aiw/` state; `aiw target` migrates it between targets. An existing hand-written root context file is reported as a conflict and never overwritten. Existing user files are preserved; conflicts are reported instead of overwritten. Hook resources are rendered according to each adapter's native or compatibility support.
|
|
67
|
+
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. Among the packaged skills, `research` runs a bounded, evidence-first investigation from a single question (logs, errors, code, or host-side external sources) and records a durable workflow-scoped artifact for later stages. Syncing a non-empty selection also renders a root context file for the active target — `AGENTS.md` (Codex/Cursor), `CLAUDE.md` (Claude Code), `GEMINI.md` (Gemini CLI) — with the confirmed profile, quality commands, and pointers to `.aiw/` state; `aiw target` migrates it between targets. An existing hand-written root context file is reported as a conflict and never overwritten. Existing user files are preserved; conflicts are reported instead of overwritten. Hook resources are rendered according to each adapter's native or compatibility support.
|
|
68
68
|
|
|
69
69
|
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.
|
|
70
70
|
|
|
@@ -203,6 +203,13 @@ npx @multileaf/ai-workflow recommend
|
|
|
203
203
|
# In CI, provide comma-separated recommendation IDs detected for that project.
|
|
204
204
|
npx @multileaf/ai-workflow recommend --select=typescript-quality,verification
|
|
205
205
|
|
|
206
|
+
# Bring installed bundled resources to the current CLI version, drift-safe
|
|
207
|
+
# (manual edits are preserved as conflicts), and add catalog resources
|
|
208
|
+
# additively without re-running the recommendation wizard.
|
|
209
|
+
npx @multileaf/ai-workflow update --dry-run
|
|
210
|
+
npx @multileaf/ai-workflow update
|
|
211
|
+
npx @multileaf/ai-workflow update --add=skills/research
|
|
212
|
+
|
|
206
213
|
# Track a feature from its first artifact through final human approval.
|
|
207
214
|
npx @multileaf/ai-workflow workflow start
|
|
208
215
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* command resolves the block it was printed for. See ADR-001 and
|
|
8
8
|
* docs/opportunities/OPP-004-exact-continuation-commands.md.
|
|
9
9
|
*/
|
|
10
|
-
export declare const BLOCKING_REASON_CODES: readonly ["gate_evidence_missing", "gate_incomplete", "stage_prerequisite_pending", "stage_prerequisite_unresolved", "stage_awaiting_approval", "stage_already_approved", "approval_evidence_missing", "approval_stale", "approval_gate_missing", "lane_escalation_required", "light_evidence_missing", "workflow_still_active", "workflow_not_active", "workflow_complete", "installation_required", "state_mismatch", "context_budget_exceeded", "stage_not_in_process", "migration_required", "worktrees_leaked", "orchestration_not_executed"];
|
|
10
|
+
export declare const BLOCKING_REASON_CODES: readonly ["gate_evidence_missing", "gate_incomplete", "stage_prerequisite_pending", "stage_prerequisite_unresolved", "stage_awaiting_approval", "stage_already_approved", "approval_evidence_missing", "approval_stale", "approval_gate_missing", "lane_escalation_required", "light_evidence_missing", "workflow_still_active", "workflow_not_active", "workflow_complete", "installation_required", "state_mismatch", "context_budget_exceeded", "stage_not_in_process", "migration_required", "worktrees_leaked", "orchestration_not_executed", "update_conflict"];
|
|
11
11
|
export type BlockingReasonCode = (typeof BLOCKING_REASON_CODES)[number];
|
|
12
12
|
/** How the user or agent gets past a block. Exactly one of three kinds. */
|
|
13
13
|
export type BlockingContinuation =
|
package/dist/blocking-reasons.js
CHANGED
|
@@ -29,6 +29,7 @@ export const BLOCKING_REASON_CODES = [
|
|
|
29
29
|
"migration_required",
|
|
30
30
|
"worktrees_leaked",
|
|
31
31
|
"orchestration_not_executed",
|
|
32
|
+
"update_conflict",
|
|
32
33
|
];
|
|
33
34
|
function command(commandText) {
|
|
34
35
|
return { kind: "command", command: commandText };
|
|
@@ -172,6 +173,11 @@ export const BLOCKING_REASON_INVENTORY = {
|
|
|
172
173
|
description: "The plan has not been executed yet; there is no checkpoint to integrate.",
|
|
173
174
|
continuation: () => action("Run `aiw orchestrate --plan=<path> --execute` first; integration forecasts need the checkpoint evidence."),
|
|
174
175
|
},
|
|
176
|
+
update_conflict: {
|
|
177
|
+
code: "update_conflict",
|
|
178
|
+
description: "Manually edited installed resources conflict with a bundled update; they are preserved, never overwritten.",
|
|
179
|
+
continuation: (context) => action(`Review the conflicted file(s)${context.detail ? ` (${context.detail})` : ""}, port your edits onto the new version manually or discard them, then rerun \`aiw update\`.`),
|
|
180
|
+
},
|
|
175
181
|
};
|
|
176
182
|
export function getBlockingReasonDefinition(code) {
|
|
177
183
|
const definition = BLOCKING_REASON_INVENTORY[code];
|
package/dist/recommendations.js
CHANGED
|
@@ -29,6 +29,17 @@ const CATALOG = [
|
|
|
29
29
|
? { evidence: projectEvidence(profile), confidence: 0.9 }
|
|
30
30
|
: undefined,
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
id: "bounded-research",
|
|
34
|
+
provider: "multileaf",
|
|
35
|
+
universal: true,
|
|
36
|
+
rationale: "Investigations that start from a single question (an error, a log signature, a migration implication) benefit from an evidence-first, budget-capped research contract with a durable artifact for later stages.",
|
|
37
|
+
permissions: [],
|
|
38
|
+
resources: local([{ type: "skills", id: "research" }]),
|
|
39
|
+
matches: (profile) => hasProjectSignals(profile)
|
|
40
|
+
? { evidence: projectEvidence(profile), confidence: 0.85 }
|
|
41
|
+
: undefined,
|
|
42
|
+
},
|
|
32
43
|
{
|
|
33
44
|
id: "requirements-specification",
|
|
34
45
|
provider: "multileaf",
|
package/dist/update.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { FileSystem } from "./types.js";
|
|
2
|
+
import type { Target } from "./types.js";
|
|
3
|
+
import { type OwnedFile } from "./ownership.js";
|
|
4
|
+
export type UpdatePlan = {
|
|
5
|
+
updated: {
|
|
6
|
+
path: string;
|
|
7
|
+
content: string;
|
|
8
|
+
}[];
|
|
9
|
+
conflicts: string[];
|
|
10
|
+
newIds: string[];
|
|
11
|
+
unchanged: number;
|
|
12
|
+
install: {
|
|
13
|
+
type: string;
|
|
14
|
+
id: string;
|
|
15
|
+
content: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
export type UpdatePlanInput = {
|
|
19
|
+
fs: FileSystem;
|
|
20
|
+
root: string;
|
|
21
|
+
aiw: string;
|
|
22
|
+
target: Target;
|
|
23
|
+
add: string[];
|
|
24
|
+
/** Catalog contents by `type/id` (injected for tests; defaults to the bundled package). */
|
|
25
|
+
bundle?: Map<string, {
|
|
26
|
+
type: string;
|
|
27
|
+
id: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}>;
|
|
30
|
+
/** Personalizer for desired bytes (defaults to the raw catalog content). */
|
|
31
|
+
personalize?: (type: string, id: string, content: string) => string;
|
|
32
|
+
/** Render path resolver per target (defaults to bundled path mapping). */
|
|
33
|
+
renderPath?: (type: string, id: string, target: Target) => string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* UPD-001: diff installed bundled resources against the catalog using the
|
|
37
|
+
* ownership checksum as the drift oracle. `--add` ids are validated against
|
|
38
|
+
* the catalog and appended additively.
|
|
39
|
+
*/
|
|
40
|
+
export declare function computeUpdatePlan(input: UpdatePlanInput): UpdatePlan;
|
|
41
|
+
/** Refreshed ownership entries after applying an update (checksums recomputed). */
|
|
42
|
+
export declare function refreshOwnershipChecksums(owned: OwnedFile[], fs: FileSystem, root: string): OwnedFile[];
|
package/dist/update.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import { parseOwnership, createOwnedFile } from "./ownership.js";
|
|
3
|
+
import { loadBundledResources } from "./bundled-resources.js";
|
|
4
|
+
import { checksumPackage } from "./package-integrity.js";
|
|
5
|
+
import { resourcesForCapabilities } from "./recommendations.js";
|
|
6
|
+
/**
|
|
7
|
+
* UPD-001: diff installed bundled resources against the catalog using the
|
|
8
|
+
* ownership checksum as the drift oracle. `--add` ids are validated against
|
|
9
|
+
* the catalog and appended additively.
|
|
10
|
+
*/
|
|
11
|
+
export function computeUpdatePlan(input) {
|
|
12
|
+
const { fs, root, aiw, target, add } = input;
|
|
13
|
+
const ownershipPath = join(aiw, "ownership.yml");
|
|
14
|
+
const owned = fs.exists(ownershipPath) ? parseOwnership(fs.read(ownershipPath)) : [];
|
|
15
|
+
const bundle = input.bundle ?? new Map(loadBundledResources(target).map((r) => [`${r.type}/${r.id}`, r]));
|
|
16
|
+
const personalize = input.personalize ?? ((_t, _i, content) => content);
|
|
17
|
+
// Unknown --add ids fail closed with the available ids.
|
|
18
|
+
const catalogResourceIds = [...bundle.keys()];
|
|
19
|
+
const catalogCapabilityResources = new Set(resourcesForCapabilities([...catalogResourceIds]).map((r) => `${r.type}/${r.id}`));
|
|
20
|
+
const addKeys = add.map((id) => (id.includes("/") ? id : capabilityResourceKey(id, bundle)));
|
|
21
|
+
for (const key of addKeys)
|
|
22
|
+
if (!bundle.has(key) && !catalogCapabilityResources.has(key))
|
|
23
|
+
throw new Error(`Unknown resource id: ${key}. Available: ${catalogResourceIds.sort().join(", ")}`);
|
|
24
|
+
const installedKeys = new Set();
|
|
25
|
+
const conflicts = [];
|
|
26
|
+
const updated = [];
|
|
27
|
+
let unchanged = 0;
|
|
28
|
+
for (const file of owned) {
|
|
29
|
+
if (file.resourceType === undefined || file.resourceId === undefined) {
|
|
30
|
+
unchanged += 1; // supporting/legacy entries are never touched by update
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const key = `${file.resourceType}/${file.resourceId}`;
|
|
34
|
+
installedKeys.add(key);
|
|
35
|
+
const resource = bundle.get(key);
|
|
36
|
+
if (!resource) {
|
|
37
|
+
unchanged += 1; // resource no longer in the catalog: leave untouched
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const filePath = join(root, file.path);
|
|
41
|
+
if (!fs.exists(filePath)) {
|
|
42
|
+
unchanged += 1;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const bytes = fs.read(filePath);
|
|
46
|
+
const drifted = `sha256-${checksumPackage(bytes)}` !== file.checksum;
|
|
47
|
+
if (drifted) {
|
|
48
|
+
conflicts.push(file.path);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const desired = personalize(resource.type, resource.id, resource.content);
|
|
52
|
+
if (desired === bytes)
|
|
53
|
+
unchanged += 1;
|
|
54
|
+
else
|
|
55
|
+
updated.push({ path: file.path, content: desired });
|
|
56
|
+
}
|
|
57
|
+
const newIds = [];
|
|
58
|
+
const install = [];
|
|
59
|
+
for (const key of catalogResourceIds) {
|
|
60
|
+
const [type, id] = key.split("/");
|
|
61
|
+
if (installedKeys.has(key))
|
|
62
|
+
continue;
|
|
63
|
+
newIds.push(key);
|
|
64
|
+
if (addKeys.includes(key))
|
|
65
|
+
install.push({ type, id, content: personalize(type, id, bundle.get(key).content) });
|
|
66
|
+
}
|
|
67
|
+
return { updated, conflicts, newIds, unchanged, install };
|
|
68
|
+
}
|
|
69
|
+
function capabilityResourceKey(capabilityId, bundle) {
|
|
70
|
+
const resources = resourcesForCapabilities([capabilityId]);
|
|
71
|
+
for (const resource of resources)
|
|
72
|
+
if (bundle.has(`${resource.type}/${resource.id}`))
|
|
73
|
+
return `${resource.type}/${resource.id}`;
|
|
74
|
+
return capabilityId;
|
|
75
|
+
}
|
|
76
|
+
/** Refreshed ownership entries after applying an update (checksums recomputed). */
|
|
77
|
+
export function refreshOwnershipChecksums(owned, fs, root) {
|
|
78
|
+
return owned.map((file) => {
|
|
79
|
+
const filePath = join(root, file.path);
|
|
80
|
+
if (!fs.exists(filePath))
|
|
81
|
+
return file;
|
|
82
|
+
return createOwnedFile(file.path, fs.read(filePath), {
|
|
83
|
+
kind: file.kind,
|
|
84
|
+
target: file.target,
|
|
85
|
+
resourceType: file.resourceType,
|
|
86
|
+
resourceId: file.resourceId,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
package/dist/workflow.js
CHANGED
|
@@ -4,6 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { BASE_DIRECTORIES, WORKFLOW_DIRECTORY } from "./constants.js";
|
|
6
6
|
import { detectTarget, isTarget, renderAiInit, describeResource, renderAiInitPath, renderResourcePath, } from "./adapter.js";
|
|
7
|
+
import { computeUpdatePlan } from "./update.js";
|
|
7
8
|
import { loadBundledResources } from "./bundled-resources.js";
|
|
8
9
|
import { assertSafeProjectPath, withSafeProjectWrites, writeProjectFilesAtomically, } from "./files.js";
|
|
9
10
|
import { parseProjectProfile, profileProject } from "./profile.js";
|
|
@@ -178,6 +179,102 @@ async function writeCompletionReport(fs, aiw, session, ledger) {
|
|
|
178
179
|
}
|
|
179
180
|
return report.consoleSummary;
|
|
180
181
|
}
|
|
182
|
+
/** Monotonic ADR unix-time stamp (distinct ids within the same millisecond). */
|
|
183
|
+
let adrLastStamp = 0;
|
|
184
|
+
/** UPD-001: bundled-resource update — diff, drift-safe apply, additive --add. */
|
|
185
|
+
async function runBundledUpdate(args, root, fs, aiw, services) {
|
|
186
|
+
const dryRun = args.includes("--dry-run");
|
|
187
|
+
const addArg = args.find((argument) => argument.startsWith("--add="))?.slice(6);
|
|
188
|
+
const add = addArg
|
|
189
|
+
? addArg
|
|
190
|
+
.split(",")
|
|
191
|
+
.map((id) => id.trim())
|
|
192
|
+
.filter(Boolean)
|
|
193
|
+
: [];
|
|
194
|
+
if (args.some((argument) => argument.startsWith("--") &&
|
|
195
|
+
!["--dry-run", "--add", "--json"].some((allowed) => argument === allowed || argument.startsWith(`${allowed}=`))))
|
|
196
|
+
return {
|
|
197
|
+
exitCode: 1,
|
|
198
|
+
error: "Usage: aiw update [--dry-run] [--add=type/id,...] | aiw update --package=path --target=target",
|
|
199
|
+
};
|
|
200
|
+
const target = parseManifest(fs.read(join(aiw, "manifest.yml"))).target.active;
|
|
201
|
+
const profilePath = join(aiw, "profile.yml");
|
|
202
|
+
const profile = /^status:\s*scanned$/m.test(fs.exists(profilePath) ? fs.read(profilePath) : "")
|
|
203
|
+
? parseProjectProfile(fs.read(profilePath))
|
|
204
|
+
: await (services.profiler?.profile(root) ?? profileProject(root));
|
|
205
|
+
const personalize = (type, id, content) => personalizeBundledResource(type, id, content, profile);
|
|
206
|
+
let plan;
|
|
207
|
+
try {
|
|
208
|
+
plan = computeUpdatePlan({ fs, root, aiw, target, add, personalize });
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
212
|
+
}
|
|
213
|
+
const lines = [
|
|
214
|
+
`updated: ${plan.updated.length}${plan.updated.map((entry) => `\n - ${entry.path}`).join("")}`,
|
|
215
|
+
`new available: ${plan.newIds.length}${plan.newIds.length ? ` (${plan.newIds.slice(0, 12).join(", ")}${plan.newIds.length > 12 ? ", …" : ""})` : ""}`,
|
|
216
|
+
`unchanged: ${plan.unchanged}`,
|
|
217
|
+
plan.conflicts.length ? `conflicts (preserved): ${plan.conflicts.join(", ")}` : "",
|
|
218
|
+
plan.install.length
|
|
219
|
+
? `installing: ${plan.install.map((r) => `${r.type}/${r.id}`).join(", ")}`
|
|
220
|
+
: "",
|
|
221
|
+
].filter(Boolean);
|
|
222
|
+
if (dryRun)
|
|
223
|
+
return { exitCode: 0, output: lines.join("\n") };
|
|
224
|
+
if (plan.conflicts.length)
|
|
225
|
+
throw new BlockingError(describeBlockingReason("update_conflict", {
|
|
226
|
+
detail: plan.conflicts.join(", "),
|
|
227
|
+
}));
|
|
228
|
+
// Drift-safe apply: replace unmodified files, refresh their checksums.
|
|
229
|
+
for (const entry of plan.updated)
|
|
230
|
+
fs.write(join(root, entry.path), entry.content);
|
|
231
|
+
const ownershipPath = join(aiw, "ownership.yml");
|
|
232
|
+
const owned = parseOwnership(fs.read(ownershipPath));
|
|
233
|
+
const updatedPaths = new Set(plan.updated.map((entry) => entry.path));
|
|
234
|
+
const nextOwned = owned.map((file) => updatedPaths.has(file.path)
|
|
235
|
+
? createOwnedFile(file.path, fs.read(join(root, file.path)), {
|
|
236
|
+
kind: file.kind,
|
|
237
|
+
target: file.target,
|
|
238
|
+
resourceType: file.resourceType,
|
|
239
|
+
resourceId: file.resourceId,
|
|
240
|
+
})
|
|
241
|
+
: file);
|
|
242
|
+
// Additive --add: render new resources and register ownership.
|
|
243
|
+
for (const resource of plan.install) {
|
|
244
|
+
const type = resource.type;
|
|
245
|
+
const neutralPath = renderResourcePath("universal", type, resource.id);
|
|
246
|
+
const targetPath = renderResourcePath(target, type, resource.id);
|
|
247
|
+
fs.write(join(root, neutralPath), resource.content);
|
|
248
|
+
nextOwned.push(createOwnedFile(neutralPath, resource.content, {
|
|
249
|
+
kind: "neutral-resource",
|
|
250
|
+
target: "universal",
|
|
251
|
+
resourceType: type,
|
|
252
|
+
resourceId: resource.id,
|
|
253
|
+
}));
|
|
254
|
+
if (targetPath !== neutralPath) {
|
|
255
|
+
fs.write(join(root, targetPath), resource.content);
|
|
256
|
+
nextOwned.push(createOwnedFile(targetPath, resource.content, {
|
|
257
|
+
kind: "target-resource",
|
|
258
|
+
target,
|
|
259
|
+
resourceType: type,
|
|
260
|
+
resourceId: resource.id,
|
|
261
|
+
}));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
fs.write(ownershipPath, serializeOwnership(nextOwned));
|
|
265
|
+
if (plan.install.length) {
|
|
266
|
+
// Record the additive selection so future syncs keep the added resources.
|
|
267
|
+
const recommendations = services.recommender?.recommend(profile) ?? recommendCapabilities(profile);
|
|
268
|
+
const previousSelection = readSelectedRecommendations(fs, aiw);
|
|
269
|
+
const selection = [...new Set([...previousSelection, ...add])];
|
|
270
|
+
fs.write(join(aiw, "recommendations.yml"), serializeRecommendations(recommendations, selection));
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
exitCode: 0,
|
|
274
|
+
output: lines.join("\n") +
|
|
275
|
+
`\nUpdate applied${plan.install.length ? "" : " (no new resources installed; use --add=type/id to install)"}.`,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
181
278
|
function beginWorkflowSession(fs, aiw, options) {
|
|
182
279
|
const sessionPath = join(aiw, "workflow.yml");
|
|
183
280
|
const ledgerPath = join(aiw, "approvals.yml");
|
|
@@ -2467,9 +2564,20 @@ export async function runCommand(args, root, fs, services = {}) {
|
|
|
2467
2564
|
if (!fs.exists(join(aiw, "manifest.yml")))
|
|
2468
2565
|
return installationRequired();
|
|
2469
2566
|
assertStageReady(aiw, fs, "technical-design");
|
|
2470
|
-
const
|
|
2567
|
+
const explicitId = args.find((arg) => arg.startsWith("--id="))?.slice(5);
|
|
2471
2568
|
const title = args.find((arg) => arg.startsWith("--title="))?.slice(8) || "Untitled Decision";
|
|
2472
|
-
|
|
2569
|
+
// Unix-time (ms) default: chronological sequence, collision-resistant.
|
|
2570
|
+
// A monotonic guard guarantees distinct ids even within the same
|
|
2571
|
+
// millisecond; same-ms creations bump until the path is free.
|
|
2572
|
+
const slug = title.toLowerCase().replaceAll(" ", "-");
|
|
2573
|
+
adrLastStamp = Math.max(adrLastStamp + 1, Date.now());
|
|
2574
|
+
let stamp = adrLastStamp;
|
|
2575
|
+
if (!explicitId)
|
|
2576
|
+
while (fs.exists(join(root, ".context/adrs", `ADR-${stamp}-${slug}.md`)))
|
|
2577
|
+
stamp += 1;
|
|
2578
|
+
adrLastStamp = stamp;
|
|
2579
|
+
const id = explicitId ?? String(stamp);
|
|
2580
|
+
const path = join(root, ".context/adrs", `ADR-${id}-${slug}.md`);
|
|
2473
2581
|
fs.write(path, `# ADR-${id}: ${title}\n\n- **Status:** proposed\n- **Related artifacts:**\n - .aiw/generated/specs/\n\n## Context\n\n## Alternatives\n\n1. **Alternative A** — Description and trade-offs.\n2. **Alternative B** — Description and trade-offs.\n\n## Decision\n\n## Rationale\n\n## Consequences\n\n`);
|
|
2474
2582
|
return { exitCode: 0, output: `Architecture decision record created: ${path}` };
|
|
2475
2583
|
}
|
|
@@ -2964,7 +3072,7 @@ export async function runCommand(args, root, fs, services = {}) {
|
|
|
2964
3072
|
return installationRequired();
|
|
2965
3073
|
const packageArg = args.find((arg) => arg.startsWith("--package="));
|
|
2966
3074
|
if (!packageArg)
|
|
2967
|
-
return
|
|
3075
|
+
return await runBundledUpdate(args, root, fs, aiw, services);
|
|
2968
3076
|
const manifestPath = resolve(root, packageArg.slice(10));
|
|
2969
3077
|
const manifestBytes = fs.readBytes?.(manifestPath);
|
|
2970
3078
|
const manifestContent = manifestBytes
|
|
@@ -3598,7 +3706,7 @@ export async function runCommand(args, root, fs, services = {}) {
|
|
|
3598
3706
|
}
|
|
3599
3707
|
return {
|
|
3600
3708
|
exitCode: 0,
|
|
3601
|
-
output: "aiw install [--target target] | workflow <start|status|complete> [--id=id] | task <start|status> --ticket=TEAM-123 [--title=text] | approve <stage> | reject <stage> --reason=text | skip <optional-stage> --reason=text | ui [--port=number] | orchestrate --plan=path [--execute] [--max-parallel=number] | telemetry <status|show|enable|disable> [privacy options] | plugin <create|validate> [options] | scan | semantic <status|query> | decision <status|triage> | self-validate --ticket=TYPE-000 | organization-policy --file=path [--replace] | policy-check --package=path [--package=path] | preset --file=path [--replace] | context | context-summary | context-quality | capabilities [--target=target] | token-usage [--stage=name --budget=number --used=number] | registry [--search=query] [--private=name] | registry configure --file=path [--replace] | skills <search|inspect|install|check|update> [options] | audit-package --package=path | verify-package --package=path --checksum=sha256 | brainstorm [--title=title] | spec [--title=title] | adr [--id=id --title=title] | plan [--title=title] | verify | trace | gate <stage> | standards <extract|list|confirm|reject> | recommend [--select=id,id] | eval run --scenarios [--registry=dir] [--harness=id] [--filter=id] [--advisory] | status | doctor | repair | uninstall [--dry-run] | target <target> | rollback | confirm | resolve --package=path | update --package=path --target=target | validate [--package=path]",
|
|
3709
|
+
output: "aiw install [--target target] | workflow <start|status|complete> [--id=id] | task <start|status> --ticket=TEAM-123 [--title=text] | approve <stage> | reject <stage> --reason=text | skip <optional-stage> --reason=text | ui [--port=number] | orchestrate --plan=path [--execute] [--max-parallel=number] | telemetry <status|show|enable|disable> [privacy options] | plugin <create|validate> [options] | scan | semantic <status|query> | decision <status|triage> | self-validate --ticket=TYPE-000 | organization-policy --file=path [--replace] | policy-check --package=path [--package=path] | preset --file=path [--replace] | context | context-summary | context-quality | capabilities [--target=target] | token-usage [--stage=name --budget=number --used=number] | registry [--search=query] [--private=name] | registry configure --file=path [--replace] | skills <search|inspect|install|check|update> [options] | audit-package --package=path | verify-package --package=path --checksum=sha256 | brainstorm [--title=title] | spec [--title=title] | adr [--id=id --title=title] | plan [--title=title] | verify | trace | gate <stage> | standards <extract|list|confirm|reject> | recommend [--select=id,id] | eval run --scenarios [--registry=dir] [--harness=id] [--filter=id] [--advisory] | status | doctor | repair | uninstall [--dry-run] | target <target> | rollback | confirm | resolve --package=path | update [--dry-run] [--add=type/id,...] | update --package=path --target=target | validate [--package=path]",
|
|
3602
3710
|
};
|
|
3603
3711
|
}
|
|
3604
3712
|
catch (error) {
|
package/docs/backlog.md
CHANGED
|
@@ -142,6 +142,14 @@ Findings from using AIW on this repository (post-0.15 dogfooding review).
|
|
|
142
142
|
- [x] **FRIC-004** Offer telemetry opt-in during install/doctor instead of silent default-off. _Acceptance:_ interactive install and `aiw doctor` prompt once to enable telemetry with the privacy summary when it is unset; non-interactive installs and `--yes` flows never prompt and default remains disabled; repeated runs do not re-prompt once a choice is recorded.
|
|
143
143
|
- [x] **FRIC-005** Namespace per-workflow generated artifacts to prevent overwrite and context contamination. _Acceptance:_ stage artifacts are written under a per-workflow path (e.g., `generated/specs/<workflowId>/brainstorm.md`) instead of fixed shared paths like `generated/specs/brainstorm.md`; `approvalArtifactPath`, quality gates, the approval ledger's artifact fingerprints, traceability, and context retrieval resolve paths through the active workflow id; starting a new workflow never overwrites or reads a previous workflow's artifacts; existing installations migrate or read legacy fixed paths with an advisory; completed workflows' artifacts are archived alongside the session.
|
|
144
144
|
|
|
145
|
+
## Research — P1
|
|
146
|
+
|
|
147
|
+
- [x] **RES-001** Ship the bounded `research` skill. _Acceptance:_ see `.aiw/generated/specs/f83c066d-0084-42fb-b501-02c78949f5bd/specification.md` (REQ-001…005): scope gate with human confirmation, step/turn budget with stop conditions and escalation, evidence-first citations (fact/hypothesis/unverified; uncited → open question), secret redaction and provenance for host-side external research, durable workflow-scoped `research.md` artifact with light-lane evidence recording, packaged and recommended advisory-only with eval contracts.
|
|
148
|
+
|
|
149
|
+
## Resource update — P1
|
|
150
|
+
|
|
151
|
+
- [x] **UPD-001** Bundled-resource update command. _Acceptance:_ see `.aiw/generated/specs/4962f74d-8508-41de-a0e6-4b54b190eb92/specification.md` (REQ-001…004): catalog-vs-installed diff (updated/new/unchanged), drift-safe replacement via the ownership-checksum oracle with typed `update_conflict` blocks, additive `--add=type/id` installation, dry-run, non-interactive and idempotent.
|
|
152
|
+
|
|
145
153
|
## Backlog rules
|
|
146
154
|
|
|
147
155
|
- [x] **FND-009** Add self-validation workflow. _Acceptance:_ changes affecting AIW behavior execute against this repository and record generated-output evidence.
|
|
@@ -6,26 +6,27 @@ Every blocking `aiw` exit carries a stable reason code plus either an exact runn
|
|
|
6
6
|
- With `--json`, blocking exits return `{ "reason_code": ..., "next_command" | "next_action" | "terminal": ... }`.
|
|
7
7
|
- The table below is generated from the registry; a test in `src/blocking-reasons.test.ts` fails CI when this page drifts from the code.
|
|
8
8
|
|
|
9
|
-
| Reason code | Description
|
|
10
|
-
| ------------------------------- |
|
|
11
|
-
| `gate_evidence_missing` | The quality gate is blocked because the required evidence artifact is missing.
|
|
12
|
-
| `gate_incomplete` | The quality gate found completeness issues in the stage artifact.
|
|
13
|
-
| `stage_prerequisite_pending` | A previous stage is awaiting human approval before this stage can start.
|
|
14
|
-
| `stage_prerequisite_unresolved` | Previous stages need human approval or an accepted optional skip before this stage can start.
|
|
15
|
-
| `stage_awaiting_approval` | This stage is awaiting human approval; approve or reject it before continuing.
|
|
16
|
-
| `stage_already_approved` | This stage is already approved; changed evidence requires rerunning its quality gate.
|
|
17
|
-
| `approval_evidence_missing` | Approval cannot be recorded because the stage evidence artifact is missing.
|
|
18
|
-
| `approval_stale` | The artifact changed after review; its approval is stale and the gate must run again.
|
|
19
|
-
| `approval_gate_missing` | No passing quality gate is recorded for this stage; gate it before approving.
|
|
20
|
-
| `lane_escalation_required` | Light-lane workflows do not author stage artifacts; escalate to the full lane to continue.
|
|
21
|
-
| `light_evidence_missing` | A light-lane workflow cannot complete without at least one recorded validation entry.
|
|
22
|
-
| `workflow_still_active` | A workflow is already active; finish or archive it before starting another.
|
|
23
|
-
| `workflow_not_active` | No SDD workflow is active for this command to operate on.
|
|
24
|
-
| `workflow_complete` | This workflow is already complete; start a new workflow to continue working.
|
|
25
|
-
| `installation_required` | AI Workflow is not installed in this repository; install it to continue.
|
|
26
|
-
| `state_mismatch` | AI Workflow state files are inconsistent with each other; run diagnostics to inspect and repair.
|
|
27
|
-
| `context_budget_exceeded` | The served context exceeds the declared ceiling for this stage; trim it or raise the ceiling explicitly.
|
|
28
|
-
| `stage_not_in_process` | This stage does not exist in the active workflow's process; use the process's own stages.
|
|
29
|
-
| `migration_required` | Legacy pre-ownership state detected; review the migration plan before continuing.
|
|
30
|
-
| `worktrees_leaked` | Managed orchestration worktrees remain on disk after their plan finished; clean them up.
|
|
31
|
-
| `orchestration_not_executed` | The plan has not been executed yet; there is no checkpoint to integrate.
|
|
9
|
+
| Reason code | Description | Continuation |
|
|
10
|
+
| ------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------- |
|
|
11
|
+
| `gate_evidence_missing` | The quality gate is blocked because the required evidence artifact is missing. | explicit action |
|
|
12
|
+
| `gate_incomplete` | The quality gate found completeness issues in the stage artifact. | explicit action |
|
|
13
|
+
| `stage_prerequisite_pending` | A previous stage is awaiting human approval before this stage can start. | runnable command |
|
|
14
|
+
| `stage_prerequisite_unresolved` | Previous stages need human approval or an accepted optional skip before this stage can start. | runnable command |
|
|
15
|
+
| `stage_awaiting_approval` | This stage is awaiting human approval; approve or reject it before continuing. | runnable command |
|
|
16
|
+
| `stage_already_approved` | This stage is already approved; changed evidence requires rerunning its quality gate. | runnable command |
|
|
17
|
+
| `approval_evidence_missing` | Approval cannot be recorded because the stage evidence artifact is missing. | explicit action |
|
|
18
|
+
| `approval_stale` | The artifact changed after review; its approval is stale and the gate must run again. | runnable command |
|
|
19
|
+
| `approval_gate_missing` | No passing quality gate is recorded for this stage; gate it before approving. | runnable command |
|
|
20
|
+
| `lane_escalation_required` | Light-lane workflows do not author stage artifacts; escalate to the full lane to continue. | explicit action |
|
|
21
|
+
| `light_evidence_missing` | A light-lane workflow cannot complete without at least one recorded validation entry. | explicit action |
|
|
22
|
+
| `workflow_still_active` | A workflow is already active; finish or archive it before starting another. | explicit action |
|
|
23
|
+
| `workflow_not_active` | No SDD workflow is active for this command to operate on. | runnable command |
|
|
24
|
+
| `workflow_complete` | This workflow is already complete; start a new workflow to continue working. | runnable command |
|
|
25
|
+
| `installation_required` | AI Workflow is not installed in this repository; install it to continue. | runnable command |
|
|
26
|
+
| `state_mismatch` | AI Workflow state files are inconsistent with each other; run diagnostics to inspect and repair. | runnable command |
|
|
27
|
+
| `context_budget_exceeded` | The served context exceeds the declared ceiling for this stage; trim it or raise the ceiling explicitly. | explicit action |
|
|
28
|
+
| `stage_not_in_process` | This stage does not exist in the active workflow's process; use the process's own stages. | explicit action |
|
|
29
|
+
| `migration_required` | Legacy pre-ownership state detected; review the migration plan before continuing. | runnable command |
|
|
30
|
+
| `worktrees_leaked` | Managed orchestration worktrees remain on disk after their plan finished; clean them up. | explicit action |
|
|
31
|
+
| `orchestration_not_executed` | The plan has not been executed yet; there is no checkpoint to integrate. | explicit action |
|
|
32
|
+
| `update_conflict` | Manually edited installed resources conflict with a bundled update; they are preserved, never overwritten. | explicit action |
|
package/package.json
CHANGED
package/resources/package.yaml
CHANGED
|
@@ -33,6 +33,7 @@ resources:
|
|
|
33
33
|
- { id: prisma-data-access, version: 0.1.0, path: skills/prisma-data-access.md }
|
|
34
34
|
- { id: vite-frontend, version: 0.1.0, path: skills/vite-frontend.md }
|
|
35
35
|
- { id: ticket, version: 0.1.0, path: skills/ticket.md }
|
|
36
|
+
- { id: research, version: 0.1.0, path: skills/research.md }
|
|
36
37
|
- { id: review-judge-a, version: 0.1.0, path: skills/review-judge-a.md }
|
|
37
38
|
- { id: review-judge-b, version: 0.1.0, path: skills/review-judge-b.md }
|
|
38
39
|
- { id: review-refuter, version: 0.1.0, path: skills/review-refuter.md }
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: research
|
|
3
|
+
description: Run a bounded, evidence-first investigation from a single question — logs, errors, code, or external sources — and record a durable research artifact.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Research (bounded, evidence-first)
|
|
7
|
+
|
|
8
|
+
Use this skill when work starts from a concrete question that needs context gathered before anything is decided or designed: an unexplained error, a log signature, a migration implication, a library behavior. This skill collects and sharpens context; it never decides, designs, or replaces diagnosis/brainstorming.
|
|
9
|
+
|
|
10
|
+
## Scope gate (before any work)
|
|
11
|
+
|
|
12
|
+
1. Restate the request as **one investigable question**. If the request bundles several questions or is vague, ask the human to confirm a single question and stop until they do.
|
|
13
|
+
2. List the **explicit sources**: file paths, log locations, a reproduction command, or external documentation areas. No source list, no start.
|
|
14
|
+
3. If the question turns out to need a fix or a decision rather than facts, stop and suggest the right lane: `aiw task start --process=bugfix` (diagnosis) or a brainstorm/specification workflow.
|
|
15
|
+
|
|
16
|
+
## Budget and stop conditions
|
|
17
|
+
|
|
18
|
+
- Cap the investigation at a fixed budget: at most ~10 investigation steps or 3 turns, whichever comes first.
|
|
19
|
+
- Stop and converge when either: two independent sources confirm the answer, or the budget is exhausted.
|
|
20
|
+
- On stop, report what was verified, what remains open, and the budget usage. Never continue "just a bit more" past the cap.
|
|
21
|
+
- If scope grows beyond the question mid-flight, stop and escalate (`aiw task escalate --reason=...` in a light-lane session, or suggest a full workflow) instead of widening the investigation.
|
|
22
|
+
|
|
23
|
+
## Evidence rules (every finding)
|
|
24
|
+
|
|
25
|
+
- Every finding cites a **verifiable source**: `file:line`, a log line with its timestamp, or a URL with the consultation date.
|
|
26
|
+
- Mark each finding's state: **fact** (source directly states it), **hypothesis** (inferred, cited basis named), or **unverified** (no source yet — belongs in open questions, not findings).
|
|
27
|
+
- A claim without a verifiable citation is an **open question**, never a finding.
|
|
28
|
+
- Prefer the repository's own evidence first: `aiw semantic query <terms>` when semantic mapping is enabled, exact `grep`/`rg` for literals, logs and reproduction commands before external sources.
|
|
29
|
+
|
|
30
|
+
## External research (host-side)
|
|
31
|
+
|
|
32
|
+
- You (the host agent) perform any web or documentation searches; AIW does no network calls.
|
|
33
|
+
- **Redact secrets before querying or persisting**: tokens, credentials, internal hostnames, and anything the interpreter guardrails would exclude must not appear in queries, excerpts, or the artifact.
|
|
34
|
+
- Record each external source as URL + consultation date in the artifact's source list.
|
|
35
|
+
|
|
36
|
+
## Artifact
|
|
37
|
+
|
|
38
|
+
Write the result to `.aiw/generated/reports/<workflowId>/research.md` with exactly these sections:
|
|
39
|
+
|
|
40
|
+
```markdown
|
|
41
|
+
# Research: <question>
|
|
42
|
+
|
|
43
|
+
## Question
|
|
44
|
+
<the single confirmed question>
|
|
45
|
+
|
|
46
|
+
## Sources
|
|
47
|
+
- <file:line / log location / reproduction command / URL + consultation date>
|
|
48
|
+
|
|
49
|
+
## Findings
|
|
50
|
+
- <finding> — state: fact|hypothesis — source: <citation> — confidence: high|medium|low
|
|
51
|
+
|
|
52
|
+
## Budget
|
|
53
|
+
steps used: <n> / cap · stop reason: <confirmed|budget>
|
|
54
|
+
|
|
55
|
+
## Open questions
|
|
56
|
+
- <unresolved items, next most-likely source>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Confidence uses the scan evidence vocabulary (high/medium/low). Then record completion in the session:
|
|
60
|
+
|
|
61
|
+
- Light-lane session: `npx --yes --package=@multileaf/ai-workflow -- aiw task evidence --validation="research artifact: .aiw/generated/reports/<workflowId>/research.md (<findings count> findings, <open count> open)"`.
|
|
62
|
+
- No active workflow: start one first — `aiw task start --no-ticket --lane=light --lane-reason="bounded research, resumable from request plus artifact"` — artifact paths are workflow-scoped.
|
|
63
|
+
|
|
64
|
+
The artifact feeds later stages (brainstorm, specification, diagnosis); cite it rather than re-reading sources.
|