@aiwg/cli 2026.10.18 → 2026.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +1 -0
  2. package/agentic/code/providers/capability-matrix.yaml +51 -0
  3. package/agentic/code/providers/flue/README.md +62 -0
  4. package/agentic/code/providers/flue/templates/aiwg/tools.ts +120 -0
  5. package/agentic/code/providers/model-capabilities.v1.json +23 -0
  6. package/agentic/code/providers/model-catalog.v1.json +9 -0
  7. package/dist/src/artifacts/corpus-tools/resolve.js +7 -2
  8. package/dist/src/cli/handlers/bundle-declaration.js +55 -0
  9. package/dist/src/cli/handlers/bundle-deployment-mode.js +71 -0
  10. package/dist/src/cli/handlers/bundle-hash-prune.js +37 -0
  11. package/dist/src/cli/handlers/bundle-reconciliation.js +140 -0
  12. package/dist/src/cli/handlers/help.js +1 -1
  13. package/dist/src/cli/handlers/init.js +1 -0
  14. package/dist/src/cli/handlers/refresh-bundles.js +35 -0
  15. package/dist/src/cli/handlers/refresh-rule-inventory.js +10 -0
  16. package/dist/src/cli/handlers/refresh.js +15 -52
  17. package/dist/src/cli/handlers/remove-bundled.js +7 -4
  18. package/dist/src/cli/handlers/remove-flue-modules.js +19 -0
  19. package/dist/src/cli/handlers/remove-historical-bundle.js +18 -0
  20. package/dist/src/cli/handlers/remove.js +8 -0
  21. package/dist/src/cli/handlers/script-runner.js +10 -0
  22. package/dist/src/cli/handlers/subcommands-list-format.js +4 -4
  23. package/dist/src/cli/handlers/update.js +18 -8
  24. package/dist/src/cli/handlers/use-additive-bundles.js +87 -0
  25. package/dist/src/cli/handlers/use-bundle-counts.js +5 -1
  26. package/dist/src/cli/handlers/use-owned-counts.js +75 -0
  27. package/dist/src/cli/handlers/use.js +53 -102
  28. package/dist/src/cli/services/deployment-verification.js +5 -1
  29. package/dist/src/config/aiwg-config.js +10 -5
  30. package/dist/src/config/framework-aliases.js +14 -0
  31. package/dist/src/config/installed-selection.js +9 -1
  32. package/dist/src/config/installed-validation.js +35 -0
  33. package/dist/src/extensions/project-local-doctor.js +1 -1
  34. package/dist/src/extensions/project-local-remove.js +3 -3
  35. package/dist/src/mcp/cli.mjs +12 -7
  36. package/dist/src/mcp/helpers.mjs +5 -1
  37. package/dist/src/mcp/http-options.mjs +101 -0
  38. package/dist/src/mcp/http-tools.mjs +51 -0
  39. package/dist/src/mcp/http-transport.mjs +201 -0
  40. package/dist/src/mcp/server.mjs +9 -7
  41. package/dist/src/mcp/tool-context.mjs +25 -0
  42. package/dist/src/mcp/tools/orchestration.mjs +2 -1
  43. package/dist/src/memory/provider-memory-adapter.js +1 -0
  44. package/dist/src/models/model-capabilities.v1.json +23 -0
  45. package/dist/src/models/model-catalog.v1.json +9 -0
  46. package/dist/src/models/policy-resources.js +1 -1
  47. package/dist/src/providers/capability-matrix.yaml +51 -0
  48. package/dist/src/providers/deployment-ownership.d.mts +2 -1
  49. package/dist/src/providers/deployment-ownership.mjs +27 -3
  50. package/dist/src/providers/deployment-preservation.d.mts +5 -0
  51. package/dist/src/providers/deployment-preservation.mjs +110 -0
  52. package/dist/src/providers/deployment-removal.js +26 -2
  53. package/dist/src/providers/flue-package-mode.js +19 -0
  54. package/dist/src/providers/provider-context-contracts.js +8 -0
  55. package/dist/src/providers/provider-definition-schema.js +1 -0
  56. package/dist/src/providers/provider-definitions.js +1 -0
  57. package/dist/src/providers/provider-seeds-3.js +18 -0
  58. package/dist/src/providers/skill-ownership.d.mts +1 -0
  59. package/dist/src/providers/skill-ownership.mjs +1 -0
  60. package/dist/src/research/reference-match.js +33 -6
  61. package/dist/src/skills/deployment-ownership.js +2 -2
  62. package/dist/src/skills/deployment-policy.js +9 -0
  63. package/dist/src/smiths/context-pipeline/flue-context.js +25 -0
  64. package/dist/src/smiths/context-pipeline/generator.js +6 -1
  65. package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +9 -7
  66. package/package.json +3 -1
  67. package/tools/agents/deploy-agents.mjs +11 -4
  68. package/tools/agents/deploy-options.mjs +11 -0
  69. package/tools/agents/providers/base-inventory.mjs +6 -1
  70. package/tools/agents/providers/base-kernel-skills.mjs +9 -5
  71. package/tools/agents/providers/base-migrations.mjs +1 -0
  72. package/tools/agents/providers/base-skill-copy.mjs +9 -1
  73. package/tools/agents/providers/claude.mjs +2 -1
  74. package/tools/agents/providers/codex.mjs +5 -1
  75. package/tools/agents/providers/flue-bundles.mjs +42 -0
  76. package/tools/agents/providers/flue-cloudflare.mjs +20 -0
  77. package/tools/agents/providers/flue-project.mjs +118 -0
  78. package/tools/agents/providers/flue-skill-copy.mjs +25 -0
  79. package/tools/agents/providers/flue-skills.mjs +45 -0
  80. package/tools/agents/providers/flue-specialists.mjs +82 -0
  81. package/tools/agents/providers/flue-validation.mjs +14 -0
  82. package/tools/agents/providers/flue.mjs +54 -0
  83. package/tools/agents/providers/hermes-skill-lifecycle.mjs +1 -0
  84. package/tools/agents/providers/rule-delivery-surface.mjs +16 -1
  85. package/tools/agents/providers/rule-deployment-commit.mjs +14 -0
  86. package/tools/agents/providers/rule-deployment-prepare.mjs +6 -1
  87. package/tools/agents/providers/rule-startup.mjs +3 -3
  88. package/tools/agents/providers/skill-copy-prune.mjs +49 -0
  89. package/tools/agents/providers/stale-artifact-prune.mjs +1 -0
  90. package/tools/agents/use-rule-selection.mjs +17 -0
  91. package/tools/skills/codex-skill-metadata.mjs +22 -0
  92. package/tools/skills/deploy-skills-codex.mjs +8 -7
  93. package/vscode-extension/schemas/aiwg.config.v1.json +44 -19
