@jstn-sdk/ma 0.1.11 → 0.1.13
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/.codex/agents/Architect.toml +0 -2
- package/.codex/agents/Auditor.toml +0 -2
- package/.codex/agents/Builder.toml +0 -2
- package/.codex/agents/Flow.toml +0 -2
- package/.codex/agents/Sage.toml +0 -2
- package/.codex/agents/Vibe.toml +0 -2
- package/.codex/hooks.json +14 -13
- package/.codex/prompts/enforcement.md +4 -0
- package/.codex/prompts/skill-contract.md +4 -0
- package/COVERAGE.md +211 -0
- package/DEMO.md +265 -0
- package/README.md +287 -37
- package/bin/ma.js +232 -71
- package/data/clone-data.ledger.json +41 -0
- package/data/clone-data.proof.json +50 -0
- package/data/clone-data.rvf +37 -0
- package/docs/README.md +7 -1
- package/docs/getting-started.md +108 -37
- package/docs/installed-sdk.md +23 -0
- package/docs/mcp-setup.md +65 -1
- package/docs/onboarding.md +18 -2
- package/docs/prompt-guidance-contract.md +17 -0
- package/docs/prompt-guidance-fragments/active-autonomy-core.md +7 -0
- package/docs/qa/release-issue-gates-0.1.13.json +644 -0
- package/docs/qa/release-readiness-0.1.13.md +116 -0
- package/docs/qa/release-readiness-0.1.5.md +1 -1
- package/docs/reference/native-engineering-patterns.md +35 -0
- package/docs/reference/native-security-playbooks.md +27 -0
- package/docs/reference/native-source-selection.md +27 -0
- package/docs/reference/native-style-and-deslop.md +20 -0
- package/docs/release-spec.md +37 -10
- package/docs/skills-publishing.md +25 -1
- package/docs/skills.md +37 -12
- package/index.js +222 -2
- package/mcp/collections.json +23 -6
- package/mcp/local/code-intel.js +113 -0
- package/mcp/local/memory.js +46 -0
- package/mcp/local/playbooks.js +168 -0
- package/mcp/local/state.js +71 -0
- package/mcp/local/team-run.js +113 -0
- package/mcp/local/trace.js +60 -0
- package/mcp/local-capabilities.json +56 -0
- package/mcp/native-playbooks.json +117 -0
- package/mcp/servers.json +34 -0
- package/package.json +8 -2
- package/plugins/meta-architect/.app.json +1 -1
- package/plugins/meta-architect/.codex-plugin/plugin.json +4 -4
- package/plugins/meta-architect/.mcp.json +1 -1
- package/plugins/meta-architect/README.md +34 -1
- package/plugins/meta-architect/obsidian/main.js +401 -0
- package/plugins/meta-architect/obsidian/manifest.json +9 -0
- package/plugins/meta-architect/obsidian/styles.css +7 -0
- package/plugins/meta-architect/skills/align/SKILL.md +24 -0
- package/plugins/meta-architect/skills/align/agents/openai.yaml +4 -0
- package/plugins/meta-architect/skills/align/references/shared-language.md +24 -0
- package/plugins/meta-architect/skills/arch/SKILL.md +2 -0
- package/plugins/meta-architect/skills/build/SKILL.md +3 -0
- package/plugins/meta-architect/skills/cleanup/SKILL.md +23 -0
- package/plugins/meta-architect/skills/cleanup/agents/openai.yaml +4 -0
- package/plugins/meta-architect/skills/cleanup/references/style-and-deslop.md +18 -0
- package/plugins/meta-architect/skills/diagnose/SKILL.md +24 -0
- package/plugins/meta-architect/skills/diagnose/agents/openai.yaml +4 -0
- package/plugins/meta-architect/skills/flow/SKILL.md +2 -0
- package/plugins/meta-architect/skills/maestro/SKILL.md +36 -3
- package/plugins/meta-architect/skills/maestro/agents/openai.yaml +2 -2
- package/plugins/meta-architect/skills/maestro/references/native-ingest-map.md +44 -0
- package/plugins/meta-architect/skills/sage/SKILL.md +5 -1
- package/plugins/meta-architect/skills/sage/references/source-selection.md +36 -0
- package/plugins/meta-architect/skills/tdd/SKILL.md +24 -0
- package/plugins/meta-architect/skills/tdd/agents/openai.yaml +4 -0
- package/plugins/meta-architect/skills/vet/SKILL.md +5 -1
- package/plugins/meta-architect/skills/vet/references/security-playbooks.md +30 -0
- package/plugins/meta-architect/skills/vibe/SKILL.md +2 -0
- package/scripts/active-autonomy-hook.mjs +96 -0
- package/scripts/build-linux-packages.mjs +328 -0
- package/scripts/doctor.js +36 -4
- package/scripts/install.sh +28 -0
- package/scripts/linux-package-lib.mjs +40 -0
- package/scripts/linux-package-smoke.mjs +103 -0
- package/scripts/ralph/prompt.md +35 -0
- package/scripts/release-sync.js +13 -6
- package/scripts/release-verify.js +166 -1
- package/skills/align/SKILL.md +24 -0
- package/skills/align/agents/openai.yaml +4 -0
- package/skills/align/references/shared-language.md +24 -0
- package/skills/arch/SKILL.md +2 -0
- package/skills/build/SKILL.md +3 -0
- package/skills/cleanup/SKILL.md +23 -0
- package/skills/cleanup/agents/openai.yaml +4 -0
- package/skills/cleanup/references/style-and-deslop.md +18 -0
- package/skills/diagnose/SKILL.md +24 -0
- package/skills/diagnose/agents/openai.yaml +4 -0
- package/skills/flow/SKILL.md +2 -0
- package/skills/index.json +21 -6
- package/skills/maestro/SKILL.md +36 -3
- package/skills/maestro/agents/openai.yaml +2 -2
- package/skills/maestro/references/native-ingest-map.md +44 -0
- package/skills/sage/SKILL.md +5 -1
- package/skills/sage/references/source-selection.md +36 -0
- package/skills/tdd/SKILL.md +24 -0
- package/skills/tdd/agents/openai.yaml +4 -0
- package/skills/vet/SKILL.md +5 -1
- package/skills/vet/references/security-playbooks.md +30 -0
- package/skills/vibe/SKILL.md +2 -0
- package/src/bootstrap.js +141 -24
- package/src/build-gate.js +2 -2
- package/src/decision-log.js +12 -9
- package/src/launcher.js +4 -0
- package/src/mcp-config.js +130 -8
- package/src/mcp-live-client.js +289 -3
- package/src/paths.js +37 -1
- package/src/policy.js +1 -1
- package/src/release-issue-gates.js +190 -0
- package/src/release-state.js +30 -1
- package/src/runtime/active-autonomy-core.js +208 -0
- package/src/runtime/alignment-sentinel.js +165 -0
- package/src/runtime/architect-review.js +88 -0
- package/src/runtime/build-readiness.js +62 -0
- package/src/runtime/code-graph-rehearse.js +113 -0
- package/src/runtime/context-economy-core.js +276 -0
- package/src/runtime/continuity-notes.js +79 -0
- package/src/runtime/core-source-ingest.js +379 -0
- package/src/runtime/detached-provider.js +74 -0
- package/src/runtime/environment-awareness-core.js +460 -0
- package/src/runtime/exposure-catalog.js +276 -0
- package/src/runtime/guidance-stack.js +42 -0
- package/src/runtime/helper-orchestration-core.js +307 -0
- package/src/runtime/learning-loop-core.js +238 -0
- package/src/runtime/maestro-events.js +18 -0
- package/src/runtime/maestro-manager.js +605 -0
- package/src/runtime/maestro-state.js +125 -0
- package/src/runtime/mcp-policy.js +192 -0
- package/src/runtime/obsidian-integration-core.js +851 -0
- package/src/runtime/obsidian-plugin-bridge.js +739 -0
- package/src/runtime/orchestrator.js +158 -0
- package/src/runtime/prompt-strategy-core.js +230 -0
- package/src/runtime/quorum-review.js +90 -0
- package/src/runtime/ralph-execution-core.js +217 -0
- package/src/runtime/redaction-gateway.js +174 -0
- package/src/runtime/runtime-state.js +1223 -0
- package/src/runtime/semantic-recording-core.js +147 -0
- package/src/runtime/signal-hooks.js +67 -0
- package/src/runtime/skills-registry-export.js +670 -0
- package/src/runtime/startup-path.js +14 -0
- package/src/runtime/universal-plugin-broker-core.js +575 -0
- package/src/runtime/workspace-intelligence-runtime.js +674 -0
- package/src/runtime/workspace-virtualizer.js +102 -0
- package/src/runtime/workspaces.js +25 -0
- package/src/runtime-artifacts.js +407 -84
- package/src/skill-installer.js +53 -5
- package/src/skills.js +1454 -78
- package/src/state-sync.js +51 -8
- package/docs/qa/release-readiness-0.1.11.md +0 -79
- package/plugins/meta-architect/skills/meta-architect/SKILL.md +0 -32
- package/plugins/meta-architect/skills/meta-architect/agents/openai.yaml +0 -4
- package/skills/meta-architect/SKILL.md +0 -32
- package/skills/meta-architect/agents/openai.yaml +0 -4
- /package/plugins/meta-architect/skills/{meta-architect → maestro}/references/core-release-rules.md +0 -0
- /package/skills/{meta-architect → maestro}/references/core-release-rules.md +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Native Ingest Map
|
|
2
|
+
|
|
3
|
+
Meta-Architect absorbs new pattern families as native product guidance without turning them into new umbrella brands or new release gates.
|
|
4
|
+
|
|
5
|
+
## Publishable helper skills
|
|
6
|
+
|
|
7
|
+
- `align`
|
|
8
|
+
- purpose: scope alignment, shared language, and docs clarity
|
|
9
|
+
- gate effect: none
|
|
10
|
+
- `diagnose`
|
|
11
|
+
- purpose: failure decomposition, blocked-lane triage, and root-cause framing
|
|
12
|
+
- gate effect: none
|
|
13
|
+
- `tdd`
|
|
14
|
+
- purpose: regression-first and test-first execution scaffolds
|
|
15
|
+
- gate effect: none
|
|
16
|
+
- `cleanup`
|
|
17
|
+
- purpose: anti-slop cleanup, prose humanization, and final-pass polish
|
|
18
|
+
- gate effect: none
|
|
19
|
+
|
|
20
|
+
## Existing-lane absorption
|
|
21
|
+
|
|
22
|
+
- `$sage`
|
|
23
|
+
- owns source selection, upstream validation order, and evidence quality
|
|
24
|
+
- uses curated native reference packs instead of raw catalog browsing as the product surface
|
|
25
|
+
- `$vet`
|
|
26
|
+
- owns security/trust-boundary review and security playbook application
|
|
27
|
+
- absorbs security playbook patterns without creating a second security umbrella
|
|
28
|
+
- `$maestro`
|
|
29
|
+
- remains the only umbrella surface and bounded autonomous manager
|
|
30
|
+
- owns next-step recommendation, helper handoff decisions, and fixed-sequence management
|
|
31
|
+
- does not create new gate states and does not replace the outputs owned by gated lanes
|
|
32
|
+
|
|
33
|
+
## Fixed gated sequence
|
|
34
|
+
|
|
35
|
+
The release-owned sequence does not change in this ingest:
|
|
36
|
+
|
|
37
|
+
1. `$arch`
|
|
38
|
+
2. `$sage`
|
|
39
|
+
3. `$flow`
|
|
40
|
+
4. `$vet`
|
|
41
|
+
5. `$vibe`
|
|
42
|
+
6. `$build`
|
|
43
|
+
|
|
44
|
+
Helper skills remain publishable but non-gating. They can prepare, unblock, or clean up work around those lanes, but they do not create new gate states and they do not own release-state transitions.
|
|
@@ -5,14 +5,16 @@ description: "Use when the user wants evidence-backed technology choices, OSS ev
|
|
|
5
5
|
|
|
6
6
|
# Sage
|
|
7
7
|
|
|
8
|
-
Use this skill inside Codex to verify or challenge stack choices with real sources.
|
|
8
|
+
Use this skill inside Codex to verify or challenge stack choices with real sources. `$sage` remains the evidence gate even as Meta-Architect absorbs more native curation and reference packs.
|
|
9
9
|
|
|
10
10
|
## Output
|
|
11
11
|
|
|
12
12
|
Produce:
|
|
13
13
|
- candidate tools, libraries, or services
|
|
14
|
+
- `decision`, `status`, `evidence`, `blockers`, `next_allowed_triggers`
|
|
14
15
|
- why each option fits or fails the architecture
|
|
15
16
|
- source-backed evidence from official docs, upstream repos, or approved GitMCP sources
|
|
17
|
+
- evidence grade and exact upstream mapping
|
|
16
18
|
- recommendation with tradeoffs
|
|
17
19
|
- unresolved gaps or missing evidence
|
|
18
20
|
- exact next trigger, usually `$flow`
|
|
@@ -24,6 +26,7 @@ Produce:
|
|
|
24
26
|
- use discovery accelerators to find or narrow candidates
|
|
25
27
|
- map the selected candidate back to an exact upstream repo
|
|
26
28
|
- verify against upstream repos and official docs before approving it
|
|
29
|
+
- Use `references/source-selection.md` when you need the native source-selection contract, evidence ladder, or packaged discovery rules.
|
|
27
30
|
- Use approved discovery accelerators when you need faster OSS candidate discovery:
|
|
28
31
|
- Ossium (`https://ossium.live/home`) for trending, curated, YC-backed, and GSoC-linked OSS discovery
|
|
29
32
|
- Trendshift (`https://trendshift.io/`) for rising GitHub engagement and topic momentum
|
|
@@ -31,6 +34,7 @@ Produce:
|
|
|
31
34
|
- Libraries.io (`https://libraries.io/`) for package/dependency metadata, with caution because its public data is scraped and not validated/curated for accuracy
|
|
32
35
|
- Open Hub (`https://openhub.net/`) for project activity, contributor, and comparison signals
|
|
33
36
|
- Open-source Projects (`https://www.opensourceprojects.dev/`) for curated OSS discovery and detailed project writeups
|
|
37
|
+
- Discovery accelerators are candidate-finding tools, not approval surfaces. The user-facing Meta-Architect product stays native even when evidence sources are external.
|
|
34
38
|
- Do not invent package capabilities or maturity claims.
|
|
35
39
|
- Prefer primary sources over summaries when validating technical details.
|
|
36
40
|
- Do not treat discovery listings alone as VERIFIED evidence; promote candidates to upstream repos and official docs before approving them.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Source Selection
|
|
2
|
+
|
|
3
|
+
Use this reference pack inside `$sage` when the repo needs evidence-backed selection without turning raw catalogs into the product surface.
|
|
4
|
+
|
|
5
|
+
## Evidence order
|
|
6
|
+
|
|
7
|
+
1. Known upstream repo and official docs
|
|
8
|
+
2. Discovery accelerator to find or narrow candidates
|
|
9
|
+
3. Exact upstream repo mapping for the shortlisted candidate
|
|
10
|
+
4. Upstream repo plus official-doc verification before approval
|
|
11
|
+
|
|
12
|
+
## Discovery accelerator rules
|
|
13
|
+
|
|
14
|
+
- Use accelerators to reduce search time, not to replace validation.
|
|
15
|
+
- Treat listings, rankings, and trend signals as hints.
|
|
16
|
+
- Promote any serious candidate to an exact upstream repo before calling it VERIFIED.
|
|
17
|
+
- Keep user-facing guidance in Meta-Architect language rather than echoing catalog branding as if it were a first-class product surface.
|
|
18
|
+
|
|
19
|
+
## Minimum approval bar
|
|
20
|
+
|
|
21
|
+
- Exact upstream repo identified
|
|
22
|
+
- Official docs available when relevant
|
|
23
|
+
- Claimed capability verified from a primary source
|
|
24
|
+
- Maturity caveats called out when evidence is weak
|
|
25
|
+
|
|
26
|
+
## Evidence grades
|
|
27
|
+
|
|
28
|
+
- `VERIFIED`: exact upstream mapping plus primary-source confirmation
|
|
29
|
+
- `PARTIAL`: candidate is mapped, but live proof or maturity proof is incomplete
|
|
30
|
+
- `MISSING`: no trustworthy exact upstream mapping yet
|
|
31
|
+
|
|
32
|
+
Always expose the evidence grade and the exact upstream mapping in user-facing `$sage` output.
|
|
33
|
+
|
|
34
|
+
## Native posture
|
|
35
|
+
|
|
36
|
+
Meta-Architect ships curated guidance and playbooks. It does not ship a raw mirror of external catalogs. External sources remain evidence inputs, not user-facing skill identities.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tdd
|
|
3
|
+
description: "Use when the user wants regression-first or test-first scaffolding before implementation work expands."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TDD
|
|
7
|
+
|
|
8
|
+
Use this skill inside Codex when implementation should start by locking behavior with tests. `tdd` is a non-gating helper skill that supports execution once the relevant lane is ready.
|
|
9
|
+
|
|
10
|
+
## Output
|
|
11
|
+
|
|
12
|
+
Produce:
|
|
13
|
+
- behavior to lock
|
|
14
|
+
- minimal regression or failing test shape
|
|
15
|
+
- implementation boundary
|
|
16
|
+
- proof that the test belongs to the requested change
|
|
17
|
+
- exact next trigger, usually the implementation lane or `$cleanup`
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
- Prefer the smallest failing test that proves the requested behavior.
|
|
22
|
+
- Lock current behavior before cleanup or refactor work when behavior is not already protected.
|
|
23
|
+
- Do not treat `tdd` as a replacement for the build gate.
|
|
24
|
+
- Keep test intent explicit so the next implementation step stays narrow.
|
|
@@ -5,21 +5,25 @@ description: "Use when the user wants a security and trust-boundary review of th
|
|
|
5
5
|
|
|
6
6
|
# Vet
|
|
7
7
|
|
|
8
|
-
Use this skill inside Codex to review security posture before the build lane.
|
|
8
|
+
Use this skill inside Codex to review security posture before the build lane. `$vet` remains the sole security gate even as Meta-Architect ships deeper native security playbooks.
|
|
9
9
|
|
|
10
10
|
## Output
|
|
11
11
|
|
|
12
12
|
Produce:
|
|
13
|
+
- `decision`, `status`, `evidence`, `blockers`, `next_allowed_triggers`
|
|
13
14
|
- trust boundaries
|
|
14
15
|
- authn/authz expectations
|
|
15
16
|
- sensitive data paths
|
|
16
17
|
- abuse cases and likely failure modes
|
|
17
18
|
- concrete mitigations
|
|
19
|
+
- accepted risks
|
|
18
20
|
- release blockers vs acceptable risks
|
|
19
21
|
- exact next trigger, usually `$vibe`
|
|
20
22
|
|
|
21
23
|
## Rules
|
|
22
24
|
|
|
23
25
|
- Prioritize material risks over exhaustive but low-value checklists.
|
|
26
|
+
- Use `references/security-playbooks.md` when you need the native security playbook set for common trust-boundary reviews.
|
|
27
|
+
- Keep security guidance product-owned and lane-aware. Do not introduce a second umbrella or a separate security release gate.
|
|
24
28
|
- Call out missing assumptions that affect security posture.
|
|
25
29
|
- Distinguish between must-fix blockers and documented accepted risk.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Security Playbooks
|
|
2
|
+
|
|
3
|
+
Use this reference pack inside `$vet` for repeatable trust-boundary reviews that stay native to Meta-Architect.
|
|
4
|
+
|
|
5
|
+
## Core review slices
|
|
6
|
+
|
|
7
|
+
- identity and session boundaries
|
|
8
|
+
- authorization and tenancy boundaries
|
|
9
|
+
- secret handling and key rotation assumptions
|
|
10
|
+
- dependency and supply-chain trust
|
|
11
|
+
- inbound data validation and outbound data exposure
|
|
12
|
+
- operational abuse cases and failure modes
|
|
13
|
+
|
|
14
|
+
## How to use the playbooks
|
|
15
|
+
|
|
16
|
+
- Start with the architecture and evidence already approved by `$arch` and `$sage`.
|
|
17
|
+
- Focus on the highest-risk boundary first.
|
|
18
|
+
- Distinguish blockers from accepted risk.
|
|
19
|
+
- Route remediation back to the owning lane rather than creating a parallel security workflow.
|
|
20
|
+
|
|
21
|
+
## Adversarial hardening
|
|
22
|
+
|
|
23
|
+
- For higher-risk changes, run a bounded adversarial hardening pass before final approval.
|
|
24
|
+
- Keep the hardening work inside the private scratchpad/runtime layer.
|
|
25
|
+
- Return structured findings, not direct gate mutations.
|
|
26
|
+
- If the hardening pass cannot resolve or clearly classify the risk, keep `$vet` in a non-terminal state instead of over-approving.
|
|
27
|
+
|
|
28
|
+
## Product boundary
|
|
29
|
+
|
|
30
|
+
This pack deepens `$vet`; it does not create a new security skill family. Security patterns are packaged as Meta-Architect guidance, not as mirrored external catalogs or branded upstream surfaces.
|
|
@@ -10,8 +10,10 @@ Use this skill inside Codex to review whether the system will feel coherent for
|
|
|
10
10
|
## Output
|
|
11
11
|
|
|
12
12
|
Produce:
|
|
13
|
+
- `decision`, `status`, `evidence`, `blockers`, `next_allowed_triggers`
|
|
13
14
|
- developer workflow risks
|
|
14
15
|
- user workflow risks
|
|
16
|
+
- operator friction and user friction
|
|
15
17
|
- complexity hotspots
|
|
16
18
|
- onboarding or operability friction
|
|
17
19
|
- simplifications that improve clarity
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import {
|
|
6
|
+
createDefaultActiveAutonomyCore,
|
|
7
|
+
detectPassivePermissionHandoff,
|
|
8
|
+
} from "../src/runtime/active-autonomy-core.js";
|
|
9
|
+
|
|
10
|
+
const DEFAULT_RESPONSE =
|
|
11
|
+
"AUTO-CONTINUE: continue the current safe branch, execute the next reversible step, then verify before reporting.";
|
|
12
|
+
|
|
13
|
+
async function readStdinJson() {
|
|
14
|
+
const chunks = [];
|
|
15
|
+
for await (const chunk of process.stdin) {
|
|
16
|
+
chunks.push(chunk);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
20
|
+
if (!raw) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(raw);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
return {
|
|
28
|
+
type: "invalid-hook-payload",
|
|
29
|
+
raw,
|
|
30
|
+
parseError: error instanceof Error ? error.message : String(error),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function extractAssistantText(payload) {
|
|
36
|
+
const candidates = [
|
|
37
|
+
payload.last_assistant_message,
|
|
38
|
+
payload["last-assistant-message"],
|
|
39
|
+
payload.message,
|
|
40
|
+
payload.text,
|
|
41
|
+
payload.output,
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
for (const candidate of candidates) {
|
|
45
|
+
if (typeof candidate === "string" && candidate.trim()) {
|
|
46
|
+
return candidate;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (Array.isArray(payload.messages)) {
|
|
51
|
+
const assistant = [...payload.messages]
|
|
52
|
+
.reverse()
|
|
53
|
+
.find((message) => message?.role === "assistant" && typeof message.content === "string");
|
|
54
|
+
return assistant?.content ?? "";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function appendAudit(cwd, entry) {
|
|
61
|
+
const auditDir = path.join(cwd, ".ma", "hooks");
|
|
62
|
+
await fs.mkdir(auditDir, { recursive: true });
|
|
63
|
+
await fs.appendFile(
|
|
64
|
+
path.join(auditDir, "audit.log"),
|
|
65
|
+
`${JSON.stringify({ timestamp: new Date().toISOString(), ...entry })}\n`,
|
|
66
|
+
"utf8",
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const payload = await readStdinJson();
|
|
71
|
+
const cwd = payload.cwd || payload.working_directory || process.env.MA_ROOT || process.cwd();
|
|
72
|
+
const assistantText = extractAssistantText(payload);
|
|
73
|
+
const blocked = detectPassivePermissionHandoff(assistantText, createDefaultActiveAutonomyCore());
|
|
74
|
+
|
|
75
|
+
const result = blocked
|
|
76
|
+
? {
|
|
77
|
+
decision: "block",
|
|
78
|
+
reason: DEFAULT_RESPONSE,
|
|
79
|
+
stopReason: "active_autonomy_passive_handoff",
|
|
80
|
+
systemMessage:
|
|
81
|
+
"Meta-Architect Active Autonomy blocked passive permission-handoff wording on an AUTO-CONTINUE branch.",
|
|
82
|
+
}
|
|
83
|
+
: {
|
|
84
|
+
decision: "approve",
|
|
85
|
+
reason: "active_autonomy_no_passive_handoff_detected",
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
await appendAudit(cwd, {
|
|
89
|
+
hook: "active-autonomy",
|
|
90
|
+
event: payload.type || payload.event || "unknown",
|
|
91
|
+
decision: result.decision,
|
|
92
|
+
stopReason: result.stopReason,
|
|
93
|
+
assistantPreview: assistantText.slice(0, 200),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import fsp from "node:fs/promises";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
import {
|
|
9
|
+
getDebArtifactPath,
|
|
10
|
+
getLinuxPackageManifestPath,
|
|
11
|
+
getPackArtifactPath,
|
|
12
|
+
getPacmanArtifactPath,
|
|
13
|
+
getRpmArtifactPath,
|
|
14
|
+
LINUX_PACKAGE_NAME,
|
|
15
|
+
LINUX_PACKAGE_REVISION,
|
|
16
|
+
} from "./linux-package-lib.mjs";
|
|
17
|
+
|
|
18
|
+
const repoRoot = process.cwd();
|
|
19
|
+
const distRoot = path.join(repoRoot, "dist");
|
|
20
|
+
const packageJson = JSON.parse(await fsp.readFile(path.join(repoRoot, "package.json"), "utf8"));
|
|
21
|
+
const version = packageJson.version;
|
|
22
|
+
const packageName = packageJson.name;
|
|
23
|
+
const maintainer = packageJson.author;
|
|
24
|
+
const homepage = packageJson.homepage;
|
|
25
|
+
const description = packageJson.description;
|
|
26
|
+
|
|
27
|
+
function fail(message) {
|
|
28
|
+
throw new Error(message);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function run(command, args, options = {}) {
|
|
32
|
+
const result = spawnSync(command, args, {
|
|
33
|
+
encoding: "utf8",
|
|
34
|
+
stdio: "pipe",
|
|
35
|
+
...options,
|
|
36
|
+
});
|
|
37
|
+
if (result.stdout) {
|
|
38
|
+
process.stdout.write(result.stdout);
|
|
39
|
+
}
|
|
40
|
+
if (result.stderr) {
|
|
41
|
+
process.stderr.write(result.stderr);
|
|
42
|
+
}
|
|
43
|
+
if (result.status !== 0) {
|
|
44
|
+
fail(`${command} ${args.join(" ")} failed with status ${result.status ?? 1}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function copyDir(src, dest) {
|
|
49
|
+
await fsp.mkdir(dest, { recursive: true });
|
|
50
|
+
const entries = await fsp.readdir(src, { withFileTypes: true });
|
|
51
|
+
for (const entry of entries) {
|
|
52
|
+
const srcPath = path.join(src, entry.name);
|
|
53
|
+
const destPath = path.join(dest, entry.name);
|
|
54
|
+
if (entry.isDirectory()) {
|
|
55
|
+
await copyDir(srcPath, destPath);
|
|
56
|
+
} else {
|
|
57
|
+
await fsp.copyFile(srcPath, destPath);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function writeExecutable(filePath, content) {
|
|
63
|
+
await fsp.writeFile(filePath, content, { mode: 0o755 });
|
|
64
|
+
await fsp.chmod(filePath, 0o755);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function getInstalledSizeBytes(root) {
|
|
68
|
+
let total = 0;
|
|
69
|
+
const entries = await fsp.readdir(root, { withFileTypes: true });
|
|
70
|
+
for (const entry of entries) {
|
|
71
|
+
const entryPath = path.join(root, entry.name);
|
|
72
|
+
if (entry.isDirectory()) {
|
|
73
|
+
total += await getInstalledSizeBytes(entryPath);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const stat = await fsp.stat(entryPath);
|
|
77
|
+
total += stat.size;
|
|
78
|
+
}
|
|
79
|
+
return total;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function createCommonRoot(root, packArtifactPath) {
|
|
83
|
+
const libRoot = path.join(root, "usr", "lib", LINUX_PACKAGE_NAME);
|
|
84
|
+
const binRoot = path.join(root, "usr", "bin");
|
|
85
|
+
await fsp.mkdir(libRoot, { recursive: true });
|
|
86
|
+
await fsp.mkdir(binRoot, { recursive: true });
|
|
87
|
+
run("tar", ["-xzf", packArtifactPath, "-C", libRoot, "--strip-components=1", "package"], {
|
|
88
|
+
cwd: repoRoot,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const wrapper = `#!/bin/sh
|
|
92
|
+
PREFIX="\${META_ARCHITECT_PREFIX:-}"
|
|
93
|
+
NODE_BIN="\${META_ARCHITECT_NODE_BIN:-node}"
|
|
94
|
+
if ! command -v "$NODE_BIN" >/dev/null 2>&1; then
|
|
95
|
+
echo "meta-architect requires nodejs >= 20 on the host system." >&2
|
|
96
|
+
exit 127
|
|
97
|
+
fi
|
|
98
|
+
if ! command -v git >/dev/null 2>&1; then
|
|
99
|
+
echo "meta-architect requires git on the host system." >&2
|
|
100
|
+
exit 127
|
|
101
|
+
fi
|
|
102
|
+
exec "$NODE_BIN" "\${PREFIX}/usr/lib/${LINUX_PACKAGE_NAME}/bin/ma.js" "$@"
|
|
103
|
+
`;
|
|
104
|
+
await writeExecutable(path.join(binRoot, "ma"), wrapper);
|
|
105
|
+
await writeExecutable(path.join(binRoot, "meta-architect"), wrapper);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function buildDeb(commonRoot, artifactPath) {
|
|
109
|
+
const debRoot = `${commonRoot}-deb`;
|
|
110
|
+
await fsp.rm(debRoot, { recursive: true, force: true });
|
|
111
|
+
await copyDir(commonRoot, debRoot);
|
|
112
|
+
const controlRoot = path.join(debRoot, "DEBIAN");
|
|
113
|
+
await fsp.mkdir(controlRoot, { recursive: true });
|
|
114
|
+
await fsp.writeFile(
|
|
115
|
+
path.join(controlRoot, "control"),
|
|
116
|
+
`Package: ${LINUX_PACKAGE_NAME}
|
|
117
|
+
Version: ${version}
|
|
118
|
+
Section: devel
|
|
119
|
+
Priority: optional
|
|
120
|
+
Architecture: all
|
|
121
|
+
Maintainer: ${maintainer}
|
|
122
|
+
Depends: nodejs (>= 20), git
|
|
123
|
+
Description: ${description}
|
|
124
|
+
Meta-Architect installs the Codex-native Meta-Architect workflow surface
|
|
125
|
+
without requiring npm package installation first.
|
|
126
|
+
Homepage: ${homepage}
|
|
127
|
+
`,
|
|
128
|
+
);
|
|
129
|
+
await fsp.rm(artifactPath, { force: true });
|
|
130
|
+
run("dpkg-deb", ["--root-owner-group", "--build", debRoot, artifactPath], { cwd: repoRoot });
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function buildPacman(commonRoot, artifactPath) {
|
|
134
|
+
const pacmanRoot = `${commonRoot}-pacman`;
|
|
135
|
+
await fsp.rm(pacmanRoot, { recursive: true, force: true });
|
|
136
|
+
await copyDir(commonRoot, pacmanRoot);
|
|
137
|
+
const installedSize = await getInstalledSizeBytes(path.join(pacmanRoot, "usr"));
|
|
138
|
+
const buildDate = Math.floor(Date.now() / 1000);
|
|
139
|
+
await fsp.writeFile(
|
|
140
|
+
path.join(pacmanRoot, ".PKGINFO"),
|
|
141
|
+
`pkgname = ${LINUX_PACKAGE_NAME}
|
|
142
|
+
pkgbase = ${LINUX_PACKAGE_NAME}
|
|
143
|
+
pkgver = ${version}-${LINUX_PACKAGE_REVISION}
|
|
144
|
+
pkgdesc = ${description}
|
|
145
|
+
url = ${homepage}
|
|
146
|
+
builddate = ${buildDate}
|
|
147
|
+
packager = ${maintainer}
|
|
148
|
+
size = ${installedSize}
|
|
149
|
+
arch = any
|
|
150
|
+
license = MIT
|
|
151
|
+
depend = nodejs
|
|
152
|
+
depend = git
|
|
153
|
+
`,
|
|
154
|
+
);
|
|
155
|
+
await fsp.writeFile(
|
|
156
|
+
path.join(pacmanRoot, ".BUILDINFO"),
|
|
157
|
+
`format = 2
|
|
158
|
+
pkgname = ${LINUX_PACKAGE_NAME}
|
|
159
|
+
pkgbase = ${LINUX_PACKAGE_NAME}
|
|
160
|
+
pkgver = ${version}-${LINUX_PACKAGE_REVISION}
|
|
161
|
+
pkgarch = any
|
|
162
|
+
packager = ${maintainer}
|
|
163
|
+
builddate = ${buildDate}
|
|
164
|
+
`,
|
|
165
|
+
);
|
|
166
|
+
await fsp.rm(artifactPath, { force: true });
|
|
167
|
+
run(
|
|
168
|
+
"tar",
|
|
169
|
+
[
|
|
170
|
+
"--sort=name",
|
|
171
|
+
"--mtime=@0",
|
|
172
|
+
"--owner=0",
|
|
173
|
+
"--group=0",
|
|
174
|
+
"--numeric-owner",
|
|
175
|
+
"-cJf",
|
|
176
|
+
artifactPath,
|
|
177
|
+
"-C",
|
|
178
|
+
pacmanRoot,
|
|
179
|
+
".PKGINFO",
|
|
180
|
+
".BUILDINFO",
|
|
181
|
+
"usr",
|
|
182
|
+
],
|
|
183
|
+
{ cwd: repoRoot },
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async function buildRpm(commonRoot, artifactPath) {
|
|
188
|
+
const rpmRoot = `${commonRoot}-rpmbuild`;
|
|
189
|
+
const topDir = path.join(rpmRoot, "topdir");
|
|
190
|
+
for (const dirName of ["BUILD", "BUILDROOT", "RPMS", "SOURCES", "SPECS", "SRPMS", "TMP", "DB"]) {
|
|
191
|
+
await fsp.mkdir(path.join(topDir, dirName), { recursive: true });
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const sourceRootName = `${LINUX_PACKAGE_NAME}-${version}`;
|
|
195
|
+
const sourceRoot = path.join(rpmRoot, sourceRootName);
|
|
196
|
+
await fsp.rm(sourceRoot, { recursive: true, force: true });
|
|
197
|
+
await copyDir(commonRoot, sourceRoot);
|
|
198
|
+
const sourceTarPath = path.join(topDir, "SOURCES", `${sourceRootName}.tar.gz`);
|
|
199
|
+
run("tar", ["-czf", sourceTarPath, "-C", rpmRoot, sourceRootName], { cwd: repoRoot });
|
|
200
|
+
|
|
201
|
+
const specPath = path.join(topDir, "SPECS", `${LINUX_PACKAGE_NAME}.spec`);
|
|
202
|
+
await fsp.writeFile(
|
|
203
|
+
specPath,
|
|
204
|
+
`Name: ${LINUX_PACKAGE_NAME}
|
|
205
|
+
Version: ${version}
|
|
206
|
+
Release: ${LINUX_PACKAGE_REVISION}%{?dist}
|
|
207
|
+
Summary: ${description}
|
|
208
|
+
License: MIT
|
|
209
|
+
URL: ${homepage}
|
|
210
|
+
BuildArch: noarch
|
|
211
|
+
Requires: nodejs >= 20
|
|
212
|
+
Requires: git
|
|
213
|
+
Source0: %{name}-%{version}.tar.gz
|
|
214
|
+
|
|
215
|
+
%description
|
|
216
|
+
Meta-Architect installs the Codex-native Meta-Architect workflow surface
|
|
217
|
+
without requiring npm package installation first.
|
|
218
|
+
|
|
219
|
+
%prep
|
|
220
|
+
%setup -q
|
|
221
|
+
|
|
222
|
+
%build
|
|
223
|
+
|
|
224
|
+
%install
|
|
225
|
+
rm -rf %{buildroot}
|
|
226
|
+
mkdir -p %{buildroot}
|
|
227
|
+
cp -a usr %{buildroot}/
|
|
228
|
+
|
|
229
|
+
%files
|
|
230
|
+
/usr/bin/ma
|
|
231
|
+
/usr/bin/meta-architect
|
|
232
|
+
/usr/lib/${LINUX_PACKAGE_NAME}
|
|
233
|
+
`,
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
await fsp.rm(artifactPath, { force: true });
|
|
237
|
+
run(
|
|
238
|
+
"rpmbuild",
|
|
239
|
+
[
|
|
240
|
+
"--define",
|
|
241
|
+
`_topdir ${topDir}`,
|
|
242
|
+
"--define",
|
|
243
|
+
`_tmppath ${path.join(topDir, "TMP")}`,
|
|
244
|
+
"--define",
|
|
245
|
+
`_dbpath ${path.join(topDir, "DB")}`,
|
|
246
|
+
"-bb",
|
|
247
|
+
specPath,
|
|
248
|
+
],
|
|
249
|
+
{
|
|
250
|
+
cwd: repoRoot,
|
|
251
|
+
env: {
|
|
252
|
+
...process.env,
|
|
253
|
+
HOME: rpmRoot,
|
|
254
|
+
TMPDIR: path.join(topDir, "TMP"),
|
|
255
|
+
QA_RPATHS: "0x0000",
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
);
|
|
259
|
+
const builtRpmPath = path.join(topDir, "RPMS", "noarch", path.basename(artifactPath));
|
|
260
|
+
await fsp.copyFile(builtRpmPath, artifactPath);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async function main() {
|
|
264
|
+
if (process.platform !== "linux") {
|
|
265
|
+
fail("Native Linux package builds are supported only on Linux hosts");
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
await fsp.mkdir(distRoot, { recursive: true });
|
|
269
|
+
const packArtifactPath = getPackArtifactPath(distRoot, packageName, version);
|
|
270
|
+
await fsp.rm(packArtifactPath, { force: true });
|
|
271
|
+
run(
|
|
272
|
+
"npm",
|
|
273
|
+
[
|
|
274
|
+
"pack",
|
|
275
|
+
".",
|
|
276
|
+
"--ignore-scripts",
|
|
277
|
+
"--cache",
|
|
278
|
+
path.join(distRoot, ".npm-cache"),
|
|
279
|
+
"--pack-destination",
|
|
280
|
+
distRoot,
|
|
281
|
+
],
|
|
282
|
+
{ cwd: repoRoot },
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
const workRoot = await fsp.mkdtemp(path.join(os.tmpdir(), "meta-architect-linux-packages-"));
|
|
286
|
+
const commonRoot = path.join(workRoot, "root");
|
|
287
|
+
await createCommonRoot(commonRoot, packArtifactPath);
|
|
288
|
+
|
|
289
|
+
const debArtifactPath = getDebArtifactPath(distRoot, version);
|
|
290
|
+
const pacmanArtifactPath = getPacmanArtifactPath(distRoot, version);
|
|
291
|
+
const rpmArtifactPath = getRpmArtifactPath(distRoot, version);
|
|
292
|
+
await buildDeb(commonRoot, debArtifactPath);
|
|
293
|
+
await buildPacman(commonRoot, pacmanArtifactPath);
|
|
294
|
+
await buildRpm(commonRoot, rpmArtifactPath);
|
|
295
|
+
|
|
296
|
+
await fsp.writeFile(
|
|
297
|
+
getLinuxPackageManifestPath(distRoot),
|
|
298
|
+
`${JSON.stringify(
|
|
299
|
+
{
|
|
300
|
+
version,
|
|
301
|
+
packageName,
|
|
302
|
+
linuxPackageName: LINUX_PACKAGE_NAME,
|
|
303
|
+
revision: LINUX_PACKAGE_REVISION,
|
|
304
|
+
artifacts: {
|
|
305
|
+
deb: path.basename(debArtifactPath),
|
|
306
|
+
pacman: path.basename(pacmanArtifactPath),
|
|
307
|
+
rpm: path.basename(rpmArtifactPath),
|
|
308
|
+
},
|
|
309
|
+
install: {
|
|
310
|
+
debian: `sudo apt install ./${path.basename(debArtifactPath)}`,
|
|
311
|
+
arch: `sudo pacman -U ./${path.basename(pacmanArtifactPath)}`,
|
|
312
|
+
rpm: `sudo dnf install ./${path.basename(rpmArtifactPath)}`,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
null,
|
|
316
|
+
2,
|
|
317
|
+
)}\n`,
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
console.log(debArtifactPath);
|
|
321
|
+
console.log(pacmanArtifactPath);
|
|
322
|
+
console.log(rpmArtifactPath);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
main().catch((error) => {
|
|
326
|
+
console.error(error.message);
|
|
327
|
+
process.exitCode = 1;
|
|
328
|
+
});
|