godpowers 1.6.15 → 1.6.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,61 @@ All notable changes to Godpowers will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.6.17] - 2026-05-16
9
+
10
+ Autonomous repository documentation sync.
11
+
12
+ ### Added
13
+ - Added `lib/repo-doc-sync.js` to detect and refresh mechanical repository
14
+ documentation claims.
15
+ - Added `docs/repo-doc-sync.md` with auto-invoke, auto-spawn, Pillars, and
16
+ arc-ready closeout behavior.
17
+ - Added behavioral tests for stale repo docs detection, safe mechanical sync,
18
+ sync logging, Pillars planning, and adjacent autonomous sync recommendations.
19
+ - Added missing `/god-export-otel` routing metadata.
20
+
21
+ ### Changed
22
+ - `/god-sync`, `/god-docs`, `/god-doctor`, `/god-status`, and `/god-mode` now
23
+ document repo documentation sync behavior.
24
+ - The dashboard proactive docs check now uses `lib/repo-doc-sync.detect`.
25
+ - Package contents checks now require `lib/repo-doc-sync.js` and
26
+ `routing/god-export-otel.yaml`.
27
+ - Release and contribution docs now describe repo documentation sync as part of
28
+ release readiness.
29
+
30
+ ### Guardrails
31
+ - Detection is read-only by default.
32
+ - Safe apply is limited to mechanical version, badge, and count claims.
33
+ - Narrative changelog, release, contribution, support, and security policy
34
+ changes route to `god-docs-writer` or the maintainer.
35
+
36
+ ## [1.6.16] - 2026-05-16
37
+
38
+ Feature awareness for existing Godpowers projects.
39
+
40
+ ### Added
41
+ - Added `lib/feature-awareness.js` to detect stale project awareness after a
42
+ Godpowers runtime upgrade.
43
+ - Added state recording for the current Godpowers feature set so existing
44
+ projects can tell whether their context has learned about new capabilities.
45
+ - Added behavioral tests for feature-awareness detection, safe state refresh,
46
+ AI-tool context refresh, migration suggestions, and `god-greenfieldifier`
47
+ escalation.
48
+
49
+ ### Changed
50
+ - `AGENTS.md` context refresh now advertises `/god-sync`, `/god-migrate`, and
51
+ `/god-context refresh` so AI tools opening an existing project see the new
52
+ migration and awareness commands.
53
+ - `/god-doctor`, `/god-context`, `/god-sync`, and `/god-mode` now document the
54
+ feature-awareness auto-invoke path for existing `.godpowers` projects.
55
+ - `state.v1.json` now accepts the `godpowers-features` awareness record.
56
+
57
+ ### Guardrails
58
+ - Detection is read-only by default.
59
+ - The apply path writes only safe state metadata and managed context fences.
60
+ - Ambiguous planning-system evidence is reported as a scoped
61
+ `god-greenfieldifier` recommendation instead of being converted blindly.
62
+
8
63
  ## [1.6.15] - 2026-05-16
9
64
 