package/README.md CHANGED
@@ -225,6 +225,7 @@ AIWG publishes three packages in exact CalVer lockstep:
225
225
  | `@aiwg/cli` | Agentic runtimes, web-connected sessions, CI, and lightweight global use | Signed release host by default | `npm i -g @aiwg/cli` |
226
226
  | `aiwg` | Full local operation, framework deployment, authoring, offline-first projects | Bundled local corpus by default; web mode optional | `npm i -g aiwg` |
227
227
  | `@aiwg/cockpit` | Optional local control plane and operator UI | Installed separately or through the full CLI | `npm i -g @aiwg/cockpit` |
228
+ | `@aiwg/flue` | Flue app skills, specialists and MCP helpers | Installed in a Flue app | `npm install @aiwg/flue` |
228
229
 
229
230
  Choose `@aiwg/cli` when AIWG skills and agents need a small, globally available
230
231
  execution layer and can obtain resources from the signed web release. Choose
@@ -934,6 +934,57 @@ providers:
934
934
  deploy_target: project
935
935
  aggregated_output: false
936
936
 
937
+ flue:
938
+ display_name: Flue (experimental)
939
+ status: experimental
940
+ route_feasibility:
941
+ scope: out
942
+ identity: unavailable
943
+ evidence: R
944
+ channel: "none - Flue 2.3.0 app target; no worker dispatch (#3120 D6)"
945
+ coverage:
946
+ profile_issue: null
947
+ source_date: "2026-10-30"
948
+ live_qualified: false
949
+ exclusion_gap: "Flue run accepts prompts in argv and lacks worker model/effort flags; app deployment only."
950
+ recheck: "Rechecked 2026-10-30 against installed Flue 2.3.0 source; #3120 D6 excludes worker dispatch."
951
+ sources:
952
+ - "tools/agents/providers/flue.mjs"
953
+ - "docs/providers/flue.md"
954
+ - "https://flueframework.com/docs/"
955
+ fanout: unknown
956
+ probe_budget: { status: proposed, calls: 0, tokens: 0 }
957
+ daemon_tier: unsupported
958
+ daemon_pty_adapter: false
959
+ artifact_paths:
960
+ agents: ""
961
+ commands: ""
962
+ skills: .agents/skills/
963
+ rules: AGENTS.md
964
+ behaviors: null
965
+ native_features:
966
+ cron: false
967
+ agent_teams: false
968
+ tasks: false
969
+ mcp: false
970
+ behaviors: false
971
+ mission_control: false
972
+ daemon: false
973
+ emulation:
974
+ cron: null
975
+ agent_teams: null
976
+ tasks: null
977
+ mcp: null
978
+ behaviors: null
979
+ mission_control: null
980
+ daemon: null
981
+ hook_wiring:
982
+ at_link_support: false
983
+ fallback: full-inject
984
+ context_file: AGENTS.md
985
+ deploy_target: project
986
+ aggregated_output: false
987
+
937
988
  pi:
938
989
  display_name: Pi Coding Agent
939
990
  route_feasibility:
@@ -0,0 +1,62 @@
1
+ # Flue tools (2.3.0)
2
+
3
+ The provider deploy can copy `templates/aiwg/tools.ts` to the app's `src/aiwg/tools.ts`; `AIWG_TOOL_NAMES` lists its three tools for deployment consumers (#3121).
4
+
5
+ ```ts
6
+ import { useTool } from '@flue/runtime';
7
+ import { aiwg_discover, aiwg_show, aiwg_artifact_write } from './aiwg/tools';
8
+
9
+ // Inside the app's agent or specialist function:
10
+ useTool(aiwg_discover);
11
+ useTool(aiwg_show);
12
+ useTool(aiwg_artifact_write);
13
+ ```
14
+
15
+ The default tools run the installed `aiwg mcp serve` in the app's launch directory.
16
+ For another trusted project or executable, call `createAiwgTools({ cwd, command, args, env })`
17
+ at app setup and mount the returned tools. Configuration belongs to the app,
18
+ never to model tool inputs. The app needs AIWG installed on PATH, Node 24+, and
19
+ the tested Flue 2.3.0 graph: Valibot, `@modelcontextprotocol/client` 2.0.0 and
20
+ its `/stdio` export. These are already present in the pinned lab graph; AIWG
21
+ does not install dependencies or provide model credentials.
22
+
23
+ Each call owns a stdio child and closes it on success or failure. Initialization
24
+ has a 10-second deadline and observes cancellation; transport cleanup can take
25
+ up to 4 more seconds to terminate a silent child. The child
26
+ inherits the SDK's safe process settings plus AIWG root/path settings; optional
27
+ subsystem toolsets are disabled. No HTTP listener, gateway, `local()` sandbox,
28
+ approval bridge or model invocation is involved. Artifact writes go through
29
+ AIWG's `artifact-write`; the server resolves the project's configured artifact
30
+ root, pins it and enforces containment. The caller cannot set `project_dir`.
31
+ This scope applies to these tools; other app code retains its own host access.
32
+
33
+ `aiwg_show` supports the four MCP card tools: skill, agent, command and rule.
34
+ It always fetches governing rule summaries and bodies, and maps an optional
35
+ single heading to MCP's section array. Discovery retains all eight MCP asset
36
+ types. Its `query` maps to `discover.phrase`; the MCP default limit remains in
37
+ effect. Schema parity compares those public projections with live `tools/list`
38
+ schemas; fixed arguments and the omitted project selector remain server-owned.
39
+
40
+ Transport decision (#3123/#3124): the SDK stdio client works. Flue's documented
41
+ trusted-code route (`@flue/runtime/dist/mcp-CYraeuuF.mjs:45-48,114-125`,
42
+ re-exported by `index.mjs:10`) calls `new URL` and constructs its own HTTP/SSE transport.
43
+ The spike supplies both stdio and a custom transport with a throwing fetch;
44
+ both reach the HTTP fetch instead of a custom transport. The SDK connects to
45
+ the existing `src/mcp/server.mjs` over stdio and directly calls all three tools.
46
+ SDK evidence: `@modelcontextprotocol/client/package.json` exports `./stdio`;
47
+ `dist/stdio.mjs:48-81` spawns the child with stdin/stdout pipes. No gateway is
48
+ needed. Sources are the installed Flue 2.3.0 lab, checked in a temporary copy.
49
+
50
+ Run the reproducible smoke without reading lab environment files or state:
51
+
52
+ ```sh
53
+ TMPDIR=/var/tmp node tools/testing/flue-lab-smoke.mjs --lab /path/to/flue-lab
54
+ ```
55
+
56
+ It copies only the lab's package manifests and installed dependencies into
57
+ `os.tmpdir()` and deletes the copy afterward. It loads the actual TypeScript
58
+ template in Node, checks actual Valibot/MCP parity, and calls the tool functions
59
+ against a synthetic discovery CLI and the real AIWG MCP artifact server.
60
+ The default unit lane uses small Flue/Valibot builder doubles and the repository's
61
+ SDK 1.x client shim, keeping optional app dependencies out of AIWG itself;
62
+ the lab smoke verifies the full real Flue/Valibot/SDK 2.x boundary.
@@ -0,0 +1,120 @@
1
+ // App-owned Flue tools backed by AIWG's contained MCP operations.
2
+ import { defineTool } from '@flue/runtime';
3
+ import * as v from 'valibot';
4
+ import { Client } from '@modelcontextprotocol/client';
5
+ import { StdioClientTransport, getDefaultEnvironment } from '@modelcontextprotocol/client/stdio';
6
+
7
+ /* Transport spike: Flue 2.3.0's documented trusted-code escape hatch
8
+ * (@flue/runtime/dist/mcp-CYraeuuF.mjs:45-48,114-125, re-exported by
9
+ * index.mjs:10) calls new URL(definition.url) and constructs HTTP/SSE internally.
10
+ * It accepts neither a custom transport nor stdio. SDK 2.0.0 Client plus
11
+ * StdioClientTransport works against src/mcp/server.mjs (SDK dist/stdio.mjs,
12
+ * package.json exports["./stdio"]). No listener, gateway, or model is needed.
13
+ * Each call owns and closes its child, including failures/cancellation.
14
+ * Verified with tools/testing/flue-lab-smoke.mjs against a read-only lab copy.
15
+ *
16
+ * MCP schemas remain authoritative: discovery.mjs discover.phrase -> query,
17
+ * discover.type -> type; *-show.name -> name, section.items -> section.
18
+ * Show fixes rules/with_rule_bodies=true. Artifact-write projects path/content,
19
+ * deliberately omitting project_dir so tool data cannot change project scope.
20
+ * test/unit/providers/flue-tools.test.ts compares these schema projections;
21
+ * the lab smoke also compares actual Valibot JSON Schema against tools/list.
22
+ */
23
+ export const AIWG_TOOL_NAMES = Object.freeze([
24
+ 'aiwg_discover', 'aiwg_show', 'aiwg_artifact_write',
25
+ ] as const);
26
+
27
+ export interface AiwgToolOptions {
28
+ /** Trusted app configuration only; never populate these from tool inputs. */
29
+ command?: string;
30
+ args?: string[];
31
+ cwd?: string;
32
+ env?: Record<string, string>;
33
+ }
34
+
35
+ /** Create an isolated set for an app/project; defaults use the installed aiwg. */
36
+ export function createAiwgTools(options: AiwgToolOptions = {}) {
37
+ const cwd = options.cwd ?? process.cwd();
38
+ // Inherit only SDK-safe process settings and AIWG path settings, not model keys.
39
+ const env = getDefaultEnvironment();
40
+ for (const key of ['AIWG_ROOT', 'AIWG_ARTIFACTS_PATH', 'AIWG_PROJECT_ARTIFACTS_PATH', 'AIWG_PROJECT_AIWG_DIR']) {
41
+ if (process.env[key]) env[key] = process.env[key];
42
+ }
43
+ Object.assign(env, options.env, { AIWG_MCP_TOOLSETS: '' });
44
+
45
+ async function call(name: string, args: Record<string, unknown>, signal?: AbortSignal) {
46
+ signal?.throwIfAborted();
47
+ // AIWG serves MCP 2025-11-25; avoid SDK 2's disposable newer-era probe child.
48
+ const client = new Client({ name: 'aiwg-flue', version: '1.0.0' }, {
49
+ versionNegotiation: { mode: 'legacy' },
50
+ });
51
+ const transport = new StdioClientTransport({
52
+ command: options.command ?? 'aiwg', args: options.args ?? ['mcp', 'serve'],
53
+ cwd, env, stderr: 'inherit',
54
+ });
55
+ try {
56
+ // Bound initialize to 10 seconds; transport.close also reaps a silent child
57
+ // on timeout/abort (SDK cleanup may take another 4 seconds to escalate).
58
+ let timer: ReturnType<typeof setTimeout> | undefined;
59
+ let abortConnect = () => {};
60
+ try {
61
+ const interrupted = new Promise<never>((_, reject) => {
62
+ abortConnect = () => reject(signal?.reason ?? new Error('AIWG MCP connect aborted'));
63
+ signal?.addEventListener('abort', abortConnect, { once: true });
64
+ if (signal?.aborted) abortConnect();
65
+ timer = setTimeout(() => reject(new Error('AIWG MCP connect timed out after 10000 ms')), 10_000);
66
+ });
67
+ await Promise.race([client.connect(transport), interrupted]);
68
+ } finally {
69
+ clearTimeout(timer);
70
+ signal?.removeEventListener('abort', abortConnect);
71
+ }
72
+ signal?.throwIfAborted();
73
+ const result = await client.callTool({ name, arguments: args }, { signal, timeout: 180_000 });
74
+ const text = result.content.filter(item => item.type === 'text').map(item => item.text).join('\n');
75
+ const output = result.structuredContent === undefined ? text
76
+ : [text, JSON.stringify(result.structuredContent)].filter(Boolean).join('\n');
77
+ if (result.isError) throw new Error(output || `AIWG MCP tool ${name} failed`);
78
+ return { output };
79
+ } finally {
80
+ await transport.close();
81
+ await client.close();
82
+ }
83
+ }
84
+
85
+ const aiwg_discover = defineTool({
86
+ name: AIWG_TOOL_NAMES[0],
87
+ description: 'Find AIWG capabilities and their governing checks. Follow with aiwg_show.',
88
+ input: v.strictObject({
89
+ query: v.string(),
90
+ type: v.optional(v.picklist(['skill', 'agent', 'command', 'rule', 'flow', 'runbook', 'template', 'behavior'])),
91
+ }),
92
+ annotations: { readOnlyHint: true, openWorldHint: false },
93
+ run: ({ data, signal }) => call('discover', {
94
+ phrase: data.query, ...(data.type === undefined ? {} : { type: data.type }),
95
+ }, signal),
96
+ });
97
+ const aiwg_show = defineTool({
98
+ name: AIWG_TOOL_NAMES[1],
99
+ description: 'Fetch an AIWG card plus governing rule bodies; optionally drill into one heading. Types: skill, agent, command, rule.',
100
+ input: v.strictObject({
101
+ type: v.picklist(['skill', 'agent', 'command', 'rule']),
102
+ name: v.string(), section: v.optional(v.string()),
103
+ }),
104
+ annotations: { readOnlyHint: true, openWorldHint: false },
105
+ run: ({ data, signal }) => call(`${data.type}-show`, {
106
+ name: data.name, rules: true, with_rule_bodies: true,
107
+ ...(data.section === undefined ? {} : { section: [data.section] }),
108
+ }, signal),
109
+ });
110
+ const aiwg_artifact_write = defineTool({
111
+ name: AIWG_TOOL_NAMES[2],
112
+ description: 'Write an artifact relative to this project’s configured artifact root. AIWG enforces containment.',
113
+ input: v.strictObject({ path: v.string(), content: v.string() }),
114
+ annotations: { readOnlyHint: false, openWorldHint: false },
115
+ run: ({ data, signal }) => call('artifact-write', { path: data.path, content: data.content }, signal),
116
+ });
117
+ return { aiwg_discover, aiwg_show, aiwg_artifact_write };
118
+ }
119
+
120
+ export const { aiwg_discover, aiwg_show, aiwg_artifact_write } = createAiwgTools();
@@ -2533,6 +2533,29 @@
2533
2533
  }
2534
2534
  }
2535
2535
  },
2536
+ "flue": {
2537
+ "sessionEnvAllowlist": [],
2538
+ "agent": "unsupported",
2539
+ "skill": "unsupported",
2540
+ "globalChild": "unsupported",
2541
+ "identifierSyntax": "App-owned Flue model configuration; no AIWG worker selector",
2542
+ "inheritance": "Application-owned; no worker dispatch",
2543
+ "invalidPinFallback": "Report unsupported",
2544
+ "configTarget": "Application-owned",
2545
+ "artifactFormat": "Kernel SKILL.md and composed AGENTS.md",
2546
+ "verification": "Flue 2.3.0 installed source; app deployment only (#3120 D6)",
2547
+ "sourceUrl": "https://flueframework.com/docs/",
2548
+ "verifiedAt": "2026-10-30",
2549
+ "workerHealthCoverage": {
2550
+ "scope": "out",
2551
+ "coverage": "unobserved",
2552
+ "handshake": "unobserved",
2553
+ "evidenceGrades": ["R"],
2554
+ "qualificationOwner": "B-OG-47",
2555
+ "provenance": ["tools/agents/providers/flue.mjs", "docs/providers/flue.md"],
2556
+ "reason": "Flue is an app target, with no worker invocation profile or adapter (#3120 D6)."
2557
+ }
2558
+ },
2536
2559
  "grokbot": {
2537
2560
  "sessionEnvAllowlist": [],
2538
2561
  "agent": "unsupported",
@@ -327,6 +327,15 @@
327
327
  "sourceUrl": "https://docs.openclaw.ai/tools/subagents",
328
328
  "verifiedAt": "2026-07-20"
329
329
  },