10
65
  Planning-system migration and sync-back.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![CI](https://github.com/aihxp/godpowers/actions/workflows/ci.yml/badge.svg)](https://github.com/aihxp/godpowers/actions/workflows/ci.yml)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5
- [![Version](https://img.shields.io/badge/version-1.6.15-blue)](CHANGELOG.md)
5
+ [![Version](https://img.shields.io/badge/version-1.6.17-blue)](CHANGELOG.md)
6
6
  [![npm](https://img.shields.io/npm/v/godpowers.svg)](https://www.npmjs.com/package/godpowers)
7
7
 
8
8
  **Ship fast. Ship right. Ship everything. Ship accountably.**
@@ -12,13 +12,11 @@ idea to hardened production. It runs as **slash commands inside your AI coding
12
12
  tool** (Claude Code, Codex, Cursor, etc.) that orchestrate **specialist agents**
13
13
  in fresh contexts to do the work.
14
14
 
15
- Version 1.6.15 adds planning-system migration for teams arriving from GSD,
16
- BMAD, or Superpowers. `/god-init` now auto-detects those systems, imports
17
- useful context into Godpowers prep and seed artifacts, and records source
18
- systems in `state.json`. `/god-sync` now syncs current Godpowers progress back
19
- to managed companion files so teams can return to the prior system with a clear
20
- handoff trail. Ambiguous imports can auto-spawn `god-greenfieldifier` for a
21
- controlled migration plan.
15
+ Version 1.6.17 adds autonomous repository documentation sync. `/god-sync`,
16
+ `/god-docs`, `/god-doctor`, `/god-status`, and `/god-mode` can now detect stale
17
+ README badges, public surface counts, release docs, contribution guidance,
18
+ security policy, and Pillars context planning needs before a project run is
19
+ declared complete.
22
20
 
23
21
  It fuses four disciplines into one unified workflow:
24
22
 
@@ -228,6 +226,16 @@ managed sync-back files such as `.planning/GODPOWERS-SYNC.md`,
228
226
  `_bmad-output/GODPOWERS-SYNC.md`, or
229
227
  `docs/superpowers/GODPOWERS-SYNC.md`.
230
228
 
229
+ Existing Godpowers projects can refresh their awareness after an upgrade:
230
+
231
+ ```bash
232
+ /god-context refresh
233
+ ```
234
+
235
+ This records the current Godpowers feature set in `.godpowers/state.json`,
236
+ refreshes managed AI-tool context fences, and suggests `/god-migrate` or
237
+ `god-greenfieldifier` when source-system evidence needs migration judgment.
238
+
231
239
  For existing codebases and org-constrained new projects, God Mode now runs a
232
240
  greenfield simulation audit and then actions it through a greenfieldification
233
241
  plan. It pauses before risky artifact rewrites because that process can change
@@ -351,8 +359,10 @@ Pi. T3 Code inherits from the underlying agent (Codex / Claude / OpenCode).
351
359
  - [Getting Started](docs/getting-started.md)
352
360
  - [Concepts](docs/concepts.md)
353
361
  - [Command reference (all 109 skills + 40 agents)](docs/reference.md)
362
+ - [Feature awareness](docs/feature-awareness.md)
363
+ - [Repository documentation sync](docs/repo-doc-sync.md)
354
364
  - [Roadmap](docs/ROADMAP.md)
355
- - [1.5 Release Notes](RELEASE.md)
365
+ - [Release Notes](RELEASE.md)
356
366
  - [Changelog](CHANGELOG.md)
357
367
  - [Inspiration](INSPIRATION.md)
358
368
 
package/RELEASE.md CHANGED
@@ -1,10 +1,12 @@
1
- # Godpowers 1.6.15 Release
1
+ # Godpowers 1.6.17 Release
2
2
 
3
3
  Date: 2026-05-16
4
4
 
5
- Godpowers 1.6.15 adds automatic migration from GSD, BMAD, and Superpowers
6
- projects into Godpowers. The release also adds managed sync-back so a team can
7
- return to its prior planning system with current Godpowers progress visible.
5
+ Godpowers 1.6.17 adds autonomous repository documentation sync for release
6
+ surfaces and project-run closeout. Godpowers can now detect stale README badges,
7
+ public surface counts, release notes, changelog entries, contribution guidance,
8
+ security policy, and Pillars context planning needs before a sync, docs, doctor,
9
+ status, or god-mode closeout declares the repository current.
8
10
 
9
11
  ## What is stable
10
12
 
@@ -20,74 +22,60 @@ return to its prior planning system with current Godpowers progress visible.
20
22
  - `.godpowers/` workflow state and artifact layout
21
23
  - Safe-sync routing before deploy, observe, harden, launch, or god-mode work
22
24
  - Critical harden finding gate before launch
23
- - GSD-style proposition closeouts for exploratory, diagnostic, audit,
24
- lifecycle, status, reconciliation, and decision-support outputs
25
- - Plain-language project-run wording in user-facing reports
25
+ - Planning-system migration for GSD, BMAD, and Superpowers
26
+ - Managed sync-back companion files for imported source systems
27
+ - Feature awareness for existing Godpowers projects
26
28
 
27
29
  ## What is new
28
30
 
29
- - Added `lib/planning-systems.js` for GSD, BMAD, and Superpowers detection.
30
- - Added `lib/source-sync.js` for managed sync-back companion files.
31
- - Added `/god-migrate` as the explicit migration command.
32
- - `/god-init` now auto-invokes planning-system import when source systems are
33
- detected.
34
- - `/god-sync` now auto-invokes source-system sync-back when enabled source
35
- systems are recorded in `state.json`.
36
- - `reverse-sync` now returns source-system sync-back results.
37
- - `state.v1.json` now records source-system import and sync-back state.
38
- - Added `docs/planning-system-migration.md`.
31
+ - Added `lib/repo-doc-sync.js`.
32
+ - Added `docs/repo-doc-sync.md`.
33
+ - Added `scripts/test-repo-doc-sync.js`.
34
+ - Added missing `/god-export-otel` routing metadata.
35
+ - `/god-sync`, `/god-docs`, `/god-doctor`, `/god-status`, and `/god-mode` now
36
+ document repo documentation sync integration.
37
+ - The dashboard proactive docs check now reads repo documentation sync status.
38
+ - Package contents checks now require the repo documentation sync helper and
39
+ `/god-export-otel` routing metadata.
39
40
 
40
- ## Migration behavior
41
+ ## Sync behavior
41
42
 
42
- Godpowers detects:
43
+ For a Godpowers repository, the helper:
43
44
 
44
- - GSD: `.planning/`, `.gsd/`, `GSD.md`, and `gsd*.md`
45
- - BMAD: `_bmad/`, `_bmad-output/`, `.bmad-core/`, `.bmad/`, and `BMAD.md`
46
- - Superpowers: `docs/superpowers/`, `.superpowers/`, `SUPERPOWERS.md`, and
47
- project-local skills
45
+ - reads package version and repository surface counts
46
+ - detects stale mechanical claims in README, user docs, architecture docs,
47
+ roadmap docs, command reference docs, `/god-version`, and `/god-doctor`
48
+ - applies safe mechanical badge, version, and count refreshes when requested
49
+ - plans Pillars sync for changed repo documentation paths
50
+ - recommends `god-docs-writer` for release notes, changelog, contribution,
51
+ support, or security policy prose
48
52
 
49
- Imported context is written to `.godpowers/prep/IMPORTED-CONTEXT.md`.
50
- Missing Godpowers seed artifacts are created only when source evidence exists.
51
- Existing Godpowers artifacts are preserved unless the user explicitly forces an
52
- overwrite.
53
-
54
- ## Sync-back behavior
55
-
56
- Godpowers writes managed companion files:
57
-
58
- - GSD: `.planning/GODPOWERS-SYNC.md` or `.gsd/GODPOWERS-SYNC.md`
59
- - BMAD: `_bmad-output/GODPOWERS-SYNC.md` or `.bmad/GODPOWERS-SYNC.md`
60
- - Superpowers: `docs/superpowers/GODPOWERS-SYNC.md` or
61
- `.superpowers/GODPOWERS-SYNC.md`
62
-
63
- Pointer fences are written only when a safe native state file already exists.
64
- Godpowers never rewrites source-system prose outside managed fences.
53
+ Detection is read-only by default. Applying sync does not invent narrative
54
+ release notes, changelog entries, contribution policy, support policy, or
55
+ security support policy.
65
56
 
66
57
  ## Auto-invoke and auto-spawn policy
67
58
 
68
- The import path is local runtime work and must be reported as:
59
+ Safe repo documentation sync is local runtime work and must be reported as:
69
60
 
70
- ```
61
+ ```text
71
62
  Agent: none, local runtime only
72
63
  ```
73
64
 
74
- The sync-back path is also local runtime work and must be reported the same
75
- way.
76
-
77
- Godpowers spawns `god-greenfieldifier` only when import confidence is low,
78
- multiple source systems conflict, or canonical seed artifacts cannot be safely
79
- created from available evidence.
65
+ Godpowers recommends or spawns `god-docs-writer` only when narrative docs need
66
+ claim verification or policy judgment after local mechanical sync has finished.
80
67
 
81
68
  ## Validation
82
69
 
83
70
  Release validation includes:
84
71
 
72
+ - `node scripts/test-repo-doc-sync.js`
73
+ - `node scripts/test-feature-awareness.js`
74
+ - `node scripts/test-context-writer.js`
85
75
  - `node scripts/test-planning-systems.js`
86
- - `node scripts/test-reverse-sync.js`
87
- - `npm test`
88
- - `npm run test:audit`
89
- - `node scripts/check-package-contents.js`
76
+ - `node scripts/test-doc-surface-counts.js`
77
+ - `node scripts/validate-skills.js`
90
78
  - `git diff --check`
91
79
 
92
- The `v1.6.15` git tag points to the release commit that matches the npm
93
- `godpowers@1.6.15` package.
80
+ The `v1.6.17` tag should point to the release commit that matches the npm
81
+ `godpowers@1.6.17` package.
package/SKILL.md CHANGED
@@ -154,7 +154,7 @@ Proactive checks:
154
154
  Checkpoint: <fresh | refreshed | missing | stale | conflicts with state.json>
155
155
  Reviews: <none | N pending, suggest /god-review-changes>
156
156
  Sync: <fresh | missing | stale | local helper ran | suggest /god-sync>
157
- Docs: <fresh | possible drift, suggest /god-docs>
157
+ Docs: <fresh | N stale, suggest /god-docs | repo-doc-sync ran>
158
158
  Runtime: <not-applicable | known URL, suggest /god-test-runtime | no known URL, defer deployed verification>
159
159
  Automation: <not configured | N active | available via provider, suggest /god-automation-setup>
160
160
  Security: <clear | sensitive files changed, suggest /god-harden>
@@ -214,7 +214,7 @@ Auto-invoked:
214
214
  Trigger: <what caused this automatic step>
215
215
  Agent: <god-updater | god-context-writer | none, local runtime only>
216
216
  Local syncs:
217
- + <planning-system-import | reverse-sync | source-sync | pillars-sync | checkpoint-sync | context-refresh>: <result or skipped reason>
217
+ + <feature-awareness | planning-system-import | reverse-sync | source-sync | repo-doc-sync | pillars-sync | checkpoint-sync | context-refresh>: <result or skipped reason>
218
218
  Artifacts: <changed files, no-op, or deferred>
219
219
  Log: <SYNC-LOG.md, CHECKPOINT.md, REVIEW-REQUIRED.md, or none>
220
220
  ```
@@ -240,6 +240,10 @@ Automatic steps that especially need visible reporting:
240
240
  `/god-automation-status`, and `/god-automation-setup`
241
241
  - planning-system import during `/god-init` or `/god-migrate`
242
242
  - source-system sync-back during `/god-sync`, `/god-scan`, or `/god-migrate`
243
+ - feature-awareness refresh during `/god-doctor`, `/god-context`,
244
+ `/god-sync`, or `/god-mode`
245
+ - repo documentation sync during `/god-sync`, `/god-docs`, `/god-doctor`,
246
+ `/god-status`, or `/god-mode`
243
247
 
244
248
  ### 13. Proactive Auto-Invoke Policy
245
249
  Godpowers should be proactive from disk evidence, not from guesswork. Before
@@ -272,6 +276,14 @@ Run these local runtime helpers automatically when their trigger is present:
272
276
  `/god-migrate`.
273
277
  - `lib/source-sync.run` when `state.json` records enabled `source-systems`
274
278
  entries and `/god-sync`, `/god-scan`, or `/god-migrate` closes a workflow.
279
+ - `lib/feature-awareness.detect` during `/god-doctor` and
280
+ `lib/feature-awareness.run` during `/god-context`, `/god-sync`, or
281
+ `/god-mode` when an initialized `.godpowers` project lacks current runtime
282
+ feature metadata or managed AI-tool context fences.
283
+ - `lib/repo-doc-sync.detect` during `/god-status` and `/god-doctor`, and
284
+ `lib/repo-doc-sync.run` during `/god-sync`, `/god-docs`, or `/god-mode`
285
+ when README badges, public surface counts, release docs, contribution docs,
286
+ or security policy may have drifted.
275
287
  - Context refresh dry-run after `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`,
276
288
  `.cursor/rules/`, `.windsurfrules`, `.github/copilot-instructions.md`,
277
289
  `.clinerules`, `.roo/`, or `.continue/` changes.
@@ -285,6 +297,9 @@ Spawn these agents only when the trigger is direct and scope is bounded:
285
297
  artifacts.
286
298
  - `god-docs-writer` in drift-check mode when docs changed after code changed,
287
299
  or code changed after docs that claim current behavior.
300
+ - `god-docs-writer` when repo-doc-sync reports narrative drift in
301
+ `CHANGELOG.md`, `RELEASE.md`, `CONTRIBUTING.md`, `SECURITY.md`, or
302
+ `SUPPORT.md` after local mechanical sync has finished.
288
303
  - `god-browser-tester` when frontend-visible files changed and a known local,
289
304
  preview, staging, or production URL is evidenced.
290
305
  - `god-harden-auditor` suggestion after security-sensitive files changed;
@@ -299,6 +314,8 @@ Spawn these agents only when the trigger is direct and scope is bounded:
299
314
  - `god-greenfieldifier` when imported GSD, BMAD, or Superpowers context has
300
315
  low confidence, conflicting systems, or missing canonical Godpowers seed
301
316
  artifacts after local import.
317
+ - `god-greenfieldifier` when feature-awareness detects unimported or imported
318
+ source-system context that is low confidence or conflicting.
302
319
 
303
320
  #### Level 4: Explicit approval required
304
321
  Never auto-run these from inference alone:
package/lib/README.md CHANGED
@@ -12,6 +12,8 @@ package-level integrations.
12
12
  | `state-lock.js` | Coordinate state writes with a lock file. |
13
13
  | `intent.js` | Read and validate `intent.yaml` from project roots or `.godpowers/`. |
14
14
  | `checkpoint.js` | Create and inspect resumable checkpoint artifacts. |
15
+ | `feature-awareness.js` | Detect and refresh existing-project awareness after runtime upgrades. |
16
+ | `repo-doc-sync.js` | Detect and refresh mechanical repository documentation surfaces. |
15
17
  | `budget.js` | Read and enforce configured budget controls. |
16
18
  | `cost-tracker.js` | Track token and cost estimates from event streams. |
17
19
 
@@ -52,6 +54,8 @@ package-level integrations.
52
54
  |--------|---------|
53
55
  | `context-writer.js` | Produce tool-specific context files. |
54
56
  | `context-budget.js` | Keep generated context within budget. |
57
+ | `planning-systems.js` | Detect and import GSD, BMAD, and Superpowers planning context. |
58
+ | `source-sync.js` | Write managed Godpowers progress back to source-system companion files. |
55
59
  | `design-detector.js` | Detect design-system conventions. |
56
60
  | `design-spec.js` | Normalize design specifications. |
57
61
  | `awesome-design.js` | Validate design guidance against awesome-design rules. |
@@ -97,11 +97,10 @@ function buildCanonicalContent(state, opts = {}) {
97
97
  lines.push('');
98
98
  lines.push('- `/god-status` - re-derive state from disk');
99
99
  lines.push('- `/god-next` - what to run next, with reason');
100
- lines.push('- `/god <free text>` - match intent to a recipe');
101
100
  lines.push('- `/god-mode` - run the full autonomous project run');
102
- lines.push('- `/god-lint` - validate artifacts against have-nots');
103
- lines.push('- `/god-scan` - rebuild linkage map from code');
104
- lines.push('- `/god-review-changes` - walk REVIEW-REQUIRED.md');
101
+ lines.push('- `/god-sync` - refresh artifacts, context, and source-system sync-back');
102
+ lines.push('- `/god-migrate` - import or sync GSD, BMAD, or Superpowers context');
103
+ lines.push('- `/god-context refresh` - refresh AI-tool awareness for this project');
105
104
  lines.push('');
106
105
 
107
106
  // Pointers to design and product files when present
package/lib/dashboard.js CHANGED
@@ -12,6 +12,7 @@ const cp = require('child_process');
12
12
  const state = require('./state');
13
13
  const router = require('./router');
14
14
  const automationProviders = require('./automation-providers');
15
+ const repoDocSync = require('./repo-doc-sync');
15
16
 
16
17
  const GOD_DIR = '.godpowers';
17
18
  const PRD_PATH = '.godpowers/prd/PRD.md';
@@ -158,12 +159,16 @@ function proactiveChecks(projectRoot, changedFiles = []) {
158
159
  'auth',
159
160
  'security'
160
161
  ]));
162
+ const repoDocs = repoDocSync.detect(projectRoot, { changedFiles });
163
+ const repoDocsStatus = repoDocs.status === 'fresh'
164
+ ? 'fresh'
165
+ : `${repoDocs.stale.length} stale, suggest /god-docs`;
161
166
 
162
167
  return {
163
168
  checkpoint,
164
169
  reviews: reviews > 0 ? `${reviews} pending, suggest /god-review-changes` : 'none',
165
170
  sync,
166
- docs: 'fresh',
171
+ docs: repoDocsStatus,
167
172
  runtime: 'not-applicable',
168
173
  automation: automationSummary(projectRoot),
169
174
  security: sensitiveChanged ? 'sensitive files changed, suggest /god-harden' : 'clear',
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Godpowers Feature Awareness
3
+ *
4
+ * Keeps existing Godpowers projects aware of capabilities added by newer
5
+ * installed runtimes. This module is deliberately conservative: detect is
6
+ * read-only, run applies only safe state and context refreshes, and ambiguous
7
+ * migration cases are returned as spawn recommendations.
8
+ */
9
+
10
+ const fs = require('fs');
11
+ const path = require('path');
12
+
13
+ const state = require('./state');
14
+ const contextWriter = require('./context-writer');
15
+ const planningSystems = require('./planning-systems');
16
+
17
+ const FEATURE_SET_VERSION = 1;
18
+
19
+ const FEATURES = [
20
+ {
21
+ id: 'planning-system-migration',
22
+ since: '1.6.15',
23
+ commands: ['/god-migrate', '/god-init'],
24
+ description: 'Detect and import GSD, BMAD, and Superpowers planning artifacts.'
25
+ },
26
+ {
27
+ id: 'source-system-sync-back',
28
+ since: '1.6.15',
29
+ commands: ['/god-sync', '/god-migrate'],
30
+ description: 'Write managed Godpowers progress summaries back to detected source systems.'
31
+ },
32
+ {
33
+ id: 'feature-awareness',
34
+ since: '1.6.16',
35
+ commands: ['/god-doctor', '/god-context', '/god-sync', '/god-mode'],
36
+ description: 'Refresh existing Godpowers projects when the installed runtime gains new capabilities.'
37
+ },
38
+ {
39
+ id: 'repo-documentation-sync',
40
+ since: '1.6.17',
41
+ commands: ['/god-sync', '/god-docs', '/god-doctor', '/god-status', '/god-mode'],
42
+ description: 'Detect and refresh repository documentation surfaces, release docs, and Pillars planning signals.'
43
+ }
44
+ ];
45
+
46
+ function packageVersion(projectRoot) {
47
+ const candidates = [
48
+ path.join(__dirname, '..', 'package.json'),
49
+ path.join(projectRoot || process.cwd(), 'package.json')
50
+ ];
51
+ for (const candidate of candidates) {
52
+ if (!fs.existsSync(candidate)) continue;
53
+ try {
54
+ const parsed = JSON.parse(fs.readFileSync(candidate, 'utf8'));
55
+ if (parsed && parsed.name === 'godpowers' && parsed.version) return parsed.version;
56
+ } catch (err) {
57
+ // Ignore malformed package metadata. Awareness can still run with unknown.
58
+ }
59
+ }
60
+ return 'unknown';
61
+ }
62
+
63
+ function expectedFeatureIds() {
64
+ return FEATURES.map((feature) => feature.id);
65
+ }
66
+
67
+ function existingFeatureIds(current) {
68
+ const record = current && current['godpowers-features'];
69
+ return Array.isArray(record && record.known) ? record.known : [];
70
+ }
71
+
72
+ function missingFeatureIds(current) {
73
+ const known = new Set(existingFeatureIds(current));
74
+ return expectedFeatureIds().filter((id) => !known.has(id));
75
+ }
76
+
77
+ function sourceSystemsNeedJudgment(current) {
78
+ const systems = Array.isArray(current && current['source-systems'])
79
+ ? current['source-systems']
80
+ : [];
81
+ return systems.filter((system) => {
82
+ return system.confidence === 'low' || Number(system['conflict-count'] || 0) > 0;
83
+ });
84
+ }
85
+
86
+ function missingContextTargets(projectRoot) {
87
+ const status = contextWriter.status(projectRoot);
88
+ const missing = [];
89
+ if (!status.canonical.hasFence) missing.push('AGENTS.md');
90
+ for (const pointer of status.pointers) {
91
+ if (!pointer.hasFence) {
92
+ missing.push(path.relative(projectRoot, pointer.path).split(path.sep).join('/'));
93
+ }
94
+ }
95
+ return missing;
96
+ }
97
+
98
+ function detect(projectRoot, opts = {}) {
99
+ const current = state.read(projectRoot);
100
+ const runtimeVersion = opts.runtimeVersion || packageVersion(projectRoot);
101
+ if (!current) {
102
+ return {
103
+ initialized: false,
104
+ runtimeVersion,
105
+ actions: [],
106
+ missingFeatures: expectedFeatureIds(),
107
+ missingContext: [],
108
+ migrationCandidates: [],
109
+ spawnRecommendation: null
110
+ };
111
+ }
112
+
113
+ const record = current['godpowers-features'] || {};
114
+ const missingFeatures = missingFeatureIds(current);
115
+ const missingContext = missingContextTargets(projectRoot);
116
+ const migrationCandidates = planningSystems.detect(projectRoot).systems
117
+ .filter((system) => {
118
+ const configured = Array.isArray(current['source-systems'])
119
+ ? current['source-systems']
120
+ : [];
121
+ return !configured.some((entry) => entry.id === system.id);
122
+ })
123
+ .map((system) => ({
124
+ id: system.id,
125
+ name: system.name,
126
+ confidence: system.confidence,
127
+ files: system.files.length
128
+ }));
129
+
130
+ const actions = [];
131
+ if (record['runtime-version'] !== runtimeVersion) actions.push('record-runtime-version');
132
+ if (missingFeatures.length > 0) actions.push('record-feature-set');
133
+ if (missingContext.length > 0) actions.push('refresh-context');
134
+ if (migrationCandidates.length > 0) actions.push('suggest-god-migrate');
135
+
136
+ const needsJudgment = sourceSystemsNeedJudgment(current);
137
+ const lowConfidenceCandidates = migrationCandidates.filter((system) => system.confidence === 'low');
138
+ const spawnRecommendation = needsJudgment.length > 0 || lowConfidenceCandidates.length > 0
139
+ ? {
140
+ agent: 'god-greenfieldifier',
141
+ reason: 'Imported or detected planning-system context needs migration judgment.',
142
+ systems: [...needsJudgment.map((system) => system.id), ...lowConfidenceCandidates.map((system) => system.id)]
143
+ }
144
+ : null;
145
+
146
+ return {
147
+ initialized: true,
148
+ runtimeVersion,
149
+ featureSetVersion: FEATURE_SET_VERSION,
150
+ actions,
151
+ currentFeatures: existingFeatureIds(current),
152
+ expectedFeatures: FEATURES,
153
+ missingFeatures,
154
+ missingContext,
155
+ migrationCandidates,
156
+ spawnRecommendation
157
+ };
158
+ }
159
+
160
+ function buildFeatureRecord(runtimeVersion, now) {
161
+ return {
162
+ 'feature-set-version': FEATURE_SET_VERSION,
163
+ 'runtime-version': runtimeVersion,
164
+ known: expectedFeatureIds(),
165
+ 'last-awareness-refresh-at': now
166
+ };
167
+ }
168
+
169
+ function sameFeatureRecord(existing, next) {
170
+ if (!existing) return false;
171
+ return existing['feature-set-version'] === next['feature-set-version']
172
+ && existing['runtime-version'] === next['runtime-version']
173
+ && JSON.stringify(existing.known || []) === JSON.stringify(next.known || []);
174
+ }
175
+
176
+ function applyStateAwareness(projectRoot, current, runtimeVersion, now) {
177
+ const nextRecord = buildFeatureRecord(runtimeVersion, now);
178
+ if (sameFeatureRecord(current['godpowers-features'], nextRecord)) {
179
+ return { written: false, record: current['godpowers-features'] };
180
+ }
181
+ const nextState = {
182
+ ...current,
183
+ 'godpowers-features': nextRecord
184
+ };
185
+ state.write(projectRoot, nextState);
186
+ return { written: true, record: nextRecord };
187
+ }
188
+
189
+ function run(projectRoot, opts = {}) {
190
+ const before = detect(projectRoot, opts);
191
+ if (!before.initialized) {
192
+ return {
193
+ ...before,
194
+ applied: false,
195
+ stateWritten: false,
196
+ contextResults: [],
197
+ reason: '.godpowers/state.json not found'
198
+ };
199
+ }
200
+
201
+ const current = state.read(projectRoot);
202
+ const now = opts.now || new Date().toISOString();
203
+ const stateResult = applyStateAwareness(projectRoot, current, before.runtimeVersion, now);
204
+ const refreshedState = state.read(projectRoot);
205
+ const shouldRefreshContext = opts.refreshContext !== false;
206
+ const contextResults = shouldRefreshContext
207
+ ? contextWriter.apply(projectRoot, refreshedState, { projectRoot })
208
+ : [];
209
+ const after = detect(projectRoot, opts);
210
+
211
+ return {
212
+ ...after,
213
+ applied: true,
214
+ stateWritten: stateResult.written,
215
+ contextResults,
216
+ stateRecord: stateResult.record
217
+ };
218
+ }
219
+
220
+ module.exports = {
221
+ FEATURE_SET_VERSION,
222
+ FEATURES,
223
+ packageVersion,
224
+ detect,
225
+ run
226
+ };
package/lib/pillars.js CHANGED
@@ -80,6 +80,15 @@ const KNOWN_PILLARS = {
80
80
  };
81
81
 
82
82
  const ARTIFACT_PILLAR_MAP = [
83
+ { pattern: /^README\.md$/i, pillars: ['context', 'repo'] },
84
+ { pattern: /^CHANGELOG\.md$/i, pillars: ['context', 'deploy'] },
85
+ { pattern: /^RELEASE\.md$/i, pillars: ['context', 'deploy'] },
86
+ { pattern: /^CONTRIBUTING\.md$/i, pillars: ['repo', 'quality'] },
87
+ { pattern: /^SECURITY\.md$/i, pillars: ['security'] },
88
+ { pattern: /^SUPPORT\.md$/i, pillars: ['context'] },
89
+ { pattern: /^docs\/ROADMAP\.md$/i, pillars: ['context', 'quality'] },
90
+ { pattern: /^docs\/reference\.md$/i, pillars: ['repo'] },
91
+ { pattern: /^docs\/repo-doc-sync\.md$/i, pillars: ['repo', 'quality'] },
83
92
  { pattern: /(^|\/)prd\/PRD\.md$/i, pillars: ['context'] },
84
93
  { pattern: /(^|\/)arch\/ARCH\.md$/i, pillars: ['arch'] },
85
94
  { pattern: /(^|\/)arch\/adr\//i, pillars: ['arch'] },