330
+ "flue": {
331
+ "roles": {
332
+ "reasoning": { "id": "app-owned", "status": "unverified", "observed": false },
333
+ "coding": { "id": "app-owned", "status": "unverified", "observed": false },
334
+ "efficiency": { "id": "app-owned", "status": "unverified", "observed": false }
335
+ },
336
+ "sourceUrl": "https://flueframework.com/docs/",
337
+ "verifiedAt": "2026-10-30"
338
+ },
330
339
  "grokbot": {
331
340
  "roles": {
332
341
  "reasoning": {
@@ -3,7 +3,7 @@ import { ArxivClient } from '../../research/clients/arxiv.js';
3
3
  import { CrossRefClient } from '../../research/clients/crossref.js';
4
4
  import { SemanticScholarClient } from '../../research/clients/semantic-scholar.js';
5
5
  import { identityKeys, normalizeIdentity, normalizeTitle } from '../../research/identity.js';
6
- import { classifyCandidates, mergePapers, needsTitleDisambiguation, parsePartialReference, scorePaper } from '../../research/reference-match.js';
6
+ import { classifyCandidates, mergePapers, needsTitleDisambiguation, needsYearReview, parsePartialReference, scorePaper } from '../../research/reference-match.js';
7
7
  import { ResearchError, ResearchErrorCode } from '../../research/types.js';
8
8
  import { findInCorpus } from './resolve-corpus.js';
9
9
  export function createResolverClients() {
@@ -121,8 +121,13 @@ export async function resolveReference(input, root, year, clients = createResolv
121
121
  const classified = classifyCandidates(candidates);
122
122
  const incomplete = paths.some(path => path.retryable);
123
123
  const titleAmbiguous = needsTitleDisambiguation(reference, candidates, incomplete);
124
+ const yearConflict = needsYearReview(reference, candidates[0]);
125
+ if (classified !== 'unresolved' && candidates[0]?.score_parts.year === 0) {
126
+ findings.push({ type: yearConflict ? 'year_conflict' : 'year_mismatch',
127
+ supplied: String(reference.year), returned: String(candidates[0].paper.year), candidate: candidates[0].paper.id });
128
+ }
124
129
  const status = classified === 'unresolved' && incomplete ? 'deferred'
125
- : classified === 'resolved' && (identifierUnresolved || titleAmbiguous) ? 'ambiguous' : classified;
130
+ : classified === 'resolved' && (identifierUnresolved || titleAmbiguous || yearConflict) ? 'ambiguous' : classified;
126
131
  if (titleAmbiguous && classified !== 'unresolved')
127
132
  findings.push({ type: 'title_ambiguous',
128
133
  supplied: reference.title, returned: reference.year === undefined
@@ -0,0 +1,55 @@
1
+ // Edit bundle intent without touching provider payloads.
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { emptyConfig, getProjectDir, readAiwgConfig, writeAiwgConfig, ensureProviderListed } from '../../config/aiwg-config.js';
5
+ import { getFrameworkRoot } from '../../channel/manager.mjs';
6
+ import { REGISTRY_ID_TO_USE_NAME } from '../../config/framework-aliases.js';
7
+ import { getProviderArtifactPathStrings } from '../../providers/provider-definitions.js';
8
+ import { firstRemovePositional, parseRemoveProvider } from './remove-options.js';
9
+ import { validateInstalled } from '../../config/installed-validation.js';
10
+ export async function declareBundle(ctx, remove = false) {
11
+ try {
12
+ const id = firstRemovePositional(ctx.args);
13
+ const { provider, error } = parseRemoveProvider(ctx.args);
14
+ if (!id || !provider || error)
15
+ return { exitCode: 2, message: error || '--declare requires a bundle and explicit --provider.' };
16
+ if (ctx.args.includes('--user') || ctx.args.includes('--global') || ctx.args[ctx.args.indexOf('--scope') + 1] === 'user') {
17
+ return { exitCode: 2, message: '--declare supports project scope only.' };
18
+ }
19
+ if (!getProviderArtifactPathStrings(provider))
20
+ return { exitCode: 2, message: `Unknown provider '${provider}'.` };
21
+ const project = getProjectDir(ctx, ctx.args);
22
+ const config = await readAiwgConfig(project) ?? emptyConfig([provider]);
23
+ const name = REGISTRY_ID_TO_USE_NAME[id] ?? id;
24
+ if (!remove && name !== 'all') {
25
+ const root = ctx.frameworkRoot || await getFrameworkRoot();
26
+ const exists = ['frameworks', 'addons', 'extensions'].some(group => fs.existsSync(path.join(root, 'agentic/code', group, id, 'manifest.json')) ||
27
+ Object.entries(REGISTRY_ID_TO_USE_NAME).some(([dir, alias]) => alias === name && fs.existsSync(path.join(root, 'agentic/code', group, dir, 'manifest.json'))) ||
28
+ fs.existsSync(path.join(project, '.aiwg', group, id, 'manifest.json')));
29
+ if (!exists)
30
+ return { exitCode: 2, message: `Unknown bundle '${id}'.` };
31
+ }
32
+ const key = Object.keys(config.installed).find(key => (REGISTRY_ID_TO_USE_NAME[key] ?? key) === name) ?? name;
33
+ if (remove) {
34
+ delete config.installed[key]?.deployedTo[provider];
35
+ if (config.installed[key] && !Object.keys(config.installed[key].deployedTo).length)
36
+ delete config.installed[key];
37
+ }
38
+ else {
39
+ config.installed[key] ??= { deployedTo: {} };
40
+ config.installed[key].deployedTo[provider] = ctx.args.includes('--copy-all') || ctx.args.includes('--copy-standard-skills') ? { copy: true } : {};
41
+ if (provider === 'flue' && ctx.args.includes('--package'))
42
+ config.installed[key].deployedTo[provider].package = true;
43
+ validateInstalled({ [key]: { deployedTo: { [provider]: config.installed[key].deployedTo[provider] } } });
44
+ ensureProviderListed(config, provider);
45
+ }
46
+ const dryRun = ctx.args.includes('--dry-run');
47
+ if (!dryRun)
48
+ await writeAiwgConfig(project, config);
49
+ return { exitCode: 0, message: `${dryRun ? 'Would ' : ''}${remove ? 'Undeclared' : 'Declared'} ${name} for ${provider}.` };
50
+ }
51
+ catch (error) {
52
+ return { exitCode: 1, message: String(error) };
53
+ }
54
+ }
55
+ //# sourceMappingURL=bundle-declaration.js.map
@@ -0,0 +1,71 @@
1
+ // Retain per-provider deployment intent in the existing project ownership receipt.
2
+ import { writeContextFileSync } from '../../smiths/context-pipeline/context-file-safety.js';
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { readAiwgConfig } from '../../config/aiwg-config.js';
6
+ import { frameworkRegistryId } from '../../config/framework-aliases.js';
7
+ const receiptPath = (project) => path.join(project, '.aiwg/.aiwg-manifest.json');
8
+ export function bundleDeploymentHistory(project) {
9
+ try {
10
+ return JSON.parse(fs.readFileSync(receiptPath(project), 'utf8')).bundleDeployments ?? {};
11
+ }
12
+ catch (error) {
13
+ if (error.code === 'ENOENT')
14
+ return {};
15
+ throw error;
16
+ }
17
+ }
18
+ export function bundleCopyArgs(installed, id, provider) {
19
+ const entry = Object.entries(installed).find(([key]) => frameworkRegistryId(key) === frameworkRegistryId(id))?.[1];
20
+ const flags = entry?.deployedTo[provider];
21
+ return [...(flags?.copy === true ? ['--copy-all'] : []), ...(flags?.skipUtils === true ? ['--no-utils'] : []),
22
+ ...(provider === 'flue' && flags?.package === true ? ['--package'] : [])];
23
+ }
24
+ export async function recordBundleDeployment(project, id, provider, args, frameworkRoot) {
25
+ const { expectedBundleOwners } = await import('./bundle-reconciliation.js');
26
+ const { getFrameworkRoot } = await import('../../channel/manager.mjs');
27
+ const flags = bundleDeploymentScope(id, provider, args);
28
+ const selected = { installed: { [id]: { deployedTo: { [provider]: flags } } } };
29
+ const produces = [...await expectedBundleOwners(selected, provider, frameworkRoot ?? await getFrameworkRoot())].sort();
30
+ const file = receiptPath(project);
31
+ const receipt = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : { scope: 'project', managed: {} };
32
+ receipt.bundleDeployments ??= {};
33
+ receipt.bundleDeployments[provider] ??= {};
34
+ receipt.bundleDeployments[provider][frameworkRegistryId(id)] = { copy: args.includes('--copy-all') || args.includes('--copy-standard-skills'), ...flags, ...(provider === 'flue' ? { package: args.includes('--package') } : {}), produces };
35
+ fs.mkdirSync(path.dirname(file), { recursive: true });
36
+ writeContextFileSync(file, `${JSON.stringify(receipt, null, 2)}\n`);
37
+ }
38
+ // Once index-mode removal completes, later additive passes own any new surface.
39
+ export function markBundleReconciled(project, id, provider) {
40
+ const file = receiptPath(project);
41
+ if (!fs.existsSync(file))
42
+ return;
43
+ const receipt = JSON.parse(fs.readFileSync(file, 'utf8'));
44
+ if (!receipt.bundleDeployments?.[provider]?.[frameworkRegistryId(id)])
45
+ return;
46
+ receipt.bundleDeployments[provider][frameworkRegistryId(id)].reconciled = true;
47
+ writeContextFileSync(file, `${JSON.stringify(receipt, null, 2)}\n`);
48
+ }
49
+ // Local/support bundles copy physically in index mode too; only operator flags prohibit cleanup.
50
+ export function copyCleanupArgs(args) {
51
+ return args.includes('--copy-all') || args.includes('--copy-standard-skills') ? [] : ['--index-mode'];
52
+ }
53
+ // Framework passes retain a separately declared local bundle's provider mode.
54
+ export async function projectLocalDeploymentContext(ctx, project, id, provider, explicit) {
55
+ if (explicit)
56
+ return ctx;
57
+ const installed = (await readAiwgConfig(project))?.installed;
58
+ if (!installed?.[id]?.deployedTo[provider])
59
+ return ctx;
60
+ return { ...ctx, args: [...ctx.args.filter(arg => !['--copy-all', '--copy-standard-skills'].includes(arg)), ...bundleCopyArgs(installed, id, provider)] };
61
+ }
62
+ export function projectLocalCopyMode(config, id, provider, args, explicit) {
63
+ const requested = args.includes('--copy-all') || args.includes('--copy-standard-skills');
64
+ return explicit ? requested : config.installed[id]?.deployedTo[provider]?.copy ?? requested;
65
+ }
66
+ // Match the effective framework gates used by the deployment pass.
67
+ export function bundleDeploymentScope(id, provider, args) {
68
+ return { skipUtils: args.includes('--no-utils'), kernelOnly: id === 'all' && !['pi', 'omp'].includes(provider)
69
+ && !args.includes('--copy-all') && !args.includes('--copy-standard-skills') };
70
+ }
71
+ //# sourceMappingURL=bundle-deployment-mode.js.map
@@ -0,0 +1,37 @@
1
+ // Reuse project-local removal when historical provider hashes outlive its declaration.
2
+ import { frameworkRegistryId } from '../../config/framework-aliases.js';
3
+ import { bundleDeploymentHistory } from './bundle-deployment-mode.js';
4
+ import { getProviderArtifactPathStrings } from '../../providers/provider-definitions.js';
5
+ import { deployedSkillRoots } from '../../providers/deployed-skill-roots.js';
6
+ import { removeProjectLocalBundle } from '../../extensions/project-local-remove.js';
7
+ export async function pruneUndeclaredHashes(project, config, requested, dryRun) {
8
+ const handled = new Set();
9
+ for (const [id, entry] of Object.entries(config.installed)) {
10
+ if (entry.source !== 'project-local')
11
+ continue;
12
+ const historicalProviders = new Set([...Object.keys(entry.deployedArtifactHashes ?? {}), ...(Object.keys(entry.artifactHashes ?? {}).length ? config.providers ?? [] : [])]);
13
+ for (const provider of historicalProviders) {
14
+ if (!getProviderArtifactPathStrings(provider))
15
+ continue;
16
+ if (entry.deployedTo[provider] || requested && !requested.split(',').includes(provider))
17
+ continue;
18
+ const mode = bundleDeploymentHistory(project)[provider]?.[frameworkRegistryId(id)];
19
+ if (mode?.copy || mode?.package) {
20
+ console.log(`${id} for ${provider}: kept (${mode?.copy ? 'copy' : 'package'} mode); run \`aiwg remove ${id}\` to delete`);
21
+ handled.add(`${provider}:${id}`);
22
+ continue;
23
+ }
24
+ const others = Object.keys(entry.deployedTo).filter(other => other !== provider);
25
+ const preserveRoots = deployedSkillRoots(project, provider).filter(root => others.some(other => deployedSkillRoots(project, other).includes(root)));
26
+ const historical = structuredClone(config);
27
+ historical.installed[id].deployedTo[provider] = {};
28
+ console.log(`${dryRun ? 'Would remove' : 'Removing'} ${id} for ${provider} (recorded hashes)`);
29
+ const result = await removeProjectLocalBundle(historical, project, id, { provider, dryRun, keepRegistry: true, preserveRoots });
30
+ for (const outcome of result.outcomes)
31
+ console.log(` ${outcome.deployedAbsPath}: ${outcome.message}`);
32
+ handled.add(`${provider}:${id}`);
33
+ }
34
+ }
35
+ return handled;
36
+ }
37
+ //# sourceMappingURL=bundle-hash-prune.js.map
@@ -0,0 +1,140 @@
1
+ // Reconcile provider bundle declarations through the existing receipt removal path.
2
+ import { providerCopyMode } from '../../providers/deployment-preservation.mjs';
3
+ import { bundleDeploymentHistory, markBundleReconciled } from './bundle-deployment-mode.js';
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import { readAiwgConfig } from '../../config/aiwg-config.js';
7
+ import { REGISTRY_ID_TO_USE_NAME, frameworkRegistryId } from '../../config/framework-aliases.js';
8
+ import { getProviderArtifactPathStrings, PROVIDER_IDS } from '../../providers/provider-definitions.js';
9
+ import { deployedSkillRoots } from '../../providers/deployed-skill-roots.js';
10
+ import { pruneUndeclaredHashes } from './bundle-hash-prune.js';
11
+ import { removeBundledDeployment } from './remove-bundled.js';
12
+ import { frameworkAdditiveBundles } from './use-additive-bundles.js';
13
+ import { getFrameworkRoot } from '../../channel/manager.mjs';
14
+ export const bundleUseName = (id) => REGISTRY_ID_TO_USE_NAME[id] ?? id;
15
+ export function bundleProviders(installed, id, requested) {
16
+ const entry = Object.entries(installed).find(([key]) => frameworkRegistryId(key) === frameworkRegistryId(id))?.[1];
17
+ return Object.keys(entry?.deployedTo ?? {}).filter(provider => !requested || requested.split(',').includes(provider));
18
+ }
19
+ export async function expectedBundleOwners(config, provider, frameworkRoot) {
20
+ const selected = Object.keys(config.installed).filter(id => bundleProviders(config.installed, id, provider).length);
21
+ const expected = new Set(selected.map(frameworkRegistryId));
22
+ for (const id of selected) {
23
+ if (!(id === 'all' || fs.existsSync(path.join(frameworkRoot, 'agentic/code/frameworks', frameworkRegistryId(id), 'manifest.json'))
24
+ || ['writing', 'general'].includes(id)))
25
+ continue;
26
+ const flags = config.installed[id].deployedTo[provider];
27
+ if (id === 'all' && provider !== 'flue' && (flags.skipUtils !== undefined || flags.kernelOnly !== undefined)) {
28
+ expected.delete('all');
29
+ for (const name of fs.readdirSync(path.join(frameworkRoot, 'agentic/code/frameworks'))) {
30
+ if (fs.existsSync(path.join(frameworkRoot, 'agentic/code/frameworks', name, 'manifest.json')))
31
+ expected.add(frameworkRegistryId(name));
32
+ }
33
+ }
34
+ // Unknown history must retain the broader additive surface.
35
+ const { addons, extensions } = await frameworkAdditiveBundles(frameworkRoot, provider, flags.skipUtils === true, flags.kernelOnly === true);
36
+ for (const owner of [...addons, ...extensions])
37
+ expected.add(frameworkRegistryId(owner));
38
+ }
39
+ if (provider !== 'flue')
40
+ for (const id of selected) {
41
+ const addon = frameworkRegistryId(id);
42
+ if (!fs.existsSync(path.join(frameworkRoot, 'agentic/code/addons', addon, 'manifest.json')))
43
+ continue;
44
+ const { resolveRequiredAddonActivationOrder } = await import('./use.js');
45
+ for (const owner of await resolveRequiredAddonActivationOrder(frameworkRoot, addon))
46
+ expected.add(frameworkRegistryId(owner));
47
+ }
48
+ return expected;
49
+ }
50
+ function receiptOwners(project, provider) {
51
+ const owners = new Set();
52
+ const visit = (file) => {
53
+ const stat = fs.lstatSync(file, { throwIfNoEntry: false });
54
+ if (!stat || stat.isSymbolicLink())
55
+ return;
56
+ if (stat.isDirectory()) {
57
+ for (const name of fs.readdirSync(file))
58
+ visit(path.join(file, name));
59
+ return;
60
+ }
61
+ if (path.basename(file) !== '.aiwg-manifest.json')
62
+ return;
63
+ const receipt = JSON.parse(fs.readFileSync(file, 'utf8'));
64
+ for (const record of Object.values(receipt.managed ?? {})) {
65
+ for (const owner of record.owners ?? (record.frameworkSlug ? [record.frameworkSlug] : []))
66
+ owners.add(owner);
67
+ }
68
+ };
69
+ const paths = Object.values(getProviderArtifactPathStrings(provider) ?? {}).filter(Boolean);
70
+ // Never follow provider home paths during project reconciliation.
71
+ const roots = paths.filter(dir => !path.isAbsolute(dir) && !dir.startsWith('~')).map(dir => path.join(project, dir.split(/[\\/]/)[0]));
72
+ for (const root of new Set([...roots, ...deployedSkillRoots(project, provider).filter(dir => dir.startsWith(`${project}${path.sep}`))]))
73
+ visit(root);
74
+ // Flue's generated app modules live in the project-scoped receipt.
75
+ if (provider === 'flue')
76
+ visit(path.join(project, '.aiwg/.aiwg-manifest.json'));
77
+ return owners;
78
+ }
79
+ export async function pruneUndeclaredBundles(project, config, requested, dryRun = false, frameworkRoot) {
80
+ if (!config)
81
+ return 0;
82
+ if (requested?.split(',').some(provider => !getProviderArtifactPathStrings(provider))) {
83
+ console.error(`Cannot reconcile unknown provider: ${requested}`);
84
+ return 1;
85
+ }
86
+ const history = bundleDeploymentHistory(project);
87
+ const hashPruned = await pruneUndeclaredHashes(project, config, requested, dryRun);
88
+ let failures = 0;
89
+ const knownProviders = [...new Set([...Object.keys(history), ...(config.providers ?? []), ...Object.values(config.installed).flatMap(entry => Object.keys(entry.deployedTo ?? {})),
90
+ ...PROVIDER_IDS.filter(provider => fs.existsSync(path.join(project, `.${provider}`)))])];
91
+ const providers = requested ? requested.split(',') : knownProviders;
92
+ const root = frameworkRoot ?? await getFrameworkRoot();
93
+ const expected = new Map();
94
+ for (const provider of new Set([...knownProviders, ...providers])) {
95
+ if (getProviderArtifactPathStrings(provider))
96
+ expected.set(provider, await expectedBundleOwners(config, provider, root));
97
+ }
98
+ for (const provider of providers) {
99
+ for (const owner of Object.keys(history[provider] ?? {})) {
100
+ if (!history[provider][owner].reconciled && !bundleProviders(config.installed, owner, provider).length)
101
+ expected.get(provider)?.delete(owner);
102
+ }
103
+ if (!getProviderArtifactPathStrings(provider))
104
+ continue;
105
+ const selected = expected.get(provider);
106
+ for (const owner of receiptOwners(project, provider)) {
107
+ if (hashPruned.has(`${provider}:${owner}`) || (selected.has('all') && provider !== 'flue') || selected.has(frameworkRegistryId(owner)))
108
+ continue;
109
+ const implicit = !history[provider]?.[frameworkRegistryId(owner)] && Object.values(history[provider] ?? {}).some(entry => entry.produces?.includes(frameworkRegistryId(owner)) || entry.produces?.includes('*'));
110
+ if (implicit)
111
+ continue;
112
+ if (providerCopyMode(project, provider, owner, config)) {
113
+ console.log(`${bundleUseName(owner)} for ${provider}: kept (copy mode); run \`aiwg remove ${bundleUseName(owner)}\` to delete`);
114
+ continue;
115
+ }
116
+ const otherProviders = [...expected].filter(([other, owners]) => other !== provider
117
+ && (history[other]?.[frameworkRegistryId(owner)]?.copy || history[other]?.[frameworkRegistryId(owner)]?.package || owners.has(frameworkRegistryId(owner)) || other !== 'flue' && owners.has('all'))).map(([other]) => other);
118
+ const sharedRoots = deployedSkillRoots(project, provider).filter(root => otherProviders.some(other => deployedSkillRoots(project, other).includes(root)));
119
+ console.log(`${dryRun ? 'Would remove' : 'Removing'} ${bundleUseName(owner)} for ${provider}`);
120
+ // A temporary historical record supplies context for the public per-bundle
121
+ // remover. --keep-registry leaves the operator's declaration byte-for-byte.
122
+ const historical = structuredClone(config);
123
+ historical.installed[owner] = { deployedTo: { [provider]: { agents: 0, commands: 0, skills: 0, rules: 0 } } };
124
+ const result = await removeBundledDeployment(project, owner, owner, historical, [provider], { dryRun, keepRegistry: true, preserveRoots: sharedRoots, includeProject: !otherProviders.length });
125
+ if (result.message)
126
+ console.log(result.message);
127
+ if (result.exitCode)
128
+ failures++;
129
+ else if (!dryRun)
130
+ markBundleReconciled(project, owner, provider);
131
+ }
132
+ }
133
+ return failures;
134
+ }
135
+ // Root collectors can recreate additive copies; enforce a recorded restricted scope last.
136
+ export async function pruneAfterScopedDeployments(project, config, requested, frameworkRoot) {
137
+ const restricted = Object.values(config?.installed ?? {}).some(entry => Object.entries(entry.deployedTo).some(([provider, flags]) => (!requested || requested.split(',').includes(provider)) && (flags.skipUtils === true || flags.kernelOnly === true)));
138
+ return restricted ? pruneUndeclaredBundles(project, await readAiwgConfig(project), requested, false, frameworkRoot) : 0;
139
+ }
140
+ //# sourceMappingURL=bundle-reconciliation.js.map
@@ -159,7 +159,7 @@ function displayHelp() {
159
159
  ui.rule();
160
160
  ui.blank();
161
161
  const providers = listProviderDefinitions().filter(({ id }) => id !== 'generic');
162
- console.log(` ${ui.dimText('Providers:')} ${providers.length} — ${providers.map(({ id }) => id).join(', ')} (default: claude; aliases: agy → antigravity, devin → windsurf, oh-my-pi → omp)`);
162
+ console.log(` ${ui.dimText('Providers:')} ${providers.length} — ${providers.map(({ id, status }) => status === 'experimental' ? `${id} (experimental)` : id).join(', ')} (default: claude; aliases: agy → antigravity, devin → windsurf, oh-my-pi → omp)`);
163
163
  ui.blank();
164
164
  console.log(` ${ui.dimText('Examples:')}`);
165
165
  console.log(` aiwg use sdlc ${ui.dimText('Install SDLC framework')}`